Search in sources :

Example 6 with TypeQLQuery

use of com.vaticle.typeql.lang.query.TypeQLQuery in project grakn by graknlabs.

the class StatisticsTest method setupSchema.

private void setupSchema(CoreDatabaseManager databaseMgr) {
    try (TypeDB.Session session = databaseMgr.session(database, Arguments.Session.Type.SCHEMA)) {
        try (TypeDB.Transaction tx = session.transaction(Arguments.Transaction.Type.WRITE)) {
            TypeQLQuery query = TypeQL.parseQuery("" + "define " + "person sub entity, owns age; " + "age sub attribute, value long; " + "");
            tx.query().define(query.asDefine());
            tx.commit();
        }
    }
}
Also used : TypeDB(com.vaticle.typedb.core.TypeDB) TypeQLQuery(com.vaticle.typeql.lang.query.TypeQLQuery)

Example 7 with TypeQLQuery

use of com.vaticle.typeql.lang.query.TypeQLQuery in project typeql-lang-java by vaticle.

the class ParserTest method testParseList.

@Test
public void testParseList() {
    final String insertString = "insert\n$x isa movie;";
    final String getString = "match\n$y isa movie;";
    List<TypeQLQuery> queries = TypeQL.parseQueries(insertString + getString).collect(toList());
    assertEquals(list(insert(var("x").isa("movie")), match(var("y").isa("movie"))), queries);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TypeQLQuery(com.vaticle.typeql.lang.query.TypeQLQuery) Test(org.junit.Test)

Example 8 with TypeQLQuery

use of com.vaticle.typeql.lang.query.TypeQLQuery in project typeql-lang-java by vaticle.

the class TypeQLQueryTest method assertValidToString.

private void assertValidToString(TypeQLQuery query) {
    // No need to execute the insert query
    TypeQLQuery parsedQuery = TypeQL.parseQuery(query.toString());
    assertEquals(query.toString(), parsedQuery.toString());
}
Also used : TypeQLQuery(com.vaticle.typeql.lang.query.TypeQLQuery)

Example 9 with TypeQLQuery

use of com.vaticle.typeql.lang.query.TypeQLQuery in project typeql-lang-java by vaticle.

the class ParserTest method testParseListOneInsert.

@Test
public void testParseListOneInsert() {
    final String insertString = "insert\n$x isa movie;";
    List<TypeQLQuery> queries = TypeQL.parseQueries(insertString).collect(toList());
    assertEquals(list(insert(var("x").isa("movie"))), queries);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TypeQLQuery(com.vaticle.typeql.lang.query.TypeQLQuery) Test(org.junit.Test)

Example 10 with TypeQLQuery

use of com.vaticle.typeql.lang.query.TypeQLQuery in project typeql-lang-java by vaticle.

the class ParserTest method testParseListOneInsertWithPrefixComment.

@Test
public void testParseListOneInsertWithPrefixComment() {
    final String insertString = "#hola\ninsert $x isa movie;";
    List<TypeQLQuery> queries = TypeQL.parseQueries(insertString).collect(toList());
    assertEquals(list(insert(var("x").isa("movie"))), queries);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TypeQLQuery(com.vaticle.typeql.lang.query.TypeQLQuery) Test(org.junit.Test)

Aggregations

TypeQLQuery (com.vaticle.typeql.lang.query.TypeQLQuery)11 Test (org.junit.Test)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 TypeQLMatch (com.vaticle.typeql.lang.query.TypeQLMatch)2 TypeDB (com.vaticle.typedb.core.TypeDB)1 ConceptMap (com.vaticle.typedb.core.concept.answer.ConceptMap)1 Attribute (com.vaticle.typedb.core.concept.thing.Attribute)1 Conjunction (com.vaticle.typeql.lang.pattern.Conjunction)1 Given (io.cucumber.java.en.Given)1