Search in sources :

Example 1 with TypeDB

use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.

the class BasicTest method write_different_attributes_in_parallel_successfully.

@Test
public void write_different_attributes_in_parallel_successfully() throws IOException {
    LocalDateTime date_1991_2_3_4_5 = LocalDateTime.of(1991, 2, 3, 4, 5);
    LocalDateTime date_1992_3_4_5_6 = LocalDateTime.of(1992, 3, 4, 5, 6);
    LocalDateTime date_1993_4_5_6_7 = LocalDateTime.of(1993, 4, 5, 6, 7);
    reset_directory_and_create_attribute_types();
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.DATA)) {
            TypeDB.Transaction txn1 = session.transaction(Arguments.Transaction.Type.WRITE);
            TypeDB.Transaction txn2 = session.transaction(Arguments.Transaction.Type.WRITE);
            TypeDB.Transaction txn3 = session.transaction(Arguments.Transaction.Type.WRITE);
            isAlive(txn1).put(true);
            isAlive(txn2).put(false);
            age(txn1).put(17);
            age(txn2).put(18);
            age(txn3).put(19);
            score(txn1).put(70.5);
            score(txn2).put(80.6);
            score(txn3).put(90.7);
            name(txn1).put("alice");
            name(txn2).put("bob");
            name(txn3).put("charlie");
            dob(txn1).put(date_1991_2_3_4_5);
            dob(txn2).put(date_1992_3_4_5_6);
            dob(txn3).put(date_1993_4_5_6_7);
            assertEquals(1, isAlive(txn1).getInstances().count());
            assertTrue(isAlive(txn1).getInstances().anyMatch(att -> att.getValue().equals(true)));
            assertEquals(1, isAlive(txn2).getInstances().count());
            assertTrue(isAlive(txn2).getInstances().anyMatch(att -> att.getValue().equals(false)));
            assertEquals(1, age(txn1).getInstances().count());
            assertTrue(age(txn1).getInstances().anyMatch(att -> att.getValue() == 17));
            assertEquals(1, age(txn2).getInstances().count());
            assertTrue(age(txn2).getInstances().anyMatch(att -> att.getValue() == 18));
            assertEquals(1, age(txn3).getInstances().count());
            assertTrue(age(txn3).getInstances().anyMatch(att -> att.getValue() == 19));
            assertEquals(1, score(txn1).getInstances().count());
            assertTrue(score(txn1).getInstances().anyMatch(att -> att.getValue() == 70.5));
            assertEquals(1, score(txn2).getInstances().count());
            assertTrue(score(txn2).getInstances().anyMatch(att -> att.getValue() == 80.6));
            assertEquals(1, score(txn3).getInstances().count());
            assertTrue(score(txn3).getInstances().anyMatch(att -> att.getValue() == 90.7));
            assertEquals(1, name(txn1).getInstances().count());
            assertTrue(name(txn1).getInstances().anyMatch(att -> att.getValue().equals("alice")));
            assertEquals(1, name(txn2).getInstances().count());
            assertTrue(name(txn2).getInstances().anyMatch(att -> att.getValue().equals("bob")));
            assertEquals(1, name(txn3).getInstances().count());
            assertTrue(name(txn3).getInstances().anyMatch(att -> att.getValue().equals("charlie")));
            assertEquals(1, dob(txn1).getInstances().count());
            assertTrue(dob(txn1).getInstances().anyMatch(att -> att.getValue().equals(date_1991_2_3_4_5)));
            assertEquals(1, dob(txn2).getInstances().count());
            assertTrue(dob(txn2).getInstances().anyMatch(att -> att.getValue().equals(date_1992_3_4_5_6)));
            assertEquals(1, dob(txn3).getInstances().count());
            assertTrue(dob(txn3).getInstances().anyMatch(att -> att.getValue().equals(date_1993_4_5_6_7)));
            txn1.commit();
            txn2.commit();
            txn3.commit();
            try (TypeDB.Transaction txn = session.transaction(Arguments.Transaction.Type.READ)) {
                LocalDateTime d1 = LocalDateTime.of(1991, 2, 3, 4, 5);
                LocalDateTime d2 = LocalDateTime.of(1992, 3, 4, 5, 6);
                LocalDateTime d3 = LocalDateTime.of(1993, 4, 5, 6, 7);
                assertEquals(true, isAlive(txn).get(true).getValue());
                assertEquals(false, isAlive(txn).get(false).getValue());
                assertEquals(17, age(txn).get(17).getValue().longValue());
                assertEquals(18, age(txn).get(18).getValue().longValue());
                assertEquals(19, age(txn).get(19).getValue().longValue());
                assertEquals(70.5, score(txn).get(70.5).getValue(), 0.001);
                assertEquals(80.6, score(txn).get(80.6).getValue(), 0.001);
                assertEquals(90.7, score(txn).get(90.7).getValue(), 0.001);
                assertEquals("alice", name(txn).get("alice").getValue());
                assertEquals("bob", name(txn).get("bob").getValue());
                assertEquals("charlie", name(txn).get("charlie").getValue());
                assertEquals(d1, dob(txn).get(d1).getValue());
                assertEquals(d2, dob(txn).get(d2).getValue());
                assertEquals(d3, dob(txn).get(d3).getValue());
                assertEquals(2, isAlive(txn).getInstances().count());
                assertTrue(isAlive(txn).getInstances().anyMatch(att -> att.getValue().equals(true)));
                assertTrue(isAlive(txn).getInstances().anyMatch(att -> att.getValue().equals(false)));
                assertEquals(3, age(txn).getInstances().count());
                assertTrue(age(txn).getInstances().anyMatch(att -> att.getValue() == 17));
                assertTrue(age(txn).getInstances().anyMatch(att -> att.getValue() == 18));
                assertTrue(age(txn).getInstances().anyMatch(att -> att.getValue() == 19));
                assertEquals(3, score(txn).getInstances().count());
                assertTrue(score(txn).getInstances().anyMatch(att -> att.getValue() == 70.5));
                assertTrue(score(txn).getInstances().anyMatch(att -> att.getValue() == 80.6));
                assertTrue(score(txn).getInstances().anyMatch(att -> att.getValue() == 90.7));
                assertEquals(3, name(txn).getInstances().count());
                assertTrue(name(txn).getInstances().anyMatch(att -> att.getValue().equals("alice")));
                assertTrue(name(txn).getInstances().anyMatch(att -> att.getValue().equals("bob")));
                assertTrue(name(txn).getInstances().anyMatch(att -> att.getValue().equals("charlie")));
                assertEquals(3, dob(txn).getInstances().count());
                assertTrue(dob(txn).getInstances().anyMatch(att -> att.getValue().equals(date_1991_2_3_4_5)));
                assertTrue(dob(txn).getInstances().anyMatch(att -> att.getValue().equals(date_1992_3_4_5_6)));
                assertTrue(dob(txn).getInstances().anyMatch(att -> att.getValue().equals(date_1993_4_5_6_7)));
            }
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ConceptManager(com.vaticle.typedb.core.concept.ConceptManager) LocalDateTime(java.time.LocalDateTime) MB(com.vaticle.typedb.core.common.collection.Bytes.MB) Util.assertNotNulls(com.vaticle.typedb.core.test.integration.util.Util.assertNotNulls) RelationType(com.vaticle.typedb.core.concept.type.RelationType) LONG(com.vaticle.typedb.core.concept.type.AttributeType.ValueType.LONG) Arguments(com.vaticle.typedb.core.common.parameters.Arguments) LogicManager(com.vaticle.typedb.core.logic.LogicManager) Rule(com.vaticle.typedb.core.logic.Rule) STRING(com.vaticle.typedb.core.concept.type.AttributeType.ValueType.STRING) ThingType(com.vaticle.typedb.core.concept.type.ThingType) Assert.fail(org.junit.Assert.fail) Path(java.nio.file.Path) TypeQL(com.vaticle.typeql.lang.TypeQL) CoreDatabaseManager(com.vaticle.typedb.core.database.CoreDatabaseManager) Options(com.vaticle.typedb.core.common.parameters.Options) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Pattern(com.vaticle.typeql.lang.pattern.Pattern) RoleType(com.vaticle.typedb.core.concept.type.RoleType) Consumer(java.util.function.Consumer) TypeDB(com.vaticle.typedb.core.TypeDB) ThingVariable(com.vaticle.typeql.lang.pattern.variable.ThingVariable) Stream(java.util.stream.Stream) Assert.assertNull(org.junit.Assert.assertNull) DATETIME(com.vaticle.typedb.core.concept.type.AttributeType.ValueType.DATETIME) Paths(java.nio.file.Paths) Attribute(com.vaticle.typedb.core.concept.thing.Attribute) DOUBLE(com.vaticle.typedb.core.concept.type.AttributeType.ValueType.DOUBLE) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) EntityType(com.vaticle.typedb.core.concept.type.EntityType) BOOLEAN(com.vaticle.typedb.core.concept.type.AttributeType.ValueType.BOOLEAN) Assert.assertEquals(org.junit.Assert.assertEquals) Util(com.vaticle.typedb.core.test.integration.util.Util) TypeDB(com.vaticle.typedb.core.TypeDB) Test(org.junit.Test)

