diff options
author | 2022-12-06 16:13:55 +0100 | |
---|---|---|
committer | 2022-12-09 00:07:39 +0100 | |
commit | eedc0ac8c20710e20095e0c19269601c2719543a (patch) | |
tree | 86341ae1eb585eb41167670ab970d2aa6dc16609 /subprojects/store-query-viatra/src/test | |
parent | refactor(frontend): theme improvements (diff) | |
download | refinery-eedc0ac8c20710e20095e0c19269601c2719543a.tar.gz refinery-eedc0ac8c20710e20095e0c19269601c2719543a.tar.zst refinery-eedc0ac8c20710e20095e0c19269601c2719543a.zip |
refactor(store): remove CountPolarity
We will have to implement counting in DNF queries in another way.
Diffstat (limited to 'subprojects/store-query-viatra/src/test')
-rw-r--r-- | subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java index d18187e5..e82e006c 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTest.java | |||
@@ -5,7 +5,6 @@ import tools.refinery.store.model.representation.Relation; | |||
5 | import tools.refinery.store.model.representation.TruthValue; | 5 | import tools.refinery.store.model.representation.TruthValue; |
6 | import tools.refinery.store.query.*; | 6 | import tools.refinery.store.query.*; |
7 | import tools.refinery.store.query.atom.*; | 7 | import tools.refinery.store.query.atom.*; |
8 | import tools.refinery.store.query.viatra.ViatraQueryableModelStore; | ||
9 | import tools.refinery.store.query.view.FilteredRelationView; | 8 | import tools.refinery.store.query.view.FilteredRelationView; |
10 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 9 | import tools.refinery.store.query.view.KeyOnlyRelationView; |
11 | import tools.refinery.store.query.view.RelationView; | 10 | import tools.refinery.store.query.view.RelationView; |
@@ -438,7 +437,7 @@ class QueryTest { | |||
438 | .clause( | 437 | .clause( |
439 | new RelationViewAtom(personView, p3), | 438 | new RelationViewAtom(personView, p3), |
440 | new RelationViewAtom(personView, p4), | 439 | new RelationViewAtom(personView, p4), |
441 | new CallAtom<>(SimplePolarity.TRANSITIVE, friendPredicate, p3, p4) | 440 | new CallAtom<>(CallPolarity.TRANSITIVE, friendPredicate, p3, p4) |
442 | ) | 441 | ) |
443 | .build(); | 442 | .build(); |
444 | 443 | ||
@@ -456,48 +455,6 @@ class QueryTest { | |||
456 | assertEquals(3, model.countResults(predicate)); | 455 | assertEquals(3, model.countResults(predicate)); |
457 | } | 456 | } |
458 | 457 | ||
459 | @Test | ||
460 | void countMatchTest() { | ||
461 | Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false); | ||
462 | Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
463 | RelationView<Boolean> personView = new KeyOnlyRelationView(person); | ||
464 | RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", | ||
465 | TruthValue::must); | ||
466 | |||
467 | Variable p1 = new Variable("p1"); | ||
468 | Variable p2 = new Variable("p2"); | ||
469 | |||
470 | DNF called = DNF.builder("Called") | ||
471 | .parameters(p1, p2) | ||
472 | .clause( | ||
473 | new RelationViewAtom(personView, p1), | ||
474 | new RelationViewAtom(personView, p2), | ||
475 | new RelationViewAtom(friendMustView, p1, p2) | ||
476 | ) | ||
477 | .build(); | ||
478 | |||
479 | DNF predicate = DNF.builder("Count") | ||
480 | .parameters(p1) | ||
481 | .clause( | ||
482 | new RelationViewAtom(personView, p1), | ||
483 | new CallAtom<>(new CountingPolarity(ComparisonOperator.EQUALS, 2), called, p1, p2) | ||
484 | ) | ||
485 | .build(); | ||
486 | |||
487 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | ||
488 | Set.of(personView, friendMustView), Set.of(called, predicate)); | ||
489 | QueryableModel model = store.createModel(); | ||
490 | |||
491 | model.put(person, Tuple.of(0), true); | ||
492 | model.put(person, Tuple.of(1), true); | ||
493 | model.put(person, Tuple.of(2), true); | ||
494 | model.put(friend, Tuple.of(0, 1), TruthValue.TRUE); | ||
495 | model.put(friend, Tuple.of(0, 2), TruthValue.TRUE); | ||
496 | |||
497 | model.flushChanges(); | ||
498 | assertEquals(1, model.countResults(predicate)); | ||
499 | } | ||
500 | |||
501 | static void compareMatchSets(Stream<TupleLike> matchSet, Set<Tuple> expected) { | 458 | static void compareMatchSets(Stream<TupleLike> matchSet, Set<Tuple> expected) { |
502 | Set<Tuple> translatedMatchSet = new HashSet<>(); | 459 | Set<Tuple> translatedMatchSet = new HashSet<>(); |
503 | var iterator = matchSet.iterator(); | 460 | var iterator = matchSet.iterator(); |