use of ai.grakn.exception.GraknTxOperationException in project grakn by graknlabs.
the class GraqlControllerDeleteTest method DELETEGraqlDeleteNotValid_ResponseStatusCodeIs422.
@Test
public void DELETEGraqlDeleteNotValid_ResponseStatusCodeIs422() {
GraknTxOperationException exception = GraknTxOperationException.cannotBeDeleted(mock(SchemaConcept.class));
// Not allowed to delete roles with incoming edges
when(tx.graql().parser().parseQuery("undefine production-being-directed sub work;").execute()).thenThrow(exception);
Response response = sendRequest("undefine production-being-directed sub work;");
assertThat(response.statusCode(), equalTo(422));
}
use of ai.grakn.exception.GraknTxOperationException in project grakn by graknlabs.
the class GraknTxTest method failAtOpeningTx.
private void failAtOpeningTx(GraknSession session, GraknTxType txType, String keyspace) {
Exception exception = null;
try {
// noinspection ResultOfMethodCallIgnored
session.open(txType);
} catch (GraknTxOperationException e) {
exception = e;
}
assertNotNull(exception);
assertThat(exception, instanceOf(GraknTxOperationException.class));
assertEquals(exception.getMessage(), ErrorMessage.TRANSACTION_ALREADY_OPEN.getMessage(keyspace));
}
use of ai.grakn.exception.GraknTxOperationException in project grakn by graknlabs.
the class GraqlControllerInsertTest method POSTGraqlDefineNotValid_ResponseExceptionContainsValidationErrorMessage.
@Test
public void POSTGraqlDefineNotValid_ResponseExceptionContainsValidationErrorMessage() {
GraknTxOperationException exception = GraknTxOperationException.invalidCasting(Object.class, Object.class);
when(tx.graql().parser().parseQuery("define person plays movie;").execute()).thenThrow(exception);
Response response = sendRequest("define person plays movie;");
assertThat(exception(response), containsString("is not of type"));
}
Aggregations