use of com.redhat.service.smartevents.infra.api.models.responses.ErrorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ErrorsAPITest method testGetList.
@Test
void testGetList() {
ErrorListResponse response = given().contentType(ContentType.JSON).when().get(APIConstants.ERROR_API_BASE_PATH).as(ErrorListResponse.class);
assertThat(exceptionClasses).hasSize((int) response.getTotal());
assertThat(response.getItems().isEmpty()).isFalse();
for (ErrorResponse item : response.getItems()) {
assertThat(item).isEqualTo(given().contentType(ContentType.JSON).when().get(item.getHref()).as(ErrorResponse.class));
}
}
use of com.redhat.service.smartevents.infra.api.models.responses.ErrorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ExternalUserExceptionMapper method toResponse.
@Override
public Response toResponse(ExternalUserException e) {
LOGGER.debug("Failure", e);
Optional<BridgeError> error = bridgeErrorService.getError(e);
ResponseBuilder builder = Response.status(e.getStatusCode());
if (error.isPresent()) {
ErrorResponse errorResponse = ErrorResponse.from(error.get());
errorResponse.setReason(e.getMessage());
builder.entity(errorResponse);
} else {
LOGGER.warn("Information for exception type {} cannot be found", e.getClass());
builder.entity(e.getMessage());
}
return builder.build();
}
use of com.redhat.service.smartevents.infra.api.models.responses.ErrorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class InternalPlatformExceptionMapper method toResponse.
@Override
public Response toResponse(InternalPlatformException e) {
LOGGER.warn("Internal Platform exception", e);
// InternalPlatformException is always returned.
Response.ResponseBuilder builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
ErrorResponse errorResponse = ErrorResponse.from(internalPlatformExceptionBridgeError);
errorResponse.setReason(String.format(MESSAGE_TEMPLATE, e.getClass().getName(), e.getMessage()));
builder.entity(errorResponse);
return builder.build();
}
use of com.redhat.service.smartevents.infra.api.models.responses.ErrorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesAPITest method getNonExistingBridge.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getNonExistingBridge() {
ErrorResponse response = TestUtils.getBridge("not-the-id").then().statusCode(404).extract().as(ErrorResponse.class);
assertThat(response.getId()).isEqualTo("4");
assertThat(response.getCode()).endsWith("4");
assertThat(response.getReason()).isNotBlank();
}
Aggregations