use of com.sequenceiq.it.verification.Call in project cloudbreak by hortonworks.
the class DefaultResponseConfigure method verify.
public T verify() {
String callsJson;
if (crnless) {
callsJson = executeQuery.execute("/tests/calls", w -> w.queryParam("path", pathReplaced(path)), r -> r.readEntity(String.class));
} else {
callsJson = executeQuery.execute("/tests/calls/" + testDto.getCrn(), w -> w.queryParam("path", pathReplaced(path)), r -> r.readEntity(String.class));
}
Call[] calls;
try {
calls = new ObjectMapper().readValue(callsJson, Call[].class);
} catch (JsonProcessingException e) {
throw new TestFailException("Cannot deserialize calls: " + e.getMessage(), e);
}
if (calls == null) {
calls = new Call[0];
}
List<Call> collect = Arrays.stream(calls).filter(this::isPathMatched).filter(call -> call.getMethod().equalsIgnoreCase(method.toString())).filter(call -> parameterCheck(call.getParameters())).collect(Collectors.toList());
VerificationContext verificationContext = new VerificationContext(collect);
verifications.forEach(v -> {
v.handle(path, method, verificationContext);
});
List<String> errors = verificationContext.getErrors();
if (!errors.isEmpty()) {
throw new TestFailException("URL verification failed: " + System.lineSeparator() + String.join(System.lineSeparator(), errors));
}
return testDto;
}
use of com.sequenceiq.it.verification.Call in project cloudbreak by hortonworks.
the class TextBodyContainsVerification method handle.
@Override
public void handle(String path, Method method, VerificationContext context) {
List<Call> accepted = new ArrayList<>();
for (Call call : context.getCalls()) {
int count = StringUtils.countMatches(call.getPostBody(), body);
if (count == times) {
accepted.add(call);
}
}
if (accepted.isEmpty()) {
context.getErrors().add(body + " did not find in any call with " + times + " expected times.");
}
context.setCalls(accepted);
}
Aggregations