Example 2 with TypeDB

use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.

the class BasicTest method write_and_retrieve_attribute_ownership_rule.

@Test
public void write_and_retrieve_attribute_ownership_rule() throws IOException {
    Util.resetDirectory(dataDir);
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        typedb.create(database);
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.SCHEMA)) {
            try (TypeDB.Transaction txn = session.transaction(Arguments.Transaction.Type.WRITE)) {
                ConceptManager conceptMgr = txn.concepts();
                LogicManager logicMgr = txn.logic();
                AttributeType name = conceptMgr.putAttributeType("name", STRING);
                EntityType person = conceptMgr.putEntityType("person");
                RelationType friendship = conceptMgr.putRelationType("friendship");
                friendship.setRelates("friend");
                person.setPlays(friendship.getRelates("friend"));
                person.setOwns(name);
                logicMgr.putRule("people-have-names", TypeQL.parsePattern("{$x isa person; }").asConjunction(), TypeQL.parseVariable("$x has name \"i have a name\"").asThing());
                txn.commit();
            }
            try (TypeDB.Transaction txn = session.transaction(Arguments.Transaction.Type.READ)) {
                ConceptManager conceptMgr = txn.concepts();
                LogicManager logicMgr = txn.logic();
                Rule rule = logicMgr.getRule("people-have-names");
                Pattern when = rule.getWhenPreNormalised();
                ThingVariable<?> then = rule.getThenPreNormalised();
                assertEquals(TypeQL.parsePattern("{$x isa person;}"), when);
                assertEquals(TypeQL.parseVariable("$x has name \"i have a name\""), then);
            }
        }
    }
}
Also used : ConceptManager(com.vaticle.typedb.core.concept.ConceptManager) EntityType(com.vaticle.typedb.core.concept.type.EntityType) Pattern(com.vaticle.typeql.lang.pattern.Pattern) LogicManager(com.vaticle.typedb.core.logic.LogicManager) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) RelationType(com.vaticle.typedb.core.concept.type.RelationType) Rule(com.vaticle.typedb.core.logic.Rule) TypeDB(com.vaticle.typedb.core.TypeDB) Test(org.junit.Test)

