use of com.nike.backstopper.model.DefaultErrorContractDTO in project riposte by Nike-Inc.
the class RiposteUnhandledExceptionHandlerTest method prepareFrameworkResponseUsesErrorResponseBodyNettyAdapterWrapper.
@Test
public void prepareFrameworkResponseUsesErrorResponseBodyNettyAdapterWrapper() {
RiposteUnhandledExceptionHandler myAdapter = new RiposteUnhandledExceptionHandler(projectApiErrors, utils);
DefaultErrorContractDTO errorContract = new DefaultErrorContractDTO(UUID.randomUUID().toString(), Arrays.asList(projectApiErrors.getUnauthorizedApiError(), projectApiErrors.getMalformedRequestApiError()));
ErrorResponseBody result = myAdapter.prepareFrameworkRepresentation(errorContract, 42, null, null, null);
assertThat(result, instanceOf(ErrorResponseBodyImpl.class));
ErrorResponseBodyImpl adapterResult = (ErrorResponseBodyImpl) result;
assertThat(adapterResult.error_id, is(errorContract.error_id));
assertThat(adapterResult.errors, is(errorContract.errors));
}
use of com.nike.backstopper.model.DefaultErrorContractDTO in project riposte by Nike-Inc.
the class VerifyPreEndpointExecutionWorkChainComponentTest method verifyErrorReceived.
private void verifyErrorReceived(ExtractableResponse response, ApiError expectedApiError) throws IOException {
assertThat(response.statusCode()).isEqualTo(expectedApiError.getHttpStatusCode());
DefaultErrorContractDTO responseAsError = objectMapper.readValue(response.asString(), DefaultErrorContractDTO.class);
assertThat(responseAsError.errors).hasSize(1);
assertThat(responseAsError.errors.get(0).code).isEqualTo(expectedApiError.getErrorCode());
assertThat(responseAsError.errors.get(0).message).isEqualTo(expectedApiError.getMessage());
}
use of com.nike.backstopper.model.DefaultErrorContractDTO in project riposte by Nike-Inc.
the class VerifyRequestAndResponseFilteringComponentTest method verifyErrorReceived.
private void verifyErrorReceived(ExtractableResponse response, ApiError expectedApiError) throws IOException {
assertThat(response.statusCode()).isEqualTo(expectedApiError.getHttpStatusCode());
DefaultErrorContractDTO responseAsError = objectMapper.readValue(response.asString(), DefaultErrorContractDTO.class);
assertThat(responseAsError.errors).hasSize(1);
assertThat(responseAsError.errors.get(0).code).isEqualTo(expectedApiError.getErrorCode());
assertThat(responseAsError.errors.get(0).message).isEqualTo(expectedApiError.getMessage());
assertThat(responseAsError.errors.get(0).metadata).isEqualTo(expectedApiError.getMetadata());
}
use of com.nike.backstopper.model.DefaultErrorContractDTO in project riposte by Nike-Inc.
the class VerifyTimeoutsAndProxyConnectionPoolingWorksComponentTest method verify_long_proxy_call_fails_with_timeout.
@Test
public void verify_long_proxy_call_fails_with_timeout() throws IOException, InterruptedException {
String responseString = given().baseUri("http://127.0.0.1").port(proxyServerShortCallTimeoutConfig.endpointsPort()).basePath(ProxyLongDelayTestEndpoint.MATCHING_PATH).header(LongDelayTestEndpoint.DELAY_MILLIS_HEADER_KEY, String.valueOf(proxyServerShortCallTimeoutConfig.defaultCompletableFutureTimeoutInMillisForNonblockingEndpoints() + 100)).log().all().when().get().then().log().all().statusCode(SampleCoreApiError.TEMPORARY_SERVICE_PROBLEM.getHttpStatusCode()).extract().asString();
DefaultErrorContractDTO errorContract = objectMapper.readValue(responseString, DefaultErrorContractDTO.class);
assertThat(errorContract).isNotNull();
assertThat(errorContract.errors.size()).isEqualTo(1);
assertThat(errorContract.errors.get(0).code).isEqualTo(SampleCoreApiError.TEMPORARY_SERVICE_PROBLEM.getErrorCode());
}
use of com.nike.backstopper.model.DefaultErrorContractDTO in project riposte by Nike-Inc.
the class ComponentTestUtils method verifyErrorReceived.
public static void verifyErrorReceived(String response, int responseStatusCode, ApiError expectedApiError) throws IOException {
assertThat(responseStatusCode).isEqualTo(expectedApiError.getHttpStatusCode());
DefaultErrorContractDTO responseAsError = objectMapper.readValue(response, DefaultErrorContractDTO.class);
assertThat(responseAsError.errors).hasSize(1);
assertThat(responseAsError.errors.get(0).code).isEqualTo(expectedApiError.getErrorCode());
assertThat(responseAsError.errors.get(0).message).isEqualTo(expectedApiError.getMessage());
assertThat(responseAsError.errors.get(0).metadata).isEqualTo(expectedApiError.getMetadata());
}
Aggregations