Search in sources :

Example 6 with GraknTxOperationException

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));
}
Also used : Response(com.jayway.restassured.response.Response) GraknTxOperationException(ai.grakn.exception.GraknTxOperationException) SchemaConcept(ai.grakn.concept.SchemaConcept) Test(org.junit.Test)

Example 7 with GraknTxOperationException

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));
}
Also used : GraknTxOperationException(ai.grakn.exception.GraknTxOperationException) InvalidKBException(ai.grakn.exception.InvalidKBException) GraknTxOperationException(ai.grakn.exception.GraknTxOperationException) VerificationException(org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with GraknTxOperationException

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"));
}
Also used : Response(com.jayway.restassured.response.Response) GraqlControllerReadOnlyTest.jsonResponse(ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse) GraknTxOperationException(ai.grakn.exception.GraknTxOperationException) Test(org.junit.Test)

Aggregations

GraknTxOperationException (ai.grakn.exception.GraknTxOperationException)8 Test (org.junit.Test)6 Response (com.jayway.restassured.response.Response)4 SchemaConcept (ai.grakn.concept.SchemaConcept)2 GraqlControllerReadOnlyTest.jsonResponse (ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse)2 Collection (java.util.Collection)2 GraknTx (ai.grakn.GraknTx)1 Attribute (ai.grakn.concept.Attribute)1 AttributeType (ai.grakn.concept.AttributeType)1 InvalidKBException (ai.grakn.exception.InvalidKBException)1 Property (com.pholser.junit.quickcheck.Property)1 ExecutionException (java.util.concurrent.ExecutionException)1 VerificationException (org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.VerificationException)1