Search in sources :

Example 1 with CorrectnessVerifier

use of com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier in project grakn by graknlabs.

the class CorrectnessVerifierTest method testSoundnessThrowsWhenRuleTriggersTooOftenEmployableExample.

@Test
public void testSoundnessThrowsWhenRuleTriggersTooOftenEmployableExample() {
    TypeQLMatch inferenceQuery = parseQuery("match $x has employable true;").asMatch();
    CorrectnessVerifier correctnessVerifier;
    try (CoreSession session = databaseMgr.session(database, Arguments.Session.Type.DATA)) {
        correctnessVerifier = CorrectnessVerifier.initialise(session);
        try (CoreTransaction tx = session.transaction(Arguments.Transaction.Type.WRITE)) {
            tx.query().insert(parseQuery("insert $p isa person;"));
            tx.commit();
        }
        assertThrows(() -> correctnessVerifier.verifySoundness(inferenceQuery), SoundnessException.class);
        assertNotThrows(() -> correctnessVerifier.verifyCompleteness(inferenceQuery));
    }
}
Also used : CorrectnessVerifier(com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier) CoreSession(com.vaticle.typedb.core.database.CoreSession) TypeQLMatch(com.vaticle.typeql.lang.query.TypeQLMatch) CoreTransaction(com.vaticle.typedb.core.database.CoreTransaction) Test(org.junit.Test)

Example 2 with CorrectnessVerifier

use of com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier in project grakn by graknlabs.

the class CorrectnessVerifierTest method testCompletenessThrowsWhenRuleIsNotTriggeredEmployableExample.

@Test
public void testCompletenessThrowsWhenRuleIsNotTriggeredEmployableExample() {
    TypeQLMatch inferenceQuery = parseQuery("match $x has employable true;").asMatch();
    CorrectnessVerifier correctnessVerifier;
    try (CoreSession session = databaseMgr.session(database, Arguments.Session.Type.DATA)) {
        correctnessVerifier = CorrectnessVerifier.initialise(session);
        try (CoreTransaction tx = session.transaction(Arguments.Transaction.Type.WRITE)) {
            tx.query().delete(parseQuery("match $p isa person; delete $p isa person;"));
            tx.commit();
        }
        assertThrows(() -> correctnessVerifier.verifyCompleteness(inferenceQuery), CompletenessException.class);
        assertNotThrows(() -> correctnessVerifier.verifySoundness(inferenceQuery));
    }
}
Also used : CorrectnessVerifier(com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier) CoreSession(com.vaticle.typedb.core.database.CoreSession) TypeQLMatch(com.vaticle.typeql.lang.query.TypeQLMatch) CoreTransaction(com.vaticle.typedb.core.database.CoreTransaction) Test(org.junit.Test)

Example 3 with CorrectnessVerifier

use of com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier in project grakn by graknlabs.

the class CorrectnessVerifierTest method testCorrectnessPassesForEmployableExample.

@Test
public void testCorrectnessPassesForEmployableExample() {
    TypeQLMatch inferenceQuery = parseQuery("match $x has employable true;").asMatch();
    try (CoreSession session = databaseMgr.session(database, Arguments.Session.Type.DATA)) {
        CorrectnessVerifier correctnessVerifier = CorrectnessVerifier.initialise(session);
        correctnessVerifier.verifyCorrectness(inferenceQuery);
        correctnessVerifier.close();
    }
}
Also used : CoreSession(com.vaticle.typedb.core.database.CoreSession) CorrectnessVerifier(com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier) TypeQLMatch(com.vaticle.typeql.lang.query.TypeQLMatch) Test(org.junit.Test)

Aggregations

CoreSession (com.vaticle.typedb.core.database.CoreSession)3 CorrectnessVerifier (com.vaticle.typedb.core.test.behaviour.reasoner.verification.CorrectnessVerifier)3 TypeQLMatch (com.vaticle.typeql.lang.query.TypeQLMatch)3 Test (org.junit.Test)3 CoreTransaction (com.vaticle.typedb.core.database.CoreTransaction)2