diff options
author | 2021-10-24 00:57:15 +0200 | |
---|---|---|
committer | 2021-10-24 00:57:15 +0200 | |
commit | f073c4c721a6df451abf75636c20bb73d615b549 (patch) | |
tree | d11dc8647c988b47bd2d1b16581384e610776214 /store/src | |
parent | Missed packaging tuple values to tuple1 in views (diff) | |
download | refinery-f073c4c721a6df451abf75636c20bb73d615b549.tar.gz refinery-f073c4c721a6df451abf75636c20bb73d615b549.tar.zst refinery-f073c4c721a6df451abf75636c20bb73d615b549.zip |
Querytest first final case
Diffstat (limited to 'store/src')
-rw-r--r-- | store/src/test/java/tools/refinery/store/query/test/QueryTest.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/store/src/test/java/tools/refinery/store/query/test/QueryTest.java b/store/src/test/java/tools/refinery/store/query/test/QueryTest.java index f7b825b6..5f1c3fd8 100644 --- a/store/src/test/java/tools/refinery/store/query/test/QueryTest.java +++ b/store/src/test/java/tools/refinery/store/query/test/QueryTest.java | |||
@@ -2,10 +2,13 @@ package tools.refinery.store.query.test; | |||
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.assertEquals; | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | 4 | ||
5 | import java.util.ArrayList; | ||
5 | import java.util.Arrays; | 6 | import java.util.Arrays; |
7 | import java.util.Collections; | ||
6 | import java.util.HashSet; | 8 | import java.util.HashSet; |
7 | import java.util.List; | 9 | import java.util.List; |
8 | import java.util.Set; | 10 | import java.util.Set; |
11 | import java.util.stream.Stream; | ||
9 | 12 | ||
10 | import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine; | 13 | import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine; |
11 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatcher; | 14 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatcher; |
@@ -18,6 +21,7 @@ import tools.refinery.store.model.Model; | |||
18 | import tools.refinery.store.model.ModelStore; | 21 | import tools.refinery.store.model.ModelStore; |
19 | import tools.refinery.store.model.ModelStoreImpl; | 22 | import tools.refinery.store.model.ModelStoreImpl; |
20 | import tools.refinery.store.model.Tuple; | 23 | import tools.refinery.store.model.Tuple; |
24 | import tools.refinery.store.model.Tuple.Tuple1; | ||
21 | import tools.refinery.store.model.representation.Relation; | 25 | import tools.refinery.store.model.representation.Relation; |
22 | import tools.refinery.store.model.representation.TruthValue; | 26 | import tools.refinery.store.model.representation.TruthValue; |
23 | import tools.refinery.store.query.QueriableModel; | 27 | import tools.refinery.store.query.QueriableModel; |
@@ -96,7 +100,21 @@ class QueryTest { | |||
96 | // System.out.println(personMatch); | 100 | // System.out.println(personMatch); |
97 | // } | 101 | // } |
98 | // } | 102 | // } |
99 | 103 | ||
104 | private void compareMatchSets(Stream<Object[]> matchSet, Set<List<Tuple>> expected) { | ||
105 | Set<List<Tuple>> translatedMatchSet = new HashSet<>(); | ||
106 | var interator = matchSet.iterator(); | ||
107 | while(interator.hasNext()) { | ||
108 | var element = interator.next(); | ||
109 | List<Tuple> elementToTranslatedMatchSet = new ArrayList<>(); | ||
110 | for(int i=0; i<element.length; i++) { | ||
111 | elementToTranslatedMatchSet.add((Tuple) element[i]); | ||
112 | } | ||
113 | translatedMatchSet.add(elementToTranslatedMatchSet); | ||
114 | } | ||
115 | assertEquals(translatedMatchSet, expected); | ||
116 | } | ||
117 | |||
100 | @Test | 118 | @Test |
101 | //@Disabled | 119 | //@Disabled |
102 | void typeConstraintTest() { | 120 | void typeConstraintTest() { |
@@ -127,7 +145,11 @@ class QueryTest { | |||
127 | 145 | ||
128 | System.out.println("Res3"); | 146 | System.out.println("Res3"); |
129 | model.flushChanges(); | 147 | model.flushChanges(); |
148 | compareMatchSets(model.allResults(predicate), Set.of( | ||
149 | List.of(Tuple.of(0)), | ||
150 | List.of(Tuple.of(1)))); | ||
130 | System.out.println(model.countResults(predicate)); | 151 | System.out.println(model.countResults(predicate)); |
152 | model.allResults(predicate).forEach(x -> System.out.println(x)); | ||
131 | 153 | ||
132 | 154 | ||
133 | //RelationalScope scope = new RelationalScope(model, Set.of(persionView)); | 155 | //RelationalScope scope = new RelationalScope(model, Set.of(persionView)); |