Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
JLoadTest.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.user.test.configurations;
2 
3 import com.griddynamics.jagger.engine.e1.Provider;
4 import com.griddynamics.jagger.engine.e1.collector.test.TestListener;
5 import com.griddynamics.jagger.user.test.configurations.auxiliary.Id;
6 import com.griddynamics.jagger.user.test.configurations.limits.JLimit;
7 import com.griddynamics.jagger.user.test.configurations.load.JLoadProfile;
8 import com.griddynamics.jagger.user.test.configurations.termination.JTerminationCriteria;
9 
10 import com.google.common.collect.Lists;
11 
12 import java.util.Arrays;
13 import java.util.LinkedList;
14 import java.util.List;
15 import java.util.Objects;
16 
34 public class JLoadTest {
35 
36  private final String id;
37  private final JLoadProfile load;
38  private final JTestDefinition testDescription;
39  private final JTerminationCriteria termination;
40  private final List<JLimit> limits;
41  private final List<Provider<TestListener>> listeners;
42 
43  private JLoadTest(Builder builder) {
44  this.id = builder.id.value();
45  this.testDescription = builder.jTestDefinition;
46  this.load = builder.load;
47  this.termination = builder.termination;
48  this.limits = builder.limits;
49  this.listeners = builder.listeners;
50  }
51 
62  public static Builder builder(Id id, JTestDefinition definition, JLoadProfile load, JTerminationCriteria termination) {
63  return new Builder(id, definition, load, termination);
64  }
65 
66  public static class Builder {
67  private final Id id;
68  private final JTestDefinition jTestDefinition;
69  private final JLoadProfile load;
70  private final JTerminationCriteria termination;
71  private List<JLimit> limits;
72 
73  private List<Provider<TestListener>> listeners = Lists.newArrayList();
74 
75  private Builder(Id id, JTestDefinition jTestDefinition, JLoadProfile load, JTerminationCriteria termination) {
76  this.id = id;
77  this.jTestDefinition = jTestDefinition;
78  this.load = load;
79  this.termination = termination;
80  this.limits = new LinkedList<>();
81  }
82 
93  public Builder addListeners(List<Provider<TestListener>> listeners) {
94  this.listeners.addAll(listeners);
95  return this;
96  }
97 
108  public Builder addListener(Provider<TestListener> listener) {
109  this.listeners.add(listener);
110  return this;
111  }
112 
118  public Builder withLimits(JLimit... limits) {
119  Objects.requireNonNull(limits);
120  this.limits = Arrays.asList(limits);
121  return this;
122  }
123 
129  public Builder withLimits(List<JLimit> limits) {
130  Objects.requireNonNull(limits);
131  this.limits = limits;
132  return this;
133  }
134 
140  public JLoadTest build() {
141  return new JLoadTest(this);
142  }
143  }
144 
145  public String getId() {
146  return id;
147  }
148 
150  return testDescription;
151  }
152 
154  return load;
155  }
156 
158  return termination;
159  }
160 
161  public List<JLimit> getLimits() {
162  return limits;
163  }
164 
165  public List<Provider<TestListener>> getListeners() {
166  return listeners;
167  }
168 }