use of com.nike.riposte.server.error.handler.ErrorResponseBody in project riposte by Nike-Inc.
the class RiposteApiExceptionHandlerTest method prepareFrameworkResponseUsesErrorResponseBodyNettyAdapterWrapper.
@Test
public void prepareFrameworkResponseUsesErrorResponseBodyNettyAdapterWrapper() {
RiposteApiExceptionHandler myAdapter = new RiposteApiExceptionHandler(projectApiErrors, validListenerList, 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.riposte.server.error.handler.ErrorResponseBody in project riposte by Nike-Inc.
the class ErrorResponseInfoImplTest method constructorWithIndividualArgsSetsValues.
@Test
public void constructorWithIndividualArgsSetsValues() {
ErrorResponseBody bodyMock = mock(ErrorResponseBody.class);
int httpStatusCode = 42;
Map<String, List<String>> headers = MapBuilder.<String, List<String>>builder().put("someHeader", Arrays.asList("hval1", "hval2")).build();
ErrorResponseInfoImpl adapter = new ErrorResponseInfoImpl(bodyMock, httpStatusCode, headers);
assertThat(adapter.errorResponseBody, sameInstance(bodyMock));
assertThat(adapter.httpStatusCode, is(httpStatusCode));
assertThat(adapter.headersToAddToResponse, is(headers));
}
use of com.nike.riposte.server.error.handler.ErrorResponseBody in project riposte by Nike-Inc.
the class ErrorResponseInfoImplTest method constructorWithErrorResponseInfoArgsSetsValues.
@Test
public void constructorWithErrorResponseInfoArgsSetsValues() {
ErrorResponseBody bodyMock = mock(ErrorResponseBody.class);
int httpStatusCode = 42;
Map<String, List<String>> headers = MapBuilder.<String, List<String>>builder().put("someHeader", Arrays.asList("hval1", "hval2")).build();
ErrorResponseInfo<ErrorResponseBody> backstopperErrorResponseInfo = new ErrorResponseInfo<>(httpStatusCode, bodyMock, headers);
ErrorResponseInfoImpl adapter = new ErrorResponseInfoImpl(backstopperErrorResponseInfo);
assertThat(adapter.errorResponseBody, sameInstance(bodyMock));
assertThat(adapter.httpStatusCode, is(httpStatusCode));
assertThat(adapter.headersToAddToResponse, is(headers));
}
use of com.nike.riposte.server.error.handler.ErrorResponseBody in project riposte by Nike-Inc.
the class RiposteUnhandledExceptionHandlerTest method handleErrorFromNettyInterfaceReturnsWrapperAroundBackstopperHandleExceptionReturnValue.
@Test
public void handleErrorFromNettyInterfaceReturnsWrapperAroundBackstopperHandleExceptionReturnValue() {
ErrorResponseBody errorResponseBodyMock = mock(ErrorResponseBody.class);
Map<String, List<String>> headersMap = MapBuilder.<String, List<String>>builder().put("headerName", Arrays.asList("hval1", "hval2")).build();
com.nike.backstopper.handler.ErrorResponseInfo<ErrorResponseBody> backstopperResponse = new ErrorResponseInfo<>(42, errorResponseBodyMock, headersMap);
doReturn(backstopperResponse).when(adapterSpy).handleException(any(Throwable.class), any(RequestInfoForLogging.class));
com.nike.riposte.server.error.handler.ErrorResponseInfo riposteErrorResponseInfo = adapterSpy.handleError(new Exception(), mock(RequestInfo.class));
assertThat(riposteErrorResponseInfo, instanceOf(ErrorResponseInfoImpl.class));
assertThat(riposteErrorResponseInfo.getErrorHttpStatusCode(), is(backstopperResponse.httpStatusCode));
assertThat(riposteErrorResponseInfo.getErrorResponseBody(), is(errorResponseBodyMock));
assertThat(riposteErrorResponseInfo.getExtraHeadersToAddToResponse(), is(headersMap));
}
Aggregations