use of net.opengis.ows.v_1_0_0.ExceptionReport in project ddf by codice.
the class CswExceptionMapperTest method testCswExceptionToServiceExceptionReportWithLocatorAndCode.
@Test
public void testCswExceptionToServiceExceptionReportWithLocatorAndCode() {
CswException exception = new CswException(SERVICE_EXCEPTION_MSG, Status.BAD_REQUEST.getStatusCode(), EXCEPTION_CODE, LOCATOR);
ExceptionMapper<Throwable> exceptionMapper = new CswExceptionMapper();
Response response = exceptionMapper.toResponse(exception);
assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
ExceptionReport exceptionReport = (ExceptionReport) response.getEntity();
assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
assertThat(SERVICE_EXCEPTION_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
assertThat(EXCEPTION_CODE, is(exceptionReport.getException().get(0).getExceptionCode()));
assertThat(LOCATOR, is(exceptionReport.getException().get(0).getLocator()));
}
use of net.opengis.ows.v_1_0_0.ExceptionReport in project ddf by codice.
the class CswExceptionMapper method createServiceException.
private ExceptionReport createServiceException(CswException cswException) {
ExceptionReport exceptionReport = new ExceptionReport();
exceptionReport.setVersion(SERVICE_EXCEPTION_REPORT_VERSION);
ExceptionType exception = new ExceptionType();
exception.setExceptionCode(cswException.getExceptionCode());
exception.setLocator(cswException.getLocator());
exception.getExceptionText().add(cswException.getMessage());
exceptionReport.getException().add(exception);
return exceptionReport;
}
Aggregations