package com.griddynamics.jagger.engine.e1.collector;
import com.griddynamics.jagger.coordinator.NodeContext;
import com.griddynamics.jagger.invoker.v2.JHttpEndpoint;
import com.griddynamics.jagger.invoker.v2.JHttpQuery;
import com.griddynamics.jagger.invoker.v2.JHttpResponse;
import org.springframework.http.HttpStatus;
import java.util.Objects;
public class ExampleResponseValidatorProvider implements ResponseValidatorProvider {
private final String someValue;
public ExampleResponseValidatorProvider(String someValue) {this.someValue = someValue;}
@Override
String taskId,
NodeContext kernelContext) {
@Override
public String getName() {
return "Example response validator";
}
@Override
public boolean validate(JHttpQuery query, JHttpEndpoint endpoint, JHttpResponse result, long duration) {
if (Objects.equals(someValue, "we are always good")) {
return true;
}
return result.getStatus() == HttpStatus.OK;
}
};
}
}
We will add created validator to a particular test. You can add multiple validators to the same test. htey will be executed in the same sequence like they are added