Search in sources :

Example 1 with ApiErrorBase

use of com.nike.backstopper.apierror.ApiErrorBase in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method constructor_sets_projectApiErrors_to_passed_in_arg.

@Test
public void constructor_sets_projectApiErrors_to_passed_in_arg() {
    // given
    ProjectApiErrors projectErrorsMock = mock(ProjectApiErrors.class);
    ApiError temporaryError = new ApiErrorBase("temp_error_for_test", 42, "temporary error", 503);
    doReturn(temporaryError).when(projectErrorsMock).getTemporaryServiceProblemApiError();
    // when
    BackstopperRiposteFrameworkErrorHandlerListener impl = new BackstopperRiposteFrameworkErrorHandlerListener(projectErrorsMock);
    // then
    assertThat(impl.projectApiErrors).isSameAs(projectErrorsMock);
}
Also used : ApiErrorBase(com.nike.backstopper.apierror.ApiErrorBase) ApiError(com.nike.backstopper.apierror.ApiError) ProjectApiErrors(com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors) Test(org.junit.Test)

Example 2 with ApiErrorBase

use of com.nike.backstopper.apierror.ApiErrorBase in project riposte by Nike-Inc.

the class VerifyMiscellaneousFunctionalityComponentTest method verify_proxy_router_response_modification_works_as_expected.

@Test
public void verify_proxy_router_response_modification_works_as_expected() throws IOException, InterruptedException {
    ExtractableResponse response = given().baseUri("http://127.0.0.1").port(serverConfig.endpointsPort()).basePath(ProxyRouterResponseModificationEndpoint.MATCHING_PATH).log().all().when().get().then().log().headers().extract();
    ApiError unmodifiedError = EmptyMetadataErrorThrower.ERROR_NO_METADATA;
    assertThat(response.statusCode()).isEqualTo(ProxyRouterResponseModificationEndpoint.MODIFIED_HTTP_STATUS_RESPONSE_CODE);
    assertThat(response.header(ProxyRouterResponseModificationEndpoint.ORIG_HTTP_STATUS_CODE_RESPONSE_HEADER_KEY)).isEqualTo(String.valueOf(unmodifiedError.getHttpStatusCode()));
    ApiError expectedModifiedError = new ApiErrorBase(unmodifiedError.getName(), unmodifiedError.getErrorCode(), unmodifiedError.getMessage(), ProxyRouterResponseModificationEndpoint.MODIFIED_HTTP_STATUS_RESPONSE_CODE);
    verifyErrorReceived(response, expectedModifiedError);
    assertThat(response.asString()).doesNotContain("metadata");
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) ApiErrorBase(com.nike.backstopper.apierror.ApiErrorBase) ApiError(com.nike.backstopper.apierror.ApiError) Test(org.junit.Test)

Aggregations

ApiError (com.nike.backstopper.apierror.ApiError)2 ApiErrorBase (com.nike.backstopper.apierror.ApiErrorBase)2 Test (org.junit.Test)2 ProjectApiErrors (com.nike.backstopper.apierror.projectspecificinfo.ProjectApiErrors)1 ExtractableResponse (io.restassured.response.ExtractableResponse)1