Example 3 with TypeDB

use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.

the class BasicTest method write_types_concurrently.

@Test
public void write_types_concurrently() throws IOException, InterruptedException {
    Util.resetDirectory(dataDir);
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        typedb.create(database);
        assertTrue(typedb.isOpen());
        assertEquals(1, typedb.all().size());
        assertEquals(database, typedb.all().iterator().next().name());
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.SCHEMA)) {
            assertTrue(session.isOpen());
            assertEquals(database, session.database().name());
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.READ)) {
                assertTrue(transaction.isOpen());
                assertTrue(transaction.type().isRead());
                Stream<Consumer<TypeDB.Transaction>> rootTypeAssertions = Stream.of(tx -> {
                    ThingType rootType = tx.concepts().getRootThingType();
                    assertNotNull(rootType);
                }, tx -> {
                    EntityType rootEntityType = tx.concepts().getRootEntityType();
                    assertNotNull(rootEntityType);
                }, tx -> {
                    RelationType rootRelationType = tx.concepts().getRootRelationType();
                    assertNotNull(rootRelationType);
                }, tx -> {
                    AttributeType rootAttributeType = tx.concepts().getRootAttributeType();
                    assertNotNull(rootAttributeType);
                });
                rootTypeAssertions.parallel().forEach(assertion -> assertion.accept(transaction));
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                assertTrue(transaction.isOpen());
                assertTrue(transaction.type().isWrite());
                ThingType rootType = transaction.concepts().getRootThingType();
                EntityType rootEntityType = transaction.concepts().getRootEntityType();
                RelationType rootRelationType = transaction.concepts().getRootRelationType();
                AttributeType rootAttributeType = transaction.concepts().getRootAttributeType();
                Util.assertNotNulls(rootType, rootEntityType, rootRelationType, rootAttributeType);
                Stream<Consumer<TypeDB.Transaction>> typeAssertions = Stream.of(tx -> {
                    AttributeType name = tx.concepts().putAttributeType("name", STRING).asString();
                    Util.assertNotNulls(name);
                    assertEquals(rootAttributeType, name.getSupertype());
                }, tx -> {
                    AttributeType.Long age = tx.concepts().putAttributeType("age", LONG).asLong();
                    Util.assertNotNulls(age);
                    assertEquals(rootAttributeType, age.getSupertype());
                }, tx -> {
                    RelationType marriage = tx.concepts().putRelationType("marriage");
                    marriage.setRelates("husband");
                    marriage.setRelates("wife");
                    Util.assertNotNulls(marriage);
                    assertEquals(rootRelationType, marriage.getSupertype());
                }, tx -> {
                    RelationType employment = tx.concepts().putRelationType("employment");
                    employment.setRelates("employee");
                    employment.setRelates("employer");
                    Util.assertNotNulls(employment);
                    assertEquals(rootRelationType, employment.getSupertype());
                }, tx -> {
                    EntityType person = tx.concepts().putEntityType("person");
                    Util.assertNotNulls(person);
                    assertEquals(rootEntityType, person.getSupertype());
                    Stream<Consumer<TypeDB.Transaction>> subPersonAssertions = Stream.of(tx2 -> {
                        EntityType man = tx2.concepts().putEntityType("man");
                        man.setSupertype(person);
                        Util.assertNotNulls(man);
                        assertEquals(person, man.getSupertype());
                    }, tx2 -> {
                        EntityType woman = tx2.concepts().putEntityType("woman");
                        woman.setSupertype(person);
                        Util.assertNotNulls(woman);
                        assertEquals(person, woman.getSupertype());
                    });
                    subPersonAssertions.parallel().forEach(assertions -> assertions.accept(tx));
                }, tx -> {
                    EntityType company = tx.concepts().putEntityType("company");
                    Util.assertNotNulls(company);
                    assertEquals(rootEntityType, company.getSupertype());
                });
                typeAssertions.parallel().forEach(assertion -> assertion.accept(transaction));
                transaction.commit();
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.READ)) {
                assert_transaction_read(transaction);
            }
        }
    }
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        assertTrue(typedb.isOpen());
        assertEquals(1, typedb.all().size());
        assertEquals(database, typedb.all().iterator().next().name());
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.SCHEMA)) {
            assertTrue(session.isOpen());
            assertEquals(database, session.database().name());
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.READ)) {
                assert_transaction_read(transaction);
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                AttributeType.String gender = transaction.concepts().putAttributeType("gender", STRING).asString();
                EntityType school = transaction.concepts().putEntityType("school");
                RelationType teaching = transaction.concepts().putRelationType("teaching");
                teaching.setRelates("teacher");
                teaching.setRelates("student");
                RoleType teacher = teaching.getRelates("teacher");
                RoleType student = teaching.getRelates("student");
                Util.assertNotNulls(gender, school, teaching, teacher, student);
                transaction.commit();
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.READ)) {
                assert_transaction_read(transaction);
                AttributeType.String gender = transaction.concepts().getAttributeType("gender").asString();
                EntityType school = transaction.concepts().getEntityType("school");
                RelationType teaching = transaction.concepts().getRelationType("teaching");
                RoleType teacher = teaching.getRelates("teacher");
                RoleType student = teaching.getRelates("student");
                Util.assertNotNulls(gender, school, teaching, teacher, student);
            }
        }
    }
}
Also used : RoleType(com.vaticle.typedb.core.concept.type.RoleType) TypeDB(com.vaticle.typedb.core.TypeDB) ThingType(com.vaticle.typedb.core.concept.type.ThingType) EntityType(com.vaticle.typedb.core.concept.type.EntityType) Consumer(java.util.function.Consumer) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) RelationType(com.vaticle.typedb.core.concept.type.RelationType) Test(org.junit.Test)

