Search in sources :

Example 1 with DeleteQuery

use of ai.grakn.graql.DeleteQuery in project grakn by graknlabs.

the class QueryParserTest method whenParsingDeleteQueryWithNoArguments_ResultIsSameAsJavaGraql.

@Test
public void whenParsingDeleteQueryWithNoArguments_ResultIsSameAsJavaGraql() {
    DeleteQuery expected = match(var("x").isa("movie").has("title", "The Title"), var("y").isa("movie")).delete();
    DeleteQuery parsed = parse("match $x isa movie has title 'The Title'; $y isa movie; delete;");
    assertEquals(expected, parsed);
}
Also used : DeleteQuery(ai.grakn.graql.DeleteQuery) Test(org.junit.Test)

Example 2 with DeleteQuery

use of ai.grakn.graql.DeleteQuery in project grakn by graknlabs.

the class DeleteQueryImplTest method deleteQueriesWithTheSameMatchAndVarsAreEqual.

@Test
public void deleteQueriesWithTheSameMatchAndVarsAreEqual() {
    DeleteQuery query1 = DeleteQueryImpl.of(vars1, match1);
    DeleteQuery query2 = DeleteQueryImpl.of(vars1, match1);
    assertEquals(query1, query2);
    assertEquals(query1.hashCode(), query2.hashCode());
}
Also used : DeleteQuery(ai.grakn.graql.DeleteQuery) Test(org.junit.Test)

Example 3 with DeleteQuery

use of ai.grakn.graql.DeleteQuery in project grakn by graknlabs.

the class DeleteQueryImplTest method deleteQueriesWithDifferentMatchesAreDifferent.

@Test
public void deleteQueriesWithDifferentMatchesAreDifferent() {
    DeleteQuery query1 = DeleteQueryImpl.of(vars1, match1);
    DeleteQuery query2 = DeleteQueryImpl.of(vars1, match2);
    assertNotEquals(query1, query2);
}
Also used : DeleteQuery(ai.grakn.graql.DeleteQuery) Test(org.junit.Test)

Example 4 with DeleteQuery

use of ai.grakn.graql.DeleteQuery in project grakn by graknlabs.

the class QueryBuilderTest method whenBuildingDeleteQueryWithGraphLast_ItExecutes.

@Test
public void whenBuildingDeleteQueryWithGraphLast_ItExecutes() {
    // Insert some data to delete
    movieKB.tx().graql().insert(var().has("title", "123").isa("movie")).execute();
    assertExists(movieKB.tx(), var().has("title", "123"));
    DeleteQuery query = match(x.has("title", "123")).delete(x).withTx(movieKB.tx());
    query.execute();
    assertNotExists(movieKB.tx(), var().has("title", "123"));
}
Also used : DeleteQuery(ai.grakn.graql.DeleteQuery) Test(org.junit.Test)

Example 5 with DeleteQuery

use of ai.grakn.graql.DeleteQuery in project grakn by graknlabs.

the class QueryParserTest method whenParsingDeleteQuery_ResultIsSameAsJavaGraql.

@Test
public void whenParsingDeleteQuery_ResultIsSameAsJavaGraql() {
    Var x = var("x");
    Var y = var("y");
    DeleteQuery expected = match(x.isa("movie").has("title", "The Title"), y.isa("movie")).delete(x, y);
    DeleteQuery parsed = parse("match $x isa movie has title 'The Title'; $y isa movie; delete $x, $y;");
    assertEquals(expected, parsed);
}
Also used : Var(ai.grakn.graql.Var) DeleteQuery(ai.grakn.graql.DeleteQuery) Test(org.junit.Test)

Aggregations

DeleteQuery (ai.grakn.graql.DeleteQuery)7 Test (org.junit.Test)7 Var (ai.grakn.graql.Var)1