use of com.endava.cats.model.report.CatsTestCase in project cats by Endava.
the class TestCaseListenerTest method givenADocumentedResponseThatMatchesTheResponseCodeAndButNotSchema_whenReportingTheResult_thenTheResultIsCorrectlyReported.
@Test
void givenADocumentedResponseThatMatchesTheResponseCodeAndButNotSchema_whenReportingTheResult_thenTheResultIsCorrectlyReported() {
FuzzingData data = Mockito.mock(FuzzingData.class);
CatsResponse response = Mockito.mock(CatsResponse.class);
Mockito.when(response.getBody()).thenReturn("{'test':1}");
Mockito.when(data.getResponseCodes()).thenReturn(Collections.singleton("200"));
Mockito.when(data.getResponses()).thenReturn(Collections.singletonMap("200", Collections.singletonList("nomatch")));
Mockito.when(response.responseCodeAsString()).thenReturn("200");
testCaseListener.createAndExecuteTest(logger, fuzzer, () -> testCaseListener.reportResult(logger, data, response, ResponseCodeFamily.TWOXX));
Mockito.verify(executionStatisticsListener, Mockito.times(1)).increaseWarns();
Mockito.verify(executionStatisticsListener, Mockito.never()).increaseSuccess();
CatsTestCase testCase = testCaseListener.testCaseMap.get("Test 1");
Assertions.assertThat(testCase.getResultDetails()).startsWith("Response does NOT match expected result. Response code");
}
use of com.endava.cats.model.report.CatsTestCase in project cats by Endava.
the class ReplayCommand method executeTestCase.
public void executeTestCase(String testCaseFileName) throws IOException {
String testCaseFile = Files.readString(Paths.get(testCaseFileName));
LOGGER.note("Loaded content: \n" + testCaseFile);
CatsTestCase testCase = JsonUtils.GSON.fromJson(testCaseFile, CatsTestCase.class);
LOGGER.info("Calling service...");
CatsResponse response = serviceCaller.callService(testCase.getRequest(), Collections.emptySet());
LOGGER.complete("Response body: \n{}", JsonUtils.GSON.toJson(response.getJsonBody()));
}
use of com.endava.cats.model.report.CatsTestCase in project cats by Endava.
the class TestCaseListener method setResultReason.
private void setResultReason(CatsResult catsResult) {
CatsTestCase testCase = testCaseMap.get(MDC.get(ID));
testCase.setResultReason(catsResult.getReason());
}
use of com.endava.cats.model.report.CatsTestCase in project cats by Endava.
the class TestCaseListener method recordResult.
private void recordResult(String message, Object[] params, String success) {
CatsTestCase testCase = testCaseMap.get(MDC.get(ID));
testCase.setResult(success);
testCase.setResultDetails(replaceBrackets(message, params));
}
use of com.endava.cats.model.report.CatsTestCase in project cats by Endava.
the class TestCaseListener method startTestCase.
private void startTestCase() {
testCaseMap.put(MDC.get(ID), new CatsTestCase());
testCaseMap.get(MDC.get(ID)).setTestId(MDC.get(ID));
}
Aggregations