Search in sources :

Example 1 with SimbaUnavailableExceptionToJSONMapper

use of org.simbasecurity.dwclient.exception.mapper.SimbaUnavailableExceptionToJSONMapper in project simba-os by cegeka.

the class SimbaUnavailableExceptionToJSONMapperTest method toResponse_ReturnsJSONValidationError.

@Test
public void toResponse_ReturnsJSONValidationError() throws Exception {
    SimbaUnavailableExceptionToJSONMapper mapperUnderTest = new SimbaUnavailableExceptionToJSONMapper();
    SimbaUnavailableException simbaUnavailableException = new SimbaUnavailableException();
    DWSimbaErrorR expectedEntity = new DWSimbaErrorR(HttpStatus.INTERNAL_SERVER_ERROR.getDescription(), SimbaUnavailableExceptionToJSONMapper.SIMBA_ERROR_MESSAGE, null);
    MediaType expectedMediaType = MediaType.APPLICATION_JSON_TYPE;
    int expectedStatus = 500;
    Response actual = mapperUnderTest.toResponse(simbaUnavailableException);
    assertThat(actual.getStatus()).isEqualTo(expectedStatus);
    assertThat((MediaType) actual.getMetadata().get("Content-Type").get(0)).isEqualTo(expectedMediaType);
    assertThat(actual.getEntity()).isEqualsToByComparingFields(expectedEntity);
}
Also used : Response(javax.ws.rs.core.Response) DWSimbaErrorR(org.simbasecurity.dwclient.dropwizard.representation.DWSimbaErrorR) MediaType(javax.ws.rs.core.MediaType) SimbaUnavailableException(org.simbasecurity.dwclient.exception.SimbaUnavailableException) SimbaUnavailableExceptionToJSONMapper(org.simbasecurity.dwclient.exception.mapper.SimbaUnavailableExceptionToJSONMapper) Test(org.junit.Test)

Aggregations

MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 DWSimbaErrorR (org.simbasecurity.dwclient.dropwizard.representation.DWSimbaErrorR)1 SimbaUnavailableException (org.simbasecurity.dwclient.exception.SimbaUnavailableException)1 SimbaUnavailableExceptionToJSONMapper (org.simbasecurity.dwclient.exception.mapper.SimbaUnavailableExceptionToJSONMapper)1