use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class DirectIsaTest method testInsertSyntax.
@Test
public void testInsertSyntax() {
QueryBuilder queryBuilder = tx.graql();
InsertQuery insertQuery;
insertQuery = queryBuilder.insert(x.directIsa(thingy));
assertEquals("insert $x isa! thingy;", insertQuery.toString());
insertQuery = queryBuilder.parse("insert $x isa! thingy;");
assertEquals(queryBuilder.insert(x.directIsa(thingy)), insertQuery);
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class AdminTest method testInsertQueryMatchPatternEmpty.
@Test
public void testInsertQueryMatchPatternEmpty() {
InsertQuery query = qb.insert(var().id(ConceptId.of("123")).isa("movie"));
assertFalse(query.admin().match().isPresent());
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class AdminTest method testInsertQueryWithMatch.
@Test
public void testInsertQueryWithMatch() {
InsertQuery query = qb.match(var("x").isa("movie")).insert(var().id(ConceptId.of("123")).isa("movie"));
assertEquals(Optional.of("match $x isa movie;"), query.admin().match().map(Object::toString));
query = qb.match(var("x").directIsa("movie")).insert(var().id(ConceptId.of("123")).isa("movie"));
assertEquals(Optional.of("match $x isa! movie;"), query.admin().match().map(Object::toString));
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class AdminTest method testMatchInsertQueryGetTypes.
@Test
public void testMatchInsertQueryGetTypes() {
InsertQuery query = qb.match(var("y").isa("movie")).insert(var("x").isa("person").has("name", var("z")), var().rel("actor", "x").isa("has-cast"));
Set<SchemaConcept> types = Stream.of("movie", "person", "name", "actor", "has-cast").map(t -> rule.tx().<SchemaConcept>getSchemaConcept(Label.of(t))).collect(toSet());
assertEquals(types, query.admin().getSchemaConcepts());
}
use of ai.grakn.graql.InsertQuery in project grakn by graknlabs.
the class AdminTest method testInsertQueryGetTypes.
@Test
public void testInsertQueryGetTypes() {
InsertQuery query = qb.insert(var("x").isa("person").has("name", var("y")), var().rel("actor", "x").isa("has-cast"));
Set<SchemaConcept> types = Stream.of("person", "name", "actor", "has-cast").map(t -> rule.tx().<SchemaConcept>getSchemaConcept(Label.of(t))).collect(toSet());
assertEquals(types, query.admin().getSchemaConcepts());
}
Aggregations