use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class OperationControllerIT method shouldReturnHelpfulErrorMessageIfOperationIsUnsupported.
@Test
public void shouldReturnHelpfulErrorMessageIfOperationIsUnsupported() {
// Given
Graph graph = new Graph.Builder().config(StreamUtil.graphConfig(this.getClass())).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(getGraphFactory().getGraph()).thenReturn(graph);
// When
final ResponseEntity<Error> response = post("/graph/operations/execute", new GetAllGraphIds(), Error.class);
// Then
assertNotNull(response.getBody().getSimpleMessage());
assertTrue(response.getBody().getSimpleMessage().contains("GetAllGraphIds is not supported by the MapStore"));
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class OperationControllerIT method shouldReturnHelpfulErrorMessageIfJsonIsIncorrect.
@Test
public void shouldReturnHelpfulErrorMessageIfJsonIsIncorrect() {
// Given
Graph graph = new Graph.Builder().config(StreamUtil.graphConfig(this.getClass())).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(getGraphFactory().getGraph()).thenReturn(graph);
// When
String request = "{\"class\"\"GetAllElements\"}";
LinkedMultiValueMap headers = new LinkedMultiValueMap();
headers.add("Content-Type", "application/json;charset=utf-8");
final ResponseEntity<Error> response = post("/graph/operations/execute", new HttpEntity(request, headers), Error.class);
// Then
assertEquals(400, response.getStatusCode().value());
assertEquals(400, response.getBody().getStatusCode());
assertTrue(response.getBody().getSimpleMessage().contains("was expecting a colon to separate field name and value"));
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class OperationControllerIT method shouldReturn403WhenUnauthorised.
@Test
public void shouldReturn403WhenUnauthorised() throws IOException {
// Given
Graph graph = new Graph.Builder().config(StreamUtil.graphConfig(this.getClass())).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(getGraphFactory().getGraph()).thenReturn(graph);
// When
final ResponseEntity<Error> response = post("/graph/operations/execute", new GetAllElements(), Error.class);
// Then
assertEquals(403, response.getStatusCode().value());
assertEquals(403, response.getBody().getStatusCode());
}
Aggregations