@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)); }
@Override protected ErrorResponseBody prepareFrameworkRepresentation( final DefaultErrorContractDTO errorContractDTO, final int httpStatusCode, final Collection<ApiError> rawFilteredApiErrors, final Throwable originalException, final RequestInfoForLogging request ) { Throwable cause = originalException.getCause(); if (cause instanceof BlankPayloadErrorContractException) { return handleBlankErrorContract(); } if (cause instanceof DelegatedErrorContractException) { return handleDelegatedErrorContract((DelegatedErrorContractException) originalException.getCause()); } if (cause instanceof StringErrorContractException) { return handleStringErrorContract((StringErrorContractException) originalException.getCause()); } return super.prepareFrameworkRepresentation(errorContractDTO, httpStatusCode, rawFilteredApiErrors, originalException, request); }