Example 4 with TypeDB

use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.

the class QueryTest method test_query_insert.

@Test
public void test_query_insert() throws IOException {
    Util.resetDirectory(dataDir);
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        typedb.create(database);
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.SCHEMA)) {
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                TypeQLDefine query = TypeQL.parseQuery(new String(Files.readAllBytes(Paths.get("test/integration/schema.tql")), UTF_8));
                transaction.query().define(query);
                transaction.commit();
            }
        }
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.DATA)) {
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                String queryString = "insert " + "$n 'vaticle' isa name; " + "$o isa organisation, has name $n; " + "$t isa team, has name 'engineers', has symbol 'vaticle/engineers'; " + "$u isa user, has name 'butler', has email 'butler@vaticle.com'; " + "($o, $t) isa org-team; " + "($o, $u) isa org-member; " + "($t, $u) isa team-member;";
                TypeQLInsert query = TypeQL.parseQuery(queryString);
                transaction.query().insert(query);
                transaction.commit();
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.READ)) {
                Attribute.String name_vaticle = transaction.concepts().getAttributeType("name").asString().get("vaticle");
                Attribute.String symbol_engineers = transaction.concepts().getAttributeType("symbol").asString().get("vaticle/engineers");
                Attribute.String email_butler = transaction.concepts().getAttributeType("email").asString().get("butler@vaticle.com");
                assertNotNulls(name_vaticle, symbol_engineers, email_butler);
                Entity organisation_vaticle = name_vaticle.getOwners().first().get().asEntity();
                Entity team_engineers = symbol_engineers.getOwners().first().get().asEntity();
                Entity user_butler = email_butler.getOwners().first().get().asEntity();
                assertNotNulls(organisation_vaticle, team_engineers, user_butler);
                assertEquals(organisation_vaticle.getRelations("org-team:org").first().get().getPlayers("team").first().get(), team_engineers);
                assertEquals(organisation_vaticle.getRelations("org-member:org").first().get().getPlayers("member").first().get(), user_butler);
                assertEquals(team_engineers.getRelations("team-member:team").first().get().getPlayers("member").first().get(), user_butler);
            }
        }
    }
}
Also used : Entity(com.vaticle.typedb.core.concept.thing.Entity) TypeQLDefine(com.vaticle.typeql.lang.query.TypeQLDefine) Attribute(com.vaticle.typedb.core.concept.thing.Attribute) TypeDB(com.vaticle.typedb.core.TypeDB) TypeQLInsert(com.vaticle.typeql.lang.query.TypeQLInsert) Test(org.junit.Test)

