use of com.vaticle.typeql.lang.query.TypeQLMatch 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.typeql.lang.query.TypeQLMatch 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.typeql.lang.query.TypeQLMatch 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();
}
}
use of com.vaticle.typeql.lang.query.TypeQLMatch in project grakn by graknlabs.
the class MaterialiserTest method testDeduplicationOfInferredConcepts.
@Test
public void testDeduplicationOfInferredConcepts() {
loadTransitivityExample(databaseMgr);
try (CoreSession session = databaseMgr.session(database, Arguments.Session.Type.DATA)) {
Materialiser materialiser = Materialiser.materialise(session);
TypeQLMatch inferredAnswersQuery = TypeQL.match(TypeQL.var("lh").isa("location-hierarchy"));
List<ConceptMap> inferredAnswers = iterate(materialiser.query(inferredAnswersQuery).entrySet()).flatMap(Map.Entry::getValue).toList();
assertEquals(6, inferredAnswers.size());
}
}
use of com.vaticle.typeql.lang.query.TypeQLMatch in project grakn by graknlabs.
the class TypeQLSteps method each_answer_does_not_satisfy.
@Then("each answer does not satisfy")
public void each_answer_does_not_satisfy(String templatedTypeQLQuery) {
String templatedQuery = String.join("\n", templatedTypeQLQuery);
for (ConceptMap answer : answers) {
String queryString = applyQueryTemplate(templatedQuery, answer);
TypeQLMatch query = TypeQL.parseQuery(queryString).asMatch();
long answerSize = tx().query().match(query).toList().size();
assertEquals(0, answerSize);
}
}
Aggregations