Search in sources :

Example 1 with GraqlSyntaxException

use of ai.grakn.exception.GraqlSyntaxException in project grakn by graknlabs.

the class GraqlControllerDeleteTest method DELETEMalformedGraqlQuery_ResponseStatusIs400.

@Test
public void DELETEMalformedGraqlQuery_ResponseStatusIs400() {
    GraqlSyntaxException syntaxError = GraqlSyntaxException.create("syntax error");
    when(tx.graql().parser().parseQuery("match $x isa ; delete;")).thenThrow(syntaxError);
    String query = "match $x isa ; delete;";
    Response response = sendRequest(query);
    assertThat(response.statusCode(), equalTo(400));
}
Also used : Response(com.jayway.restassured.response.Response) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GraqlSyntaxException(ai.grakn.exception.GraqlSyntaxException) Test(org.junit.Test)

Example 2 with GraqlSyntaxException

use of ai.grakn.exception.GraqlSyntaxException in project grakn by graknlabs.

the class GraqlControllerDeleteTest method DELETEMalformedGraqlQuery_ResponseExceptionContainsSyntaxError.

@Test
public void DELETEMalformedGraqlQuery_ResponseExceptionContainsSyntaxError() {
    GraqlSyntaxException syntaxError = GraqlSyntaxException.create("syntax error");
    when(tx.graql().parser().parseQuery("match $x isa ; delete;")).thenThrow(syntaxError);
    String query = "match $x isa ; delete;";
    Response response = sendRequest(query);
    assertThat(exception(response), containsString("syntax error"));
}
Also used : Response(com.jayway.restassured.response.Response) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GraqlSyntaxException(ai.grakn.exception.GraqlSyntaxException) Test(org.junit.Test)

Example 3 with GraqlSyntaxException

use of ai.grakn.exception.GraqlSyntaxException in project grakn by graknlabs.

the class GraqlControllerInsertTest method POSTMalformedGraqlQuery_ResponseExceptionContainsSyntaxError.

@Test
public void POSTMalformedGraqlQuery_ResponseExceptionContainsSyntaxError() {
    GraqlSyntaxException syntaxError = GraqlSyntaxException.create("syntax error");
    when(tx.graql().parser().parseQuery("insert $x isa ;")).thenThrow(syntaxError);
    String query = "insert $x isa ;";
    Response response = sendRequest(query);
    assertThat(exception(response), containsString("syntax error"));
}
Also used : Response(com.jayway.restassured.response.Response) GraqlControllerReadOnlyTest.jsonResponse(ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GraqlSyntaxException(ai.grakn.exception.GraqlSyntaxException) Test(org.junit.Test)

Example 4 with GraqlSyntaxException

use of ai.grakn.exception.GraqlSyntaxException in project grakn by graknlabs.

the class GraqlControllerInsertTest method POSTMalformedGraqlQuery_ResponseStatusIs400.

@Test
public void POSTMalformedGraqlQuery_ResponseStatusIs400() {
    GraqlSyntaxException syntaxError = GraqlSyntaxException.create("syntax error");
    when(tx.graql().parser().parseQuery("insert $x isa ;")).thenThrow(syntaxError);
    String query = "insert $x isa ;";
    Response response = sendRequest(query);
    assertThat(response.statusCode(), equalTo(400));
}
Also used : Response(com.jayway.restassured.response.Response) GraqlControllerReadOnlyTest.jsonResponse(ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GraqlSyntaxException(ai.grakn.exception.GraqlSyntaxException) Test(org.junit.Test)

Aggregations

GraqlSyntaxException (ai.grakn.exception.GraqlSyntaxException)4 Response (com.jayway.restassured.response.Response)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 GraqlControllerReadOnlyTest.jsonResponse (ai.grakn.engine.controller.GraqlControllerReadOnlyTest.jsonResponse)2