diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-02-24 20:21:15 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-02-24 23:29:49 +0100 |
commit | f8a3c575e400259a4985233c07b7a50e5d4d82c5 (patch) | |
tree | f5975a19fcce28eba17b5af8adde5a37ddba83c6 /subprojects/store-query-viatra/src/test | |
parent | refactor: split query and partial from store (diff) | |
download | refinery-f8a3c575e400259a4985233c07b7a50e5d4d82c5.tar.gz refinery-f8a3c575e400259a4985233c07b7a50e5d4d82c5.tar.zst refinery-f8a3c575e400259a4985233c07b7a50e5d4d82c5.zip |
feat: Dnf reduction and structural equality
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 | 40 |
1 files changed, 40 insertions, 0 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 6a3a62e3..54ae70c3 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 | |||
@@ -17,6 +17,7 @@ import java.util.Set; | |||
17 | import java.util.stream.Stream; | 17 | import java.util.stream.Stream; |
18 | 18 | ||
19 | import static org.junit.jupiter.api.Assertions.assertEquals; | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
20 | import static org.junit.jupiter.api.Assertions.assertThrows; | ||
20 | import static tools.refinery.store.query.literal.Literals.not; | 21 | import static tools.refinery.store.query.literal.Literals.not; |
21 | 22 | ||
22 | class QueryTest { | 23 | class QueryTest { |
@@ -669,6 +670,45 @@ class QueryTest { | |||
669 | assertEquals(3, predicateResultSet.countResults()); | 670 | assertEquals(3, predicateResultSet.countResults()); |
670 | } | 671 | } |
671 | 672 | ||
673 | @Test | ||
674 | void alwaysFalseTest() { | ||
675 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
676 | |||
677 | var p1 = new Variable("p1"); | ||
678 | var predicate = Dnf.builder("AlwaysFalse").parameters(p1).build(); | ||
679 | |||
680 | var store = ModelStore.builder() | ||
681 | .symbols(person) | ||
682 | .with(ViatraModelQuery.ADAPTER) | ||
683 | .queries(predicate) | ||
684 | .build(); | ||
685 | |||
686 | var model = store.createEmptyModel(); | ||
687 | var personInterpretation = model.getInterpretation(person); | ||
688 | var queryEngine = model.getAdapter(ModelQuery.ADAPTER); | ||
689 | var predicateResultSet = queryEngine.getResultSet(predicate); | ||
690 | |||
691 | personInterpretation.put(Tuple.of(0), true); | ||
692 | personInterpretation.put(Tuple.of(1), true); | ||
693 | personInterpretation.put(Tuple.of(2), true); | ||
694 | |||
695 | queryEngine.flushChanges(); | ||
696 | assertEquals(0, predicateResultSet.countResults()); | ||
697 | } | ||
698 | |||
699 | @Test | ||
700 | void alwaysTrueTest() { | ||
701 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
702 | |||
703 | var p1 = new Variable("p1"); | ||
704 | var predicate = Dnf.builder("AlwaysTrue").parameters(p1).clause().build(); | ||
705 | |||
706 | var storeBuilder = ModelStore.builder().symbols(person); | ||
707 | var queryBuilder = storeBuilder.with(ViatraModelQuery.ADAPTER); | ||
708 | |||
709 | assertThrows(IllegalArgumentException.class, () -> queryBuilder.queries(predicate)); | ||
710 | } | ||
711 | |||
672 | static void compareMatchSets(Stream<TupleLike> matchSet, Set<Tuple> expected) { | 712 | static void compareMatchSets(Stream<TupleLike> matchSet, Set<Tuple> expected) { |
673 | Set<Tuple> translatedMatchSet = new HashSet<>(); | 713 | Set<Tuple> translatedMatchSet = new HashSet<>(); |
674 | var iterator = matchSet.iterator(); | 714 | var iterator = matchSet.iterator(); |