use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class NonRestHttpMethodsFuzzerTest method shouldCallServiceAndReportWarnWhenServiceRespondsWith400.
@Test
void shouldCallServiceAndReportWarnWhenServiceRespondsWith400() {
FuzzingData data = FuzzingData.builder().pathItem(new PathItem()).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(400).httpMethod("POST").build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
nonRestHttpMethodsFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(17)).reportWarn(Mockito.any(), Mockito.anyString(), AdditionalMatchers.aryEq(new Object[] { "POST", 405, 400 }));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class NonRestHttpMethodsFuzzerTest method shouldCallServiceAndReportInfoWhenServiceRespondsWith405.
@Test
void shouldCallServiceAndReportInfoWhenServiceRespondsWith405() {
FuzzingData data = FuzzingData.builder().pathItem(new PathItem()).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(405).httpMethod("POST").build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
nonRestHttpMethodsFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(17)).reportInfo(Mockito.any(), Mockito.anyString(), AdditionalMatchers.aryEq(new Object[] { "POST", 405 }));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class NonRestHttpMethodsFuzzerTest method shouldCallServiceAndReportErrorWhenServiceRespondsWith200.
@Test
void shouldCallServiceAndReportErrorWhenServiceRespondsWith200() {
FuzzingData data = FuzzingData.builder().pathItem(new PathItem()).reqSchema(new StringSchema()).build();
CatsResponse catsResponse = CatsResponse.builder().body("{}").responseCode(200).httpMethod("POST").build();
Mockito.when(serviceCaller.call(Mockito.any())).thenReturn(catsResponse);
nonRestHttpMethodsFuzzer.fuzz(data);
Mockito.verify(testCaseListener, Mockito.times(17)).reportError(Mockito.any(), Mockito.anyString(), AdditionalMatchers.aryEq(new Object[] { "POST", 405, 200 }));
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class ServiceCallerTest method givenAServer_whenDoingATraceCall_thenProperDetailsAreBeingReturned.
@Test
void givenAServer_whenDoingATraceCall_thenProperDetailsAreBeingReturned() {
serviceCaller.initHttpClient();
serviceCaller.initRateLimiter();
CatsResponse catsResponse = serviceCaller.call(ServiceData.builder().relativePath("/pets/{id}").payload("{'id':'1'}").httpMethod(HttpMethod.TRACE).headers(Collections.singleton(CatsHeader.builder().name("header").value("header").build())).build());
Assertions.assertThat(catsResponse.responseCodeAsString()).isEqualTo("200");
Assertions.assertThat(catsResponse.getBody()).isEmpty();
}
use of com.endava.cats.model.CatsResponse in project cats by Endava.
the class ServiceCallerTest method givenAServer_whenDoingADeleteCall_thenProperDetailsAreBeingReturned.
@Test
void givenAServer_whenDoingADeleteCall_thenProperDetailsAreBeingReturned() {
serviceCaller.initHttpClient();
serviceCaller.initRateLimiter();
CatsResponse catsResponse = serviceCaller.call(ServiceData.builder().relativePath("/pets/{id}").payload("{'id':'1'}").httpMethod(HttpMethod.DELETE).headers(Collections.singleton(CatsHeader.builder().name("header").value("header").build())).build());
Assertions.assertThat(catsResponse.responseCodeAsString()).isEqualTo("200");
Assertions.assertThat(catsResponse.getBody()).isEmpty();
}
Aggregations