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));
}
}
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));
}
}
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();
}
}
Aggregations