use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class InsertQueryImplTest method insertQueriesWithDifferentGraphsAreDifferent.
@Test
public void insertQueriesWithDifferentGraphsAreDifferent() {
GraknTx graph1 = mock(GraknTx.class);
GraknTx graph2 = mock(GraknTx.class);
InsertQuery query1 = InsertQueryImpl.create(vars1, Optional.empty(), Optional.of(graph1));
InsertQuery query2 = InsertQueryImpl.create(vars2, Optional.empty(), Optional.of(graph2));
assertNotEquals(query1, query2);
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class QueryBuilderTest method whenBuildingMatchInsertQueryWithGraphLast_ItExecutes.
@Test
public void whenBuildingMatchInsertQueryWithGraphLast_ItExecutes() {
assertNotExists(movieKB.tx(), var().has("title", "a-movie"));
InsertQuery query = match(x.label("movie")).insert(var().has("title", "a-movie").isa("movie")).withTx(movieKB.tx());
query.execute();
assertExists(movieKB.tx(), var().has("title", "a-movie"));
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class QueryBuilderTest method whenBuildingInsertQueryWithGraphLast_ItExecutes.
@Test
public void whenBuildingInsertQueryWithGraphLast_ItExecutes() {
assertNotExists(movieKB.tx(), var().has("title", "a-movie"));
InsertQuery query = insert(var().has("title", "a-movie").isa("movie")).withTx(movieKB.tx());
query.execute();
assertExists(movieKB.tx(), var().has("title", "a-movie"));
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class QueryToStringTest method testMatchInsertToString.
@Test
public void testMatchInsertToString() {
InsertQuery query = qb.match(var("x").isa("movie")).insert(var("x").has("title", "hello"));
assertEquals("match $x isa movie;\ninsert $x has title \"hello\";", query.toString());
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class QueryToStringTest method assertValidToString.
private void assertValidToString(InsertQuery query) {
// No need to execute the insert query
InsertQuery parsedQuery = qb.parse(query.toString());
assertEquals(query.toString(), parsedQuery.toString());
}
Aggregations