use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class GraphConfigurationControllerIT method shouldReturn500WhenANonExistentClassIsProvidedEndingInClassForGetFilterFunctions.
@Test
public void shouldReturn500WhenANonExistentClassIsProvidedEndingInClassForGetFilterFunctions() {
// Given
Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(graphFactory.getGraph()).thenReturn(emptyGraph);
// When
ResponseEntity<Error> response = get("/graph/config/filterFunctions/a.random.class", Error.class);
// Then
checkResponse(response, 500);
assertThat(response.getBody().getSimpleMessage()).isEqualTo("Could not find input class: a.random.class");
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class OperationControllerIT method shouldPropagateStatusInformationContainedInOperationExceptionsThrownByOperationHandlers.
@Test
public void shouldPropagateStatusInformationContainedInOperationExceptionsThrownByOperationHandlers() throws IOException {
// Given
final StoreProperties storeProperties = new MapStoreProperties();
storeProperties.set(StoreProperties.JOB_TRACKER_ENABLED, Boolean.FALSE.toString());
final Graph graph = new Graph.Builder().config(StreamUtil.graphConfig(this.getClass())).storeProperties(storeProperties).addSchema(new Schema()).build();
when(getGraphFactory().getGraph()).thenReturn(graph);
// When
final ResponseEntity<Error> response = post("/graph/operations/execute", new GetAllJobDetails(), Error.class);
// Then
assertEquals(SERVICE_UNAVAILABLE.getStatusCode(), response.getStatusCode().value());
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class GraphConfigurationControllerIT method shouldReturn500WhenANonExistentClassIsProvidedForGetFilterFunctions.
@Test
public void shouldReturn500WhenANonExistentClassIsProvidedForGetFilterFunctions() {
// Given
Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(graphFactory.getGraph()).thenReturn(emptyGraph);
// When
ResponseEntity<Error> response = get("/graph/config/filterFunctions/a.random.thing", Error.class);
// Then
checkResponse(response, 500);
assertThat(response.getBody().getSimpleMessage()).isEqualTo("Could not find input class: a.random.thing");
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class ProxyStore method handleResponse.
protected <O> O handleResponse(final Response response, final ResponseDeserialiser<O> responseDeserialiser) throws StoreException {
final String outputJson = response.hasEntity() ? response.readEntity(String.class) : null;
if (Family.SUCCESSFUL != response.getStatusInfo().getFamily()) {
final Error error;
try {
error = JSONSerialiser.deserialise(StringUtil.toBytes(outputJson), Error.class);
} catch (final Exception e) {
LOGGER.warn("Gaffer bad status {}. Detail: {}", response.getStatus(), outputJson);
throw new StoreException("Delegate Gaffer store returned status: " + response.getStatus() + ". Response content was: " + outputJson);
}
throw new GafferWrappedErrorRuntimeException(error);
}
O output = null;
if (null != outputJson) {
try {
output = responseDeserialiser.deserialise(outputJson);
} catch (final SerialisationException e) {
throw new StoreException(e.getMessage(), e);
}
}
return output;
}
use of uk.gov.gchq.gaffer.core.exception.Error in project Gaffer by gchq.
the class GraphConfigurationControllerIT method shouldReturn500WhenANonExistentClassIsProvidedForGetSerialiseFields.
@Test
public void shouldReturn500WhenANonExistentClassIsProvidedForGetSerialiseFields() {
// Given
Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
when(graphFactory.getGraph()).thenReturn(emptyGraph);
// When
ResponseEntity<Error> response = get("/graph/config/serialisedFields/a.random.class", Error.class);
// Then
checkResponse(response, 500);
assertThat(response.getBody().getSimpleMessage()).isEqualTo("Class name was not recognised: a.random.class");
}
Aggregations