Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
JTestDefinition.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.user.test.configurations;
2 
3 import com.griddynamics.jagger.engine.e1.collector.ResponseValidator;
4 import com.griddynamics.jagger.invoker.Invoker;
5 import com.griddynamics.jagger.invoker.v2.DefaultHttpInvoker;
6 import com.griddynamics.jagger.user.test.configurations.auxiliary.Id;
7 
8 import java.util.Collections;
9 import java.util.List;
10 
26 public class JTestDefinition {
27 
28  private final String id;
29  private final Iterable endpoints;
30 
31  private String comment;
32  private Iterable queries;
33  private Class<? extends Invoker> invoker;
34  private List<Class<? extends ResponseValidator>> validators;
35 
37  this.id = builder.id.value();
38  this.endpoints = builder.endpointsProvider;
39 
40  this.comment = builder.comment;
41  if (this.comment == null) {
42  this.comment = "";
43  }
44  this.queries = builder.queries;
45  this.invoker = builder.invoker;
46  this.validators = builder.validators;
47  }
48 
56  public static Builder builder(Id id, Iterable endpointsProvider) {
57  return new Builder(id, endpointsProvider);
58  }
59 
60  public static class Builder {
61  private final Id id;
62  private final Iterable endpointsProvider;
63 
64  private String comment = "";
65  private Iterable queries;
66  private Class<? extends Invoker> invoker = DefaultHttpInvoker.class;
67  private List<Class<? extends ResponseValidator>> validators = Collections.emptyList();
68 
69  private Builder(Id id, Iterable endpointsProvider) {
70  this.id = id;
71  this.endpointsProvider = endpointsProvider;
72  }
73 
78  public Builder withComment(String comment) {
79  this.comment = comment;
80  return this;
81  }
82 
89  public Builder withQueryProvider(Iterable queryProvider) {
90  this.queries = queryProvider;
91  return this;
92  }
93 
103  public Builder withInvoker(Class<? extends Invoker> invoker) {
104  this.invoker = invoker;
105  return this;
106  }
107 
117  public Builder withValidators(List<Class<? extends ResponseValidator>> validators) {
118  this.validators = validators;
119  return this;
120  }
121 
128  return new JTestDefinition(this);
129  }
130  }
131 
132  public String getId() {
133  return id;
134  }
135 
136  public String getDescription() {
137  return comment;
138  }
139 
140  public Iterable getEndpoints() {
141  return endpoints;
142  }
143 
144  public Iterable getQueries() {
145  return queries;
146  }
147 
148  public Class<? extends Invoker> getInvoker() {
149  return invoker;
150  }
151 
152  public String getComment() {
153  return comment;
154  }
155 
156  public List<Class<? extends ResponseValidator>> getValidators() {
157  return validators;
158  }
159 }