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.google.common.collect.Lists;
4 import com.griddynamics.jagger.engine.e1.Provider;
5 import com.griddynamics.jagger.engine.e1.collector.test.TestListener;
6 import com.griddynamics.jagger.user.test.configurations.auxiliary.Id;
7 import com.griddynamics.jagger.user.test.configurations.limits.JLimit;
8 import com.griddynamics.jagger.user.test.configurations.load.JLoadProfile;
9 import com.griddynamics.jagger.user.test.configurations.termination.JTerminationCriteria;
10 
11 import java.util.Arrays;
12 import java.util.LinkedList;
13 import java.util.List;
14 import java.util.Objects;
15 
33 public class JLoadTest {
34 
35  private final String id;
36  private final JLoadProfile load;
37  private final JTestDefinition testDescription;
38  private final JTerminationCriteria termination;
39  private final List<JLimit> limits;
40  private final List<Provider<TestListener>> listeners;
41 
42  private JLoadTest(Builder builder) {
43  this.id = builder.id.value();
44  this.testDescription = builder.jTestDefinition;
45  this.load = builder.load;
46  this.termination = builder.termination;
47  this.limits = builder.limits;
48  this.listeners = builder.listeners;
49  }
50 
61  public static Builder builder(Id id, JTestDefinition definition, JLoadProfile load, JTerminationCriteria termination) {
62  return new Builder(id, definition, load, termination);
63  }
64 
65  public static class Builder {
66  private final Id id;
67  private final JTestDefinition jTestDefinition;
68  private final JLoadProfile load;
69  private final JTerminationCriteria termination;
70  private List<JLimit> limits;
71 
72  private List<Provider<TestListener>> listeners = Lists.newArrayList();
73 
74  private Builder(Id id, JTestDefinition jTestDefinition, JLoadProfile load, JTerminationCriteria termination) {
75  this.id = id;
76  this.jTestDefinition = jTestDefinition;
77  this.load = load;
78  this.termination = termination;
79  this.limits = new LinkedList<>();
80  }
81 
92  public Builder addListeners(List<Provider<TestListener>> listeners) {
93  this.listeners.addAll(listeners);
94  return this;
95  }
96 
107  public Builder addListener(Provider<TestListener> listener) {
108  this.listeners.add(listener);
109  return this;
110  }
111 
117  public Builder withLimits(JLimit... limits) {
118  Objects.requireNonNull(limits);
119  this.limits = Arrays.asList(limits);
120  return this;
121  }
122 
128  public Builder withLimits(List<JLimit> limits) {
129  Objects.requireNonNull(limits);
130  this.limits = limits;
131  return this;
132  }
133 
139  public JLoadTest build() {
140  return new JLoadTest(this);
141  }
142  }
143 
144  public String getId() {
145  return id;
146  }
147 
149  return testDescription;
150  }
151 
153  return load;
154  }
155 
157  return termination;
158  }
159 
160  public List<JLimit> getLimits() {
161  return limits;
162  }
163 
164  public List<Provider<TestListener>> getListeners() {
165  return listeners;
166  }
167 }