diff options
author | 2022-10-19 12:22:14 -0400 | |
---|---|---|
committer | 2022-11-05 19:41:16 +0100 | |
commit | f7e6301423e380e86dd4bd42409e2c4c9d6aade0 (patch) | |
tree | c5c95c2cdc4e83c6c5514b238bbd3e31c1d09048 /subprojects/store-query-viatra/src/test | |
parent | refactor(frontend): minor theme improvements (diff) | |
download | refinery-f7e6301423e380e86dd4bd42409e2c4c9d6aade0.tar.gz refinery-f7e6301423e380e86dd4bd42409e2c4c9d6aade0.tar.zst refinery-f7e6301423e380e86dd4bd42409e2c4c9d6aade0.zip |
refactor: DNF query builder
Diffstat (limited to 'subprojects/store-query-viatra/src/test')
2 files changed, 123 insertions, 126 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java index d6213b02..8984cb2c 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java | |||
@@ -3,9 +3,11 @@ package tools.refinery.store.query.viatra.tests; | |||
3 | import org.junit.jupiter.api.Test; | 3 | import org.junit.jupiter.api.Test; |
4 | import tools.refinery.store.model.representation.Relation; | 4 | 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.QueryableModel; | 6 | import tools.refinery.store.query.*; |
7 | import tools.refinery.store.query.QueryableModelStore; | 7 | import tools.refinery.store.query.atom.CallKind; |
8 | import tools.refinery.store.query.building.*; | 8 | import tools.refinery.store.query.atom.EquivalenceAtom; |
9 | import tools.refinery.store.query.atom.DNFCallAtom; | ||
10 | import tools.refinery.store.query.atom.RelationViewAtom; | ||
9 | import tools.refinery.store.query.viatra.ViatraQueryableModelStore; | 11 | import tools.refinery.store.query.viatra.ViatraQueryableModelStore; |
10 | import tools.refinery.store.query.view.FilteredRelationView; | 12 | import tools.refinery.store.query.view.FilteredRelationView; |
11 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 13 | import tools.refinery.store.query.view.KeyOnlyRelationView; |
@@ -25,10 +27,11 @@ class QueryTest { | |||
25 | Relation<Boolean> asset = new Relation<>("Asset", 1, false); | 27 | Relation<Boolean> asset = new Relation<>("Asset", 1, false); |
26 | RelationView<Boolean> personView = new KeyOnlyRelationView(person); | 28 | RelationView<Boolean> personView = new KeyOnlyRelationView(person); |
27 | 29 | ||
28 | List<Variable> parameters = List.of(new Variable("p1")); | 30 | var p1 = new Variable("p1"); |
29 | RelationAtom personRelationAtom = new RelationAtom(personView, parameters); | 31 | DNF predicate = DNF.builder("TypeConstraint") |
30 | DNFAnd clause = new DNFAnd(Collections.emptySet(), List.of(personRelationAtom)); | 32 | .parameters(p1) |
31 | DNFPredicate predicate = new DNFPredicate("TypeConstraint", parameters, List.of(clause)); | 33 | .clause(new RelationViewAtom(personView, p1)) |
34 | .build(); | ||
32 | 35 | ||
33 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, asset), Set.of(personView), | 36 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, asset), Set.of(personView), |
34 | Set.of(predicate)); | 37 | Set.of(predicate)); |
@@ -54,14 +57,14 @@ class QueryTest { | |||
54 | 57 | ||
55 | Variable p1 = new Variable("p1"); | 58 | Variable p1 = new Variable("p1"); |
56 | Variable p2 = new Variable("p2"); | 59 | Variable p2 = new Variable("p2"); |
57 | List<Variable> parameters = Arrays.asList(p1, p2); | 60 | DNF predicate = DNF.builder("RelationConstraint") |
58 | 61 | .parameters(p1, p2) | |
59 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 62 | .clause( |
60 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 63 | new RelationViewAtom(personView, p1), |
61 | RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 64 | new RelationViewAtom(personView, p1), |
62 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 65 | new RelationViewAtom(friendMustView, p1, p2) |
63 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom)); | 66 | ) |
64 | DNFPredicate predicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 67 | .build(); |
65 | 68 | ||
66 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 69 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
67 | Set.of(personView, friendMustView), Set.of(predicate)); | 70 | Set.of(personView, friendMustView), Set.of(predicate)); |
@@ -93,15 +96,15 @@ class QueryTest { | |||
93 | 96 | ||
94 | Variable p1 = new Variable("p1"); | 97 | Variable p1 = new Variable("p1"); |
95 | Variable p2 = new Variable("p2"); | 98 | Variable p2 = new Variable("p2"); |
96 | List<Variable> parameters = Arrays.asList(p1, p2); | 99 | DNF predicate = DNF.builder("RelationConstraint") |
97 | 100 | .parameters(p1, p2) | |
98 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 101 | .clause( |
99 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 102 | new RelationViewAtom(personView, p1), |
100 | RelationAtom friendRelationAtom1 = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 103 | new RelationViewAtom(personView, p2), |
101 | RelationAtom friendRelationAtom2 = new RelationAtom(friendMustView, Arrays.asList(p2, p1)); | 104 | new RelationViewAtom(friendMustView, p1, p2), |
102 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 105 | new RelationViewAtom(friendMustView, p2, p1) |
103 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom1, friendRelationAtom2)); | 106 | ) |
104 | DNFPredicate predicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 107 | .build(); |
105 | 108 | ||
106 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 109 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
107 | Set.of(personView, friendMustView), Set.of(predicate)); | 110 | Set.of(personView, friendMustView), Set.of(predicate)); |
@@ -141,14 +144,14 @@ class QueryTest { | |||
141 | 144 | ||
142 | Variable p1 = new Variable("p1"); | 145 | Variable p1 = new Variable("p1"); |
143 | Variable p2 = new Variable("p2"); | 146 | Variable p2 = new Variable("p2"); |
144 | List<Variable> parameters = List.of(p1); | 147 | DNF predicate = DNF.builder("RelationConstraint") |
145 | 148 | .parameters(p1) | |
146 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 149 | .clause( |
147 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 150 | new RelationViewAtom(personView, p1), |
148 | RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 151 | new RelationViewAtom(personView, p2), |
149 | DNFAnd clause = new DNFAnd(Set.of(p2), | 152 | new RelationViewAtom(friendMustView, p1, p2) |
150 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom)); | 153 | ) |
151 | DNFPredicate predicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 154 | .build(); |
152 | 155 | ||
153 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 156 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
154 | Set.of(personView, friendMustView), Set.of(predicate)); | 157 | Set.of(personView, friendMustView), Set.of(predicate)); |
@@ -182,24 +185,19 @@ class QueryTest { | |||
182 | 185 | ||
183 | Variable p1 = new Variable("p1"); | 186 | Variable p1 = new Variable("p1"); |
184 | Variable p2 = new Variable("p2"); | 187 | Variable p2 = new Variable("p2"); |
185 | List<Variable> parameters = Arrays.asList(p1, p2); | 188 | DNF predicate = DNF.builder("Or") |
186 | 189 | .parameters(p1, p2) | |
187 | // Person-Person friendship | 190 | .clause( |
188 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 191 | new RelationViewAtom(personView, p1), |
189 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 192 | new RelationViewAtom(personView, p2), |
190 | RelationAtom friendRelationAtom1 = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 193 | new RelationViewAtom(friendMustView, p1, p2) |
191 | DNFAnd clause1 = new DNFAnd(Collections.emptySet(), | 194 | ) |
192 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom1)); | 195 | .clause( |
193 | 196 | new RelationViewAtom(animalView, p1), | |
194 | // Animal-Animal friendship | 197 | new RelationViewAtom(animalView, p2), |
195 | RelationAtom animalRelationAtom1 = new RelationAtom(animalView, List.of(p1)); | 198 | new RelationViewAtom(friendMustView, p1, p2) |
196 | RelationAtom animalRelationAtom2 = new RelationAtom(animalView, List.of(p2)); | 199 | ) |
197 | RelationAtom friendRelationAtom2 = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 200 | .build(); |
198 | DNFAnd clause2 = new DNFAnd(Collections.emptySet(), | ||
199 | Arrays.asList(animalRelationAtom1, animalRelationAtom2, friendRelationAtom2)); | ||
200 | |||
201 | // No friendship between species | ||
202 | DNFPredicate predicate = new DNFPredicate("Or", parameters, Arrays.asList(clause1, clause2)); | ||
203 | 201 | ||
204 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, animal, friend), | 202 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, animal, friend), |
205 | Set.of(personView, animalView, friendMustView), Set.of(predicate)); | 203 | Set.of(personView, animalView, friendMustView), Set.of(predicate)); |
@@ -226,14 +224,14 @@ class QueryTest { | |||
226 | 224 | ||
227 | Variable p1 = new Variable("p1"); | 225 | Variable p1 = new Variable("p1"); |
228 | Variable p2 = new Variable("p2"); | 226 | Variable p2 = new Variable("p2"); |
229 | List<Variable> parameters = Arrays.asList(p1, p2); | 227 | DNF predicate = DNF.builder("Equality") |
230 | 228 | .parameters(p1, p2) | |
231 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 229 | .clause( |
232 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 230 | new RelationViewAtom(personView, p1), |
233 | EquivalenceAtom equivalenceAtom = new EquivalenceAtom(true, p1, p2); | 231 | new RelationViewAtom(personView, p2), |
234 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 232 | new EquivalenceAtom(p1, p2) |
235 | Arrays.asList(personRelationAtom1, personRelationAtom2, equivalenceAtom)); | 233 | ) |
236 | DNFPredicate predicate = new DNFPredicate("Equality", parameters, List.of(clause)); | 234 | .build(); |
237 | 235 | ||
238 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person), Set.of(personView), Set.of(predicate)); | 236 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person), Set.of(personView), Set.of(predicate)); |
239 | QueryableModel model = store.createModel(); | 237 | QueryableModel model = store.createModel(); |
@@ -258,16 +256,16 @@ class QueryTest { | |||
258 | Variable p1 = new Variable("p1"); | 256 | Variable p1 = new Variable("p1"); |
259 | Variable p2 = new Variable("p2"); | 257 | Variable p2 = new Variable("p2"); |
260 | Variable p3 = new Variable("p3"); | 258 | Variable p3 = new Variable("p3"); |
261 | List<Variable> parameters = Arrays.asList(p1, p2, p3); | 259 | DNF predicate = DNF.builder("Inequality") |
262 | 260 | .parameters(p1, p2, p3) | |
263 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 261 | .clause( |
264 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 262 | new RelationViewAtom(personView, p1), |
265 | RelationAtom friendRelationAtom1 = new RelationAtom(friendMustView, Arrays.asList(p1, p3)); | 263 | new RelationViewAtom(personView, p2), |
266 | RelationAtom friendRelationAtom2 = new RelationAtom(friendMustView, Arrays.asList(p2, p3)); | 264 | new RelationViewAtom(friendMustView, p1, p3), |
267 | EquivalenceAtom inequivalenceAtom = new EquivalenceAtom(false, p1, p2); | 265 | new RelationViewAtom(friendMustView, p2, p3), |
268 | DNFAnd clause = new DNFAnd(Collections.emptySet(), Arrays.asList(personRelationAtom1, personRelationAtom2, | 266 | new EquivalenceAtom(false, p1, p2) |
269 | friendRelationAtom1, friendRelationAtom2, inequivalenceAtom)); | 267 | ) |
270 | DNFPredicate predicate = new DNFPredicate("Inequality", parameters, List.of(clause)); | 268 | .build(); |
271 | 269 | ||
272 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 270 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
273 | Set.of(personView, friendMustView), Set.of(predicate)); | 271 | Set.of(personView, friendMustView), Set.of(predicate)); |
@@ -294,24 +292,25 @@ class QueryTest { | |||
294 | 292 | ||
295 | Variable p1 = new Variable("p1"); | 293 | Variable p1 = new Variable("p1"); |
296 | Variable p2 = new Variable("p2"); | 294 | Variable p2 = new Variable("p2"); |
297 | List<Variable> parameters = Arrays.asList(p1, p2); | 295 | DNF friendPredicate = DNF.builder("RelationConstraint") |
298 | 296 | .parameters(p1, p2) | |
299 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 297 | .clause( |
300 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 298 | new RelationViewAtom(personView, p1), |
301 | RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 299 | new RelationViewAtom(personView, p2), |
302 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 300 | new RelationViewAtom(friendMustView, p1, p2) |
303 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom)); | 301 | ) |
304 | DNFPredicate friendPredicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 302 | .build(); |
305 | 303 | ||
306 | Variable p3 = new Variable("p3"); | 304 | Variable p3 = new Variable("p3"); |
307 | Variable p4 = new Variable("p4"); | 305 | Variable p4 = new Variable("p4"); |
308 | List<Variable> substitution = Arrays.asList(p3, p4); | 306 | DNF predicate = DNF.builder("PositivePatternCall") |
309 | RelationAtom personRelationAtom3 = new RelationAtom(personView, List.of(p3)); | 307 | .parameters(p3, p4) |
310 | RelationAtom personRelationAtom4 = new RelationAtom(personView, List.of(p4)); | 308 | .clause( |
311 | PredicateAtom friendPredicateAtom = new PredicateAtom(true, false, friendPredicate, substitution); | 309 | new RelationViewAtom(personView, p3), |
312 | DNFAnd patternCallClause = new DNFAnd(Collections.emptySet(), | 310 | new RelationViewAtom(personView, p4), |
313 | Arrays.asList(personRelationAtom3, personRelationAtom4, friendPredicateAtom)); | 311 | new DNFCallAtom(friendPredicate, p3, p4) |
314 | DNFPredicate predicate = new DNFPredicate("PatternCall", substitution, List.of(patternCallClause)); | 312 | ) |
313 | .build(); | ||
315 | 314 | ||
316 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 315 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
317 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); | 316 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); |
@@ -339,25 +338,25 @@ class QueryTest { | |||
339 | 338 | ||
340 | Variable p1 = new Variable("p1"); | 339 | Variable p1 = new Variable("p1"); |
341 | Variable p2 = new Variable("p2"); | 340 | Variable p2 = new Variable("p2"); |
342 | List<Variable> parameters = Arrays.asList(p1, p2); | 341 | DNF friendPredicate = DNF.builder("RelationConstraint") |
343 | 342 | .parameters(p1, p2) | |
344 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 343 | .clause( |
345 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 344 | new RelationViewAtom(personView, p1), |
346 | RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 345 | new RelationViewAtom(personView, p2), |
347 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 346 | new RelationViewAtom(friendMustView, p1, p2) |
348 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom)); | 347 | ) |
349 | DNFPredicate friendPredicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 348 | .build(); |
350 | 349 | ||
351 | Variable p3 = new Variable("p3"); | 350 | Variable p3 = new Variable("p3"); |
352 | Variable p4 = new Variable("p4"); | 351 | Variable p4 = new Variable("p4"); |
353 | List<Variable> substitution = Arrays.asList(p3, p4); | 352 | DNF predicate = DNF.builder("NegativePatternCall") |
354 | RelationAtom personRelationAtom3 = new RelationAtom(personView, List.of(p3)); | 353 | .parameters(p3, p4) |
355 | RelationAtom personRelationAtom4 = new RelationAtom(personView, List.of(p4)); | 354 | .clause( |
356 | PredicateAtom friendPredicateAtom = new PredicateAtom(false, false, friendPredicate, substitution); | 355 | new RelationViewAtom(personView, p3), |
357 | DNFAnd negativePatternCallClause = new DNFAnd(Collections.emptySet(), | 356 | new RelationViewAtom(personView, p4), |
358 | Arrays.asList(personRelationAtom3, personRelationAtom4, friendPredicateAtom)); | 357 | new DNFCallAtom(CallKind.NEGATIVE, friendPredicate, p3, p4) |
359 | DNFPredicate predicate = new DNFPredicate("NegativePatternCall", substitution, | 358 | ) |
360 | List.of(negativePatternCallClause)); | 359 | .build(); |
361 | 360 | ||
362 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 361 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
363 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); | 362 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); |
@@ -384,25 +383,25 @@ class QueryTest { | |||
384 | 383 | ||
385 | Variable p1 = new Variable("p1"); | 384 | Variable p1 = new Variable("p1"); |
386 | Variable p2 = new Variable("p2"); | 385 | Variable p2 = new Variable("p2"); |
387 | List<Variable> parameters = Arrays.asList(p1, p2); | 386 | DNF friendPredicate = DNF.builder("RelationConstraint") |
388 | 387 | .parameters(p1, p2) | |
389 | RelationAtom personRelationAtom1 = new RelationAtom(personView, List.of(p1)); | 388 | .clause( |
390 | RelationAtom personRelationAtom2 = new RelationAtom(personView, List.of(p2)); | 389 | new RelationViewAtom(personView, p1), |
391 | RelationAtom friendRelationAtom = new RelationAtom(friendMustView, Arrays.asList(p1, p2)); | 390 | new RelationViewAtom(personView, p2), |
392 | DNFAnd clause = new DNFAnd(Collections.emptySet(), | 391 | new RelationViewAtom(friendMustView, p1, p2) |
393 | Arrays.asList(personRelationAtom1, personRelationAtom2, friendRelationAtom)); | 392 | ) |
394 | DNFPredicate friendPredicate = new DNFPredicate("RelationConstraint", parameters, List.of(clause)); | 393 | .build(); |
395 | 394 | ||
396 | Variable p3 = new Variable("p3"); | 395 | Variable p3 = new Variable("p3"); |
397 | Variable p4 = new Variable("p4"); | 396 | Variable p4 = new Variable("p4"); |
398 | List<Variable> substitution = Arrays.asList(p3, p4); | 397 | DNF predicate = DNF.builder("TransitivePatternCall") |
399 | RelationAtom personRelationAtom3 = new RelationAtom(personView, List.of(p3)); | 398 | .parameters(p3, p4) |
400 | RelationAtom personRelationAtom4 = new RelationAtom(personView, List.of(p4)); | 399 | .clause( |
401 | PredicateAtom friendPredicateAtom = new PredicateAtom(true, true, friendPredicate, substitution); | 400 | new RelationViewAtom(personView, p3), |
402 | DNFAnd patternCallClause = new DNFAnd(Collections.emptySet(), | 401 | new RelationViewAtom(personView, p4), |
403 | Arrays.asList(personRelationAtom3, personRelationAtom4, friendPredicateAtom)); | 402 | new DNFCallAtom(CallKind.TRANSITIVE, friendPredicate, p3, p4) |
404 | DNFPredicate predicate = new DNFPredicate("TransitivePatternCall", substitution, | 403 | ) |
405 | List.of(patternCallClause)); | 404 | .build(); |
406 | 405 | ||
407 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), | 406 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, friend), |
408 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); | 407 | Set.of(personView, friendMustView), Set.of(friendPredicate, predicate)); |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java index f57bca2b..a555f024 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java | |||
@@ -1,20 +1,17 @@ | |||
1 | package tools.refinery.store.query.viatra.tests; | 1 | package tools.refinery.store.query.viatra.tests; |
2 | 2 | ||
3 | import org.junit.jupiter.api.Test; | 3 | import org.junit.jupiter.api.Test; |
4 | import tools.refinery.store.tuple.Tuple; | ||
5 | import tools.refinery.store.model.representation.Relation; | 4 | import tools.refinery.store.model.representation.Relation; |
5 | import tools.refinery.store.query.DNF; | ||
6 | import tools.refinery.store.query.QueryableModel; | 6 | import tools.refinery.store.query.QueryableModel; |
7 | import tools.refinery.store.query.QueryableModelStore; | 7 | import tools.refinery.store.query.QueryableModelStore; |
8 | import tools.refinery.store.query.building.DNFAnd; | 8 | import tools.refinery.store.query.Variable; |
9 | import tools.refinery.store.query.building.DNFPredicate; | 9 | import tools.refinery.store.query.atom.RelationViewAtom; |
10 | import tools.refinery.store.query.building.RelationAtom; | ||
11 | import tools.refinery.store.query.building.Variable; | ||
12 | import tools.refinery.store.query.viatra.ViatraQueryableModelStore; | 10 | import tools.refinery.store.query.viatra.ViatraQueryableModelStore; |
13 | import tools.refinery.store.query.view.KeyOnlyRelationView; | 11 | import tools.refinery.store.query.view.KeyOnlyRelationView; |
14 | import tools.refinery.store.query.view.RelationView; | 12 | import tools.refinery.store.query.view.RelationView; |
13 | import tools.refinery.store.tuple.Tuple; | ||
15 | 14 | ||
16 | import java.util.Collections; | ||
17 | import java.util.List; | ||
18 | import java.util.Set; | 15 | import java.util.Set; |
19 | 16 | ||
20 | import static org.junit.jupiter.api.Assertions.assertEquals; | 17 | import static org.junit.jupiter.api.Assertions.assertEquals; |
@@ -26,10 +23,11 @@ class QueryTransactionTest { | |||
26 | Relation<Boolean> asset = new Relation<>("Asset", 1, false); | 23 | Relation<Boolean> asset = new Relation<>("Asset", 1, false); |
27 | RelationView<Boolean> personView = new KeyOnlyRelationView(person); | 24 | RelationView<Boolean> personView = new KeyOnlyRelationView(person); |
28 | 25 | ||
29 | List<Variable> parameters = List.of(new Variable("p1")); | 26 | var p1 = new Variable("p1"); |
30 | RelationAtom personRelationAtom = new RelationAtom(personView, parameters); | 27 | DNF predicate = DNF.builder("TypeConstraint") |
31 | DNFAnd clause = new DNFAnd(Collections.emptySet(), List.of(personRelationAtom)); | 28 | .parameters(p1) |
32 | DNFPredicate predicate = new DNFPredicate("TypeConstraint", parameters, List.of(clause)); | 29 | .clause(new RelationViewAtom(personView, p1)) |
30 | .build(); | ||
33 | 31 | ||
34 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, asset), Set.of(personView), | 32 | QueryableModelStore store = new ViatraQueryableModelStore(Set.of(person, asset), Set.of(personView), |
35 | Set.of(predicate)); | 33 | Set.of(predicate)); |