Search in sources :

Example 16 with InsertQuery

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);
}
Also used : GraknTx(ai.grakn.GraknTx) InsertQuery(ai.grakn.graql.InsertQuery) Test(org.junit.Test)

Example 17 with InsertQuery

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"));
}
Also used : InsertQuery(ai.grakn.graql.InsertQuery) Test(org.junit.Test)

Example 18 with InsertQuery

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"));
}
Also used : InsertQuery(ai.grakn.graql.InsertQuery) Test(org.junit.Test)

Example 19 with InsertQuery

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());
}
Also used : InsertQuery(ai.grakn.graql.InsertQuery) Test(org.junit.Test)

Example 20 with InsertQuery

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());
}
Also used : InsertQuery(ai.grakn.graql.InsertQuery)

Aggregations

InsertQuery (ai.grakn.graql.InsertQuery)31 Test (org.junit.Test)29 Answer (ai.grakn.graql.admin.Answer)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 QueryBuilder (ai.grakn.graql.QueryBuilder)3 GraknTx (ai.grakn.GraknTx)2 ConceptId (ai.grakn.concept.ConceptId)2 Entity (ai.grakn.concept.Entity)2 Label (ai.grakn.concept.Label)2 Relationship (ai.grakn.concept.Relationship)2 SchemaConcept (ai.grakn.concept.SchemaConcept)2 DeleteQuery (ai.grakn.graql.DeleteQuery)2 Graql (ai.grakn.graql.Graql)2 Graql.label (ai.grakn.graql.Graql.label)2 Graql.var (ai.grakn.graql.Graql.var)2 Match (ai.grakn.graql.Match)2 VarPattern (ai.grakn.graql.VarPattern)2 Conjunction (ai.grakn.graql.admin.Conjunction)2 PatternAdmin (ai.grakn.graql.admin.PatternAdmin)2 MovieKB (ai.grakn.test.kbs.MovieKB)2