Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
JLoadScenario.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.user.test.configurations;
2 
3 import com.griddynamics.jagger.user.test.configurations.auxiliary.Id;
4 
5 import java.util.ArrayList;
6 import java.util.Collections;
7 import java.util.List;
8 import java.util.Objects;
9 
27 public class JLoadScenario {
28 
29  private final String id;
30  private final List<JParallelTestsGroup> testGroups;
31  private final List<Double> percentileValues;
32 
33  private JLoadScenario(Builder builder) {
34  this.id = builder.id.value();
35  this.testGroups = builder.testGroups;
36  this.percentileValues = builder.percentileValues;
37  }
38 
46  public static Builder builder(Id id, List<JParallelTestsGroup> testGroups) {
47  return new Builder(id, testGroups);
48  }
49 
58  public static Builder builder(Id id, JParallelTestsGroup testGroup, JParallelTestsGroup... testGroups) {
59  List<JParallelTestsGroup> jParallelTestsGroupList = new ArrayList<>();
60  jParallelTestsGroupList.add(testGroup);
61  Collections.addAll(jParallelTestsGroupList, testGroups);
62 
63  return new Builder(id, jParallelTestsGroupList);
64  }
65 
66  public static class Builder {
67  private final Id id;
68  private final List<JParallelTestsGroup> testGroups;
69  private List<Double> percentileValues;
70  public Builder(Id id, List<JParallelTestsGroup> testGroups) {
71  this.id = id;
72  this.testGroups = testGroups;
73  }
74 
79  public Builder withLatencyPercentiles(List<Double> percentileValues) {
80  Objects.requireNonNull(percentileValues);
81  percentileValues.stream().filter(percentile -> percentile <= 0.0 || percentile >= 100.0)
82  .findAny()
83  .ifPresent(badPercentile -> {
84  throw new IllegalArgumentException("Percentile value must be > 0 and < 100. Provided value is " + badPercentile);
85  });
86 
87  this.percentileValues = percentileValues;
88  return this;
89  }
90 
96  public JLoadScenario build() {
97  return new JLoadScenario(this);
98  }
99 
100  }
101 
102  public List<JParallelTestsGroup> getTestGroups() {
103  return testGroups;
104  }
105 
106  public String getId() {
107  return id;
108  }
109 
110  public List<Double> getPercentileValues() {
111  return percentileValues;
112  }
113 }