aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar OszkarSemerath <semerath@mit.bme.hu>2021-10-24 23:37:32 +0200
committerLibravatar OszkarSemerath <semerath@mit.bme.hu>2021-10-24 23:37:32 +0200
commitd88cfd7b4f7e2dab4047a2edb12106189aade66b (patch)
tree899b2b67767ac627e1f4ce0469e2de9d58e6ac7b
parentFixed query parameter list undeterministic order (diff)
downloadrefinery-d88cfd7b4f7e2dab4047a2edb12106189aade66b.tar.gz
refinery-d88cfd7b4f7e2dab4047a2edb12106189aade66b.tar.zst
refinery-d88cfd7b4f7e2dab4047a2edb12106189aade66b.zip
Existentially quantified variable test
-rw-r--r--store/src/test/java/tools/refinery/store/query/test/QueryTest.java41
1 files changed, 39 insertions, 2 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 629ecc14..5280195b 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
@@ -236,10 +236,47 @@ class QueryTest {
236 List.of(Tuple.of(0), Tuple.of(2)), 236 List.of(Tuple.of(0), Tuple.of(2)),
237 List.of(Tuple.of(2), Tuple.of(0)) 237 List.of(Tuple.of(2), Tuple.of(0))
238 )); 238 ));
239
240 } 239 }
241 240
242 // existTest 241 @Test
242 void existTest() {
243 Relation<Boolean> person = new Relation<Boolean>("Person", 1, false);
244 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE);
245 RelationView<Boolean> persionView = new KeyOnlyRelationView(person);
246 RelationView<TruthValue> friendMustView = new FilteredRelationView<TruthValue>(friend, (k, v) -> v.must());
247
248 Variable p1 = new Variable("p1");
249 Variable p2 = new Variable("p2");
250 List<Variable> parameters = Arrays.asList(p1);
251
252 RelationAtom personRelationAtom1 = new RelationAtom(persionView, Arrays.asList(p1));
253 RelationAtom personRelationAtom2 = new RelationAtom(persionView, Arrays.asList(p2));
254 RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2));
255 DNFAnd clause = new DNFAnd(new HashSet<>(parameters),
256 Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom));
257 DNFPredicate predicate = new DNFPredicate("RelationConstraint", parameters, Arrays.asList(clause));
258
259 QueriableModelStore store = new QueriableModelStoreImpl(Set.of(person, friend), Set.of(persionView,friendMustView), Set.of(predicate));
260 QueriableModel model = store.createModel();
261
262 assertEquals(0, model.countResults(predicate));
263
264 model.put(person, Tuple.of(0), true);
265 model.put(person, Tuple.of(1), true);
266 model.put(person, Tuple.of(2), true);
267 model.put(friend, Tuple.of(0, 1), TruthValue.TRUE);
268 model.put(friend, Tuple.of(1, 0), TruthValue.TRUE);
269 model.put(friend, Tuple.of(1, 2), TruthValue.TRUE);
270
271 assertEquals(0, model.countResults(predicate));
272
273 model.flushChanges();
274 assertEquals(2, model.countResults(predicate));
275 compareMatchSets(model.allResults(predicate), Set.of(
276 List.of(Tuple.of(0)),
277 List.of(Tuple.of(1))
278 ));
279 }
243 280
244 @Test 281 @Test
245 @Disabled 282 @Disabled