test(integrations): Properly check for RestErrors in responses now that JAX-RS exception mappers are
@@ -17,6 +17,7 @@ package com.redhat.ipaas.runtime;
import com.fasterxml.jackson.databind.JsonNode;
import com.redhat.ipaas.model.integration.Integration;
+import com.redhat.ipaas.rest.v1.handler.exception.RestError;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.HttpStatus;
@@ -45,11 +46,19 @@ public class IntegrationsITCase extends BaseITCase {
assertThat(response.getStatusCode()).as("status code").isEqualTo(HttpStatus.UNAUTHORIZED);
}
+ @Test
+ public void invalidSortField() {
+ ResponseEntity<RestError> response = get("/api/v1/integrations?sort=invalid_field", RestError.class, HttpStatus.BAD_REQUEST);
+ assertThat(response.getBody().getErrorCode()).isEqualTo(HttpStatus.BAD_REQUEST.value());
+ assertThat(response.getBody().getUserMsg()).isEqualTo("Please check your sorting arguments");
+ assertThat(response.getBody().getDeveloperMsg()).startsWith("Illegal Argument on Call");
+ }
+
@Test
public void createAndGetIntegration() {
// Verify that the integration does not exist.
- get("/api/v1/integrations/2001", Integration.class,
+ get("/api/v1/integrations/2001", RestError.class,
tokenRule.validToken(), HttpStatus.NOT_FOUND);
// Create the integration.
@@ -84,7 +93,7 @@ public class IntegrationsITCase extends BaseITCase {
delete("/api/v1/integrations/2001");
// We should not be able to fetch it again..
- get("/api/v1/integrations/2001", Integration.class,
+ get("/api/v1/integrations/2001", RestError.class,
tokenRule.validToken(), HttpStatus.NOT_FOUND);
