Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
ExampleResponseValidatorProvider.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.engine.e1.collector;
2 
3 import com.griddynamics.jagger.coordinator.NodeContext;
4 import com.griddynamics.jagger.invoker.v2.JHttpEndpoint;
5 import com.griddynamics.jagger.invoker.v2.JHttpQuery;
6 import com.griddynamics.jagger.invoker.v2.JHttpResponse;
7 import org.springframework.http.HttpStatus;
8 
9 import java.util.Objects;
10 
21 
22  private final String someValue;
23 
24  /* Constructor allows to pass parameters to the validator */
25  public ExampleResponseValidatorProvider(String someValue) {this.someValue = someValue;}
26 
27  @Override
29  String taskId,
30  NodeContext kernelContext) {
31 
32  return new ResponseValidator<JHttpQuery, JHttpEndpoint, JHttpResponse>(taskId, sessionId, kernelContext) {
33  @Override
34  /* This name will be displayed in the reports */
35  public String getName() {
36  return "Example response validator";
37  }
38 
39  @Override
40  /* Validator logic in defined here */
41  public boolean validate(JHttpQuery query, JHttpEndpoint endpoint, JHttpResponse result, long duration) {
42  if (Objects.equals(someValue, "we are always good")) {
43  return true;
44  }
45  return result.getStatus() == HttpStatus.OK;
46  }
47  };
48  }
49 }
50 
51