use of com.sequenceiq.it.cloudbreak.dto.mock.Method 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;
}
Aggregations