Example 5 with TypeDB

use of com.vaticle.typedb.core.TypeDB in project grakn by graknlabs.

the class QueryTest method test_query_undefine.

@Test
public void test_query_undefine() throws IOException {
    Util.resetDirectory(dataDir);
    try (TypeDB.DatabaseManager typedb = CoreDatabaseManager.open(options)) {
        typedb.create(database);
        try (TypeDB.Session session = typedb.session(database, Arguments.Session.Type.SCHEMA)) {
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                TypeQLDefine query = TypeQL.parseQuery(new String(Files.readAllBytes(Paths.get("test/integration/schema.tql")), UTF_8));
                transaction.query().define(query);
                transaction.commit();
            }
            try (TypeDB.Transaction transaction = session.transaction(Arguments.Transaction.Type.WRITE)) {
                String queryString = "undefine analysis abstract, owns created, plays commit-analysis:analysis;";
                TypeQLUndefine query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine rule performance-tracker-rule;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine performance-tracker relates tracker;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine email regex '.+\\@.+\\..+';";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine index sub attribute, value long;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                // undefine first 4 rules
                queryString = "undefine rule repo-fork-rule;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine rule repo-dependency-transitive-rule;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine rule repo-dependency-transitive-type-rule;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                queryString = "undefine rule repo-collaborator-org-rule;";
                query = TypeQL.parseQuery(queryString);
                transaction.query().undefine(query);
                transaction.commit();
            }
            try (TypeDB.Transaction tx = session.transaction(Arguments.Transaction.Type.READ)) {
                EntityType analysis = tx.concepts().getEntityType("analysis");
                RelationType performanceTracker = tx.concepts().getRelationType("performance-tracker");
                RoleType commitAnalysisAnalysis = tx.concepts().getRelationType("commit-analysis").getRelates("analysis");
                AttributeType.DateTime created = tx.concepts().getAttributeType("created").asDateTime();
                AttributeType.String email = tx.concepts().getAttributeType("email").asString();
                assertNotNulls(analysis, performanceTracker, commitAnalysisAnalysis, created, email);
                assertFalse(analysis.isAbstract());
                assertTrue(analysis.getOwns().noneMatch(att -> att.equals(created)));
                assertTrue(analysis.getPlays().noneMatch(rol -> rol.equals(commitAnalysisAnalysis)));
                assertTrue(performanceTracker.getRelates().noneMatch(rol -> rol.getLabel().name().equals("tracker")));
                assertNull(email.getRegex());
                AttributeType index = tx.concepts().getAttributeType("index");
                assertNull(index);
                assertNull(tx.logic().getRule("repo-fork-rule"));
                assertNull(tx.logic().getRule("repo-dependency-transitive-rule"));
                assertNull(tx.logic().getRule("repo-dependency-transitive-type-rule"));
                assertNull(tx.logic().getRule("repo-collaborator-org-rule"));
                // check total count
                assertEquals(15 - 5, tx.logic().rules().toList().size());
                // a query that used to trigger a rule should not cause an error
                List<ConceptMap> answers = tx.query().match(TypeQL.parseQuery("match $x isa repo-fork;").asMatch()).toList();
            }
        }
    }
}
Also used : TypeQLDelete(com.vaticle.typeql.lang.query.TypeQLDelete) TypeQLInsert(com.vaticle.typeql.lang.query.TypeQLInsert) MB(com.vaticle.typedb.core.common.collection.Bytes.MB) TypeQLUndefine(com.vaticle.typeql.lang.query.TypeQLUndefine) Util.assertNotNulls(com.vaticle.typedb.core.test.integration.util.Util.assertNotNulls) RelationType(com.vaticle.typedb.core.concept.type.RelationType) Arguments(com.vaticle.typedb.core.common.parameters.Arguments) Path(java.nio.file.Path) TypeQLDefine(com.vaticle.typeql.lang.query.TypeQLDefine) TypeQL(com.vaticle.typeql.lang.TypeQL) FunctionalIterator(com.vaticle.typedb.core.common.iterator.FunctionalIterator) CoreDatabaseManager(com.vaticle.typedb.core.database.CoreDatabaseManager) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) ConceptMap(com.vaticle.typedb.core.concept.answer.ConceptMap) Test(org.junit.Test) IOException(java.io.IOException) RoleType(com.vaticle.typedb.core.concept.type.RoleType) TypeDB(com.vaticle.typedb.core.TypeDB) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Paths(java.nio.file.Paths) Assert.assertFalse(org.junit.Assert.assertFalse) Attribute(com.vaticle.typedb.core.concept.thing.Attribute) Database(com.vaticle.typedb.core.common.parameters.Options.Database) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) EntityType(com.vaticle.typedb.core.concept.type.EntityType) TypeQLMatch(com.vaticle.typeql.lang.query.TypeQLMatch) Entity(com.vaticle.typedb.core.concept.thing.Entity) Assert.assertEquals(org.junit.Assert.assertEquals) Util(com.vaticle.typedb.core.test.integration.util.Util) TypeQLUndefine(com.vaticle.typeql.lang.query.TypeQLUndefine) RoleType(com.vaticle.typedb.core.concept.type.RoleType) TypeDB(com.vaticle.typedb.core.TypeDB) EntityType(com.vaticle.typedb.core.concept.type.EntityType) TypeQLDefine(com.vaticle.typeql.lang.query.TypeQLDefine) AttributeType(com.vaticle.typedb.core.concept.type.AttributeType) RelationType(com.vaticle.typedb.core.concept.type.RelationType) ConceptMap(com.vaticle.typedb.core.concept.answer.ConceptMap) Test(org.junit.Test)

Aggregations

TypeDB (com.vaticle.typedb.core.TypeDB)11 Test (org.junit.Test)10 EntityType (com.vaticle.typedb.core.concept.type.EntityType)8 RelationType (com.vaticle.typedb.core.concept.type.RelationType)8 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)7 RoleType (com.vaticle.typedb.core.concept.type.RoleType)7 Attribute (com.vaticle.typedb.core.concept.thing.Attribute)6 IOException (java.io.IOException)6 MB (com.vaticle.typedb.core.common.collection.Bytes.MB)5 Arguments (com.vaticle.typedb.core.common.parameters.Arguments)5 ConceptManager (com.vaticle.typedb.core.concept.ConceptManager)5 CoreDatabaseManager (com.vaticle.typedb.core.database.CoreDatabaseManager)5 LogicManager (com.vaticle.typedb.core.logic.LogicManager)5 Rule (com.vaticle.typedb.core.logic.Rule)5 Util (com.vaticle.typedb.core.test.integration.util.Util)5 Util.assertNotNulls (com.vaticle.typedb.core.test.integration.util.Util.assertNotNulls)5 TypeQL (com.vaticle.typeql.lang.TypeQL)5 Pattern (com.vaticle.typeql.lang.pattern.Pattern)5 Path (java.nio.file.Path)5 Paths (java.nio.file.Paths)5