diff options
Diffstat (limited to 'subprojects/store-query-viatra/src/test')
4 files changed, 67 insertions, 224 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java index 86a27f5b..b21c254c 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/DiagonalQueryTest.java | |||
@@ -11,6 +11,7 @@ import tools.refinery.store.query.ModelQueryAdapter; | |||
11 | import tools.refinery.store.query.dnf.Dnf; | 11 | import tools.refinery.store.query.dnf.Dnf; |
12 | import tools.refinery.store.query.dnf.Query; | 12 | import tools.refinery.store.query.dnf.Query; |
13 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 13 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
14 | import tools.refinery.store.query.view.AnySymbolView; | ||
14 | import tools.refinery.store.query.view.FunctionView; | 15 | import tools.refinery.store.query.view.FunctionView; |
15 | import tools.refinery.store.query.view.KeyOnlyView; | 16 | import tools.refinery.store.query.view.KeyOnlyView; |
16 | import tools.refinery.store.representation.Symbol; | 17 | import tools.refinery.store.representation.Symbol; |
@@ -26,13 +27,17 @@ import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertNull | |||
26 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; | 27 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; |
27 | 28 | ||
28 | class DiagonalQueryTest { | 29 | class DiagonalQueryTest { |
30 | private static final Symbol<Boolean> person = Symbol.of("Person", 1); | ||
31 | private static final Symbol<Boolean> friend = Symbol.of("friend", 2); | ||
32 | private static final Symbol<Boolean> symbol = Symbol.of("symbol", 4); | ||
33 | private static final Symbol<Integer> intSymbol = Symbol.of("intSymbol", 4, Integer.class); | ||
34 | private static final AnySymbolView personView = new KeyOnlyView<>(person); | ||
35 | private static final AnySymbolView friendView = new KeyOnlyView<>(friend); | ||
36 | private static final AnySymbolView symbolView = new KeyOnlyView<>(symbol); | ||
37 | private static final AnySymbolView intSymbolView = new FunctionView<>(intSymbol); | ||
38 | |||
29 | @QueryEngineTest | 39 | @QueryEngineTest |
30 | void inputKeyNegationTest(QueryEvaluationHint hint) { | 40 | void inputKeyNegationTest(QueryEvaluationHint hint) { |
31 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
32 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | ||
33 | var personView = new KeyOnlyView<>(person); | ||
34 | var symbolView = new KeyOnlyView<>(symbol); | ||
35 | |||
36 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause(p2 -> List.of( | 41 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause(p2 -> List.of( |
37 | personView.call(p1), | 42 | personView.call(p1), |
38 | not(symbolView.call(p1, p1, p2, p2)) | 43 | not(symbolView.call(p1, p1, p2, p2)) |
@@ -71,11 +76,6 @@ class DiagonalQueryTest { | |||
71 | 76 | ||
72 | @QueryEngineTest | 77 | @QueryEngineTest |
73 | void subQueryNegationTest(QueryEvaluationHint hint) { | 78 | void subQueryNegationTest(QueryEvaluationHint hint) { |
74 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
75 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | ||
76 | var personView = new KeyOnlyView<>(person); | ||
77 | var symbolView = new KeyOnlyView<>(symbol); | ||
78 | |||
79 | var subQuery = Dnf.of("SubQuery", builder -> { | 79 | var subQuery = Dnf.of("SubQuery", builder -> { |
80 | var p1 = builder.parameter("p1"); | 80 | var p1 = builder.parameter("p1"); |
81 | var p2 = builder.parameter("p2"); | 81 | var p2 = builder.parameter("p2"); |
@@ -128,11 +128,6 @@ class DiagonalQueryTest { | |||
128 | 128 | ||
129 | @QueryEngineTest | 129 | @QueryEngineTest |
130 | void inputKeyCountTest(QueryEvaluationHint hint) { | 130 | void inputKeyCountTest(QueryEvaluationHint hint) { |
131 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
132 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | ||
133 | var personView = new KeyOnlyView<>(person); | ||
134 | var symbolView = new KeyOnlyView<>(symbol); | ||
135 | |||
136 | var query = Query.of("Diagonal", Integer.class, (builder, p1, output) -> builder.clause(p2 -> List.of( | 131 | var query = Query.of("Diagonal", Integer.class, (builder, p1, output) -> builder.clause(p2 -> List.of( |
137 | personView.call(p1), | 132 | personView.call(p1), |
138 | output.assign(symbolView.count(p1, p1, p2, p2)) | 133 | output.assign(symbolView.count(p1, p1, p2, p2)) |
@@ -172,11 +167,6 @@ class DiagonalQueryTest { | |||
172 | 167 | ||
173 | @QueryEngineTest | 168 | @QueryEngineTest |
174 | void subQueryCountTest(QueryEvaluationHint hint) { | 169 | void subQueryCountTest(QueryEvaluationHint hint) { |
175 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
176 | var symbol = new Symbol<>("symbol", 4, Boolean.class, false); | ||
177 | var personView = new KeyOnlyView<>(person); | ||
178 | var symbolView = new KeyOnlyView<>(symbol); | ||
179 | |||
180 | var subQuery = Dnf.of("SubQuery", builder -> { | 170 | var subQuery = Dnf.of("SubQuery", builder -> { |
181 | var p1 = builder.parameter("p1"); | 171 | var p1 = builder.parameter("p1"); |
182 | var p2 = builder.parameter("p2"); | 172 | var p2 = builder.parameter("p2"); |
@@ -230,19 +220,14 @@ class DiagonalQueryTest { | |||
230 | 220 | ||
231 | @QueryEngineTest | 221 | @QueryEngineTest |
232 | void inputKeyAggregationTest(QueryEvaluationHint hint) { | 222 | void inputKeyAggregationTest(QueryEvaluationHint hint) { |
233 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
234 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); | ||
235 | var personView = new KeyOnlyView<>(person); | ||
236 | var symbolView = new FunctionView<>(symbol); | ||
237 | |||
238 | var query = Query.of("Diagonal", Integer.class, (builder, p1, output) -> builder.clause(Integer.class, | 223 | var query = Query.of("Diagonal", Integer.class, (builder, p1, output) -> builder.clause(Integer.class, |
239 | (p2, y) -> List.of( | 224 | (p2, y) -> List.of( |
240 | personView.call(p1), | 225 | personView.call(p1), |
241 | output.assign(symbolView.aggregate(y, INT_SUM, p1, p1, p2, p2, y)) | 226 | output.assign(intSymbolView.aggregate(y, INT_SUM, p1, p1, p2, p2, y)) |
242 | ))); | 227 | ))); |
243 | 228 | ||
244 | var store = ModelStore.builder() | 229 | var store = ModelStore.builder() |
245 | .symbols(person, symbol) | 230 | .symbols(person, intSymbol) |
246 | .with(ViatraModelQueryAdapter.builder() | 231 | .with(ViatraModelQueryAdapter.builder() |
247 | .defaultHint(hint) | 232 | .defaultHint(hint) |
248 | .queries(query)) | 233 | .queries(query)) |
@@ -250,7 +235,7 @@ class DiagonalQueryTest { | |||
250 | 235 | ||
251 | var model = store.createEmptyModel(); | 236 | var model = store.createEmptyModel(); |
252 | var personInterpretation = model.getInterpretation(person); | 237 | var personInterpretation = model.getInterpretation(person); |
253 | var symbolInterpretation = model.getInterpretation(symbol); | 238 | var intSymbolInterpretation = model.getInterpretation(intSymbol); |
254 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | 239 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); |
255 | var queryResultSet = queryEngine.getResultSet(query); | 240 | var queryResultSet = queryEngine.getResultSet(query); |
256 | 241 | ||
@@ -258,11 +243,11 @@ class DiagonalQueryTest { | |||
258 | personInterpretation.put(Tuple.of(1), true); | 243 | personInterpretation.put(Tuple.of(1), true); |
259 | personInterpretation.put(Tuple.of(2), true); | 244 | personInterpretation.put(Tuple.of(2), true); |
260 | 245 | ||
261 | symbolInterpretation.put(Tuple.of(0, 0, 1, 1), 1); | 246 | intSymbolInterpretation.put(Tuple.of(0, 0, 1, 1), 1); |
262 | symbolInterpretation.put(Tuple.of(0, 0, 2, 2), 2); | 247 | intSymbolInterpretation.put(Tuple.of(0, 0, 2, 2), 2); |
263 | symbolInterpretation.put(Tuple.of(0, 0, 1, 2), 10); | 248 | intSymbolInterpretation.put(Tuple.of(0, 0, 1, 2), 10); |
264 | symbolInterpretation.put(Tuple.of(1, 1, 0, 1), 11); | 249 | intSymbolInterpretation.put(Tuple.of(1, 1, 0, 1), 11); |
265 | symbolInterpretation.put(Tuple.of(1, 2, 1, 1), 12); | 250 | intSymbolInterpretation.put(Tuple.of(1, 2, 1, 1), 12); |
266 | 251 | ||
267 | queryEngine.flushChanges(); | 252 | queryEngine.flushChanges(); |
268 | assertNullableResults(Map.of( | 253 | assertNullableResults(Map.of( |
@@ -275,11 +260,6 @@ class DiagonalQueryTest { | |||
275 | 260 | ||
276 | @QueryEngineTest | 261 | @QueryEngineTest |
277 | void subQueryAggregationTest(QueryEvaluationHint hint) { | 262 | void subQueryAggregationTest(QueryEvaluationHint hint) { |
278 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
279 | var symbol = new Symbol<>("symbol", 4, Integer.class, null); | ||
280 | var personView = new KeyOnlyView<>(person); | ||
281 | var symbolView = new FunctionView<>(symbol); | ||
282 | |||
283 | var subQuery = Dnf.of("SubQuery", builder -> { | 263 | var subQuery = Dnf.of("SubQuery", builder -> { |
284 | var p1 = builder.parameter("p1"); | 264 | var p1 = builder.parameter("p1"); |
285 | var p2 = builder.parameter("p2"); | 265 | var p2 = builder.parameter("p2"); |
@@ -289,12 +269,12 @@ class DiagonalQueryTest { | |||
289 | var y = builder.parameter("y", Integer.class); | 269 | var y = builder.parameter("y", Integer.class); |
290 | builder.clause( | 270 | builder.clause( |
291 | personView.call(p1), | 271 | personView.call(p1), |
292 | symbolView.call(p1, p2, p3, p4, x), | 272 | intSymbolView.call(p1, p2, p3, p4, x), |
293 | y.assign(x) | 273 | y.assign(x) |
294 | ); | 274 | ); |
295 | builder.clause( | 275 | builder.clause( |
296 | personView.call(p2), | 276 | personView.call(p2), |
297 | symbolView.call(p1, p2, p3, p4, x), | 277 | intSymbolView.call(p1, p2, p3, p4, x), |
298 | y.assign(x) | 278 | y.assign(x) |
299 | ); | 279 | ); |
300 | }); | 280 | }); |
@@ -305,7 +285,7 @@ class DiagonalQueryTest { | |||
305 | ))); | 285 | ))); |
306 | 286 | ||
307 | var store = ModelStore.builder() | 287 | var store = ModelStore.builder() |
308 | .symbols(person, symbol) | 288 | .symbols(person, intSymbol) |
309 | .with(ViatraModelQueryAdapter.builder() | 289 | .with(ViatraModelQueryAdapter.builder() |
310 | .defaultHint(hint) | 290 | .defaultHint(hint) |
311 | .queries(query)) | 291 | .queries(query)) |
@@ -313,7 +293,7 @@ class DiagonalQueryTest { | |||
313 | 293 | ||
314 | var model = store.createEmptyModel(); | 294 | var model = store.createEmptyModel(); |
315 | var personInterpretation = model.getInterpretation(person); | 295 | var personInterpretation = model.getInterpretation(person); |
316 | var symbolInterpretation = model.getInterpretation(symbol); | 296 | var intSymbolInterpretation = model.getInterpretation(intSymbol); |
317 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | 297 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); |
318 | var queryResultSet = queryEngine.getResultSet(query); | 298 | var queryResultSet = queryEngine.getResultSet(query); |
319 | 299 | ||
@@ -321,11 +301,11 @@ class DiagonalQueryTest { | |||
321 | personInterpretation.put(Tuple.of(1), true); | 301 | personInterpretation.put(Tuple.of(1), true); |
322 | personInterpretation.put(Tuple.of(2), true); | 302 | personInterpretation.put(Tuple.of(2), true); |
323 | 303 | ||
324 | symbolInterpretation.put(Tuple.of(0, 0, 1, 1), 1); | 304 | intSymbolInterpretation.put(Tuple.of(0, 0, 1, 1), 1); |
325 | symbolInterpretation.put(Tuple.of(0, 0, 2, 2), 2); | 305 | intSymbolInterpretation.put(Tuple.of(0, 0, 2, 2), 2); |
326 | symbolInterpretation.put(Tuple.of(0, 0, 1, 2), 10); | 306 | intSymbolInterpretation.put(Tuple.of(0, 0, 1, 2), 10); |
327 | symbolInterpretation.put(Tuple.of(1, 1, 0, 1), 11); | 307 | intSymbolInterpretation.put(Tuple.of(1, 1, 0, 1), 11); |
328 | symbolInterpretation.put(Tuple.of(1, 2, 1, 1), 12); | 308 | intSymbolInterpretation.put(Tuple.of(1, 2, 1, 1), 12); |
329 | 309 | ||
330 | queryEngine.flushChanges(); | 310 | queryEngine.flushChanges(); |
331 | assertNullableResults(Map.of( | 311 | assertNullableResults(Map.of( |
@@ -338,18 +318,13 @@ class DiagonalQueryTest { | |||
338 | 318 | ||
339 | @QueryEngineTest | 319 | @QueryEngineTest |
340 | void inputKeyTransitiveTest(QueryEvaluationHint hint) { | 320 | void inputKeyTransitiveTest(QueryEvaluationHint hint) { |
341 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
342 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); | ||
343 | var personView = new KeyOnlyView<>(person); | ||
344 | var symbolView = new KeyOnlyView<>(symbol); | ||
345 | |||
346 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause( | 321 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause( |
347 | personView.call(p1), | 322 | personView.call(p1), |
348 | symbolView.callTransitive(p1, p1) | 323 | friendView.callTransitive(p1, p1) |
349 | )); | 324 | )); |
350 | 325 | ||
351 | var store = ModelStore.builder() | 326 | var store = ModelStore.builder() |
352 | .symbols(person, symbol) | 327 | .symbols(person, friend) |
353 | .with(ViatraModelQueryAdapter.builder() | 328 | .with(ViatraModelQueryAdapter.builder() |
354 | .defaultHint(hint) | 329 | .defaultHint(hint) |
355 | .queries(query)) | 330 | .queries(query)) |
@@ -357,7 +332,7 @@ class DiagonalQueryTest { | |||
357 | 332 | ||
358 | var model = store.createEmptyModel(); | 333 | var model = store.createEmptyModel(); |
359 | var personInterpretation = model.getInterpretation(person); | 334 | var personInterpretation = model.getInterpretation(person); |
360 | var symbolInterpretation = model.getInterpretation(symbol); | 335 | var friendInterpretation = model.getInterpretation(friend); |
361 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | 336 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); |
362 | var queryResultSet = queryEngine.getResultSet(query); | 337 | var queryResultSet = queryEngine.getResultSet(query); |
363 | 338 | ||
@@ -365,9 +340,9 @@ class DiagonalQueryTest { | |||
365 | personInterpretation.put(Tuple.of(1), true); | 340 | personInterpretation.put(Tuple.of(1), true); |
366 | personInterpretation.put(Tuple.of(2), true); | 341 | personInterpretation.put(Tuple.of(2), true); |
367 | 342 | ||
368 | symbolInterpretation.put(Tuple.of(0, 0), true); | 343 | friendInterpretation.put(Tuple.of(0, 0), true); |
369 | symbolInterpretation.put(Tuple.of(0, 1), true); | 344 | friendInterpretation.put(Tuple.of(0, 1), true); |
370 | symbolInterpretation.put(Tuple.of(1, 2), true); | 345 | friendInterpretation.put(Tuple.of(1, 2), true); |
371 | 346 | ||
372 | queryEngine.flushChanges(); | 347 | queryEngine.flushChanges(); |
373 | assertResults(Map.of( | 348 | assertResults(Map.of( |
@@ -380,21 +355,16 @@ class DiagonalQueryTest { | |||
380 | 355 | ||
381 | @QueryEngineTest | 356 | @QueryEngineTest |
382 | void subQueryTransitiveTest(QueryEvaluationHint hint) { | 357 | void subQueryTransitiveTest(QueryEvaluationHint hint) { |
383 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
384 | var symbol = new Symbol<>("symbol", 2, Boolean.class, false); | ||
385 | var personView = new KeyOnlyView<>(person); | ||
386 | var symbolView = new KeyOnlyView<>(symbol); | ||
387 | |||
388 | var subQuery = Dnf.of("SubQuery", builder -> { | 358 | var subQuery = Dnf.of("SubQuery", builder -> { |
389 | var p1 = builder.parameter("p1"); | 359 | var p1 = builder.parameter("p1"); |
390 | var p2 = builder.parameter("p2"); | 360 | var p2 = builder.parameter("p2"); |
391 | builder.clause( | 361 | builder.clause( |
392 | personView.call(p1), | 362 | personView.call(p1), |
393 | symbolView.call(p1, p2) | 363 | friendView.call(p1, p2) |
394 | ); | 364 | ); |
395 | builder.clause( | 365 | builder.clause( |
396 | personView.call(p2), | 366 | personView.call(p2), |
397 | symbolView.call(p1, p2) | 367 | friendView.call(p1, p2) |
398 | ); | 368 | ); |
399 | }); | 369 | }); |
400 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause( | 370 | var query = Query.of("Diagonal", (builder, p1) -> builder.clause( |
@@ -403,7 +373,7 @@ class DiagonalQueryTest { | |||
403 | )); | 373 | )); |
404 | 374 | ||
405 | var store = ModelStore.builder() | 375 | var store = ModelStore.builder() |
406 | .symbols(person, symbol) | 376 | .symbols(person, friend) |
407 | .with(ViatraModelQueryAdapter.builder() | 377 | .with(ViatraModelQueryAdapter.builder() |
408 | .defaultHint(hint) | 378 | .defaultHint(hint) |
409 | .queries(query)) | 379 | .queries(query)) |
@@ -411,7 +381,7 @@ class DiagonalQueryTest { | |||
411 | 381 | ||
412 | var model = store.createEmptyModel(); | 382 | var model = store.createEmptyModel(); |
413 | var personInterpretation = model.getInterpretation(person); | 383 | var personInterpretation = model.getInterpretation(person); |
414 | var symbolInterpretation = model.getInterpretation(symbol); | 384 | var friendInterpretation = model.getInterpretation(friend); |
415 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | 385 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); |
416 | var queryResultSet = queryEngine.getResultSet(query); | 386 | var queryResultSet = queryEngine.getResultSet(query); |
417 | 387 | ||
@@ -419,9 +389,9 @@ class DiagonalQueryTest { | |||
419 | personInterpretation.put(Tuple.of(1), true); | 389 | personInterpretation.put(Tuple.of(1), true); |
420 | personInterpretation.put(Tuple.of(2), true); | 390 | personInterpretation.put(Tuple.of(2), true); |
421 | 391 | ||
422 | symbolInterpretation.put(Tuple.of(0, 0), true); | 392 | friendInterpretation.put(Tuple.of(0, 0), true); |
423 | symbolInterpretation.put(Tuple.of(0, 1), true); | 393 | friendInterpretation.put(Tuple.of(0, 1), true); |
424 | symbolInterpretation.put(Tuple.of(1, 2), true); | 394 | friendInterpretation.put(Tuple.of(1, 2), true); |
425 | 395 | ||
426 | queryEngine.flushChanges(); | 396 | queryEngine.flushChanges(); |
427 | assertResults(Map.of( | 397 | assertResults(Map.of( |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java index 98c8cd92..723e9180 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java | |||
@@ -13,6 +13,7 @@ import tools.refinery.store.query.dnf.Dnf; | |||
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
16 | import tools.refinery.store.query.view.AnySymbolView; | ||
16 | import tools.refinery.store.query.view.FilteredView; | 17 | import tools.refinery.store.query.view.FilteredView; |
17 | import tools.refinery.store.query.view.FunctionView; | 18 | import tools.refinery.store.query.view.FunctionView; |
18 | import tools.refinery.store.query.view.KeyOnlyView; | 19 | import tools.refinery.store.query.view.KeyOnlyView; |
@@ -35,13 +36,15 @@ import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertNull | |||
35 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; | 36 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; |
36 | 37 | ||
37 | class FunctionalQueryTest { | 38 | class FunctionalQueryTest { |
39 | private static final Symbol<Boolean> person = Symbol.of("Person", 1); | ||
40 | private static final Symbol<Integer> age = Symbol.of("age", 1, Integer.class); | ||
41 | private static final Symbol<TruthValue> friend = Symbol.of("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
42 | private static final AnySymbolView personView = new KeyOnlyView<>(person); | ||
43 | private static final AnySymbolView ageView = new FunctionView<>(age); | ||
44 | private static final AnySymbolView friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
45 | |||
38 | @QueryEngineTest | 46 | @QueryEngineTest |
39 | void inputKeyTest(QueryEvaluationHint hint) { | 47 | void inputKeyTest(QueryEvaluationHint hint) { |
40 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
41 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
42 | var personView = new KeyOnlyView<>(person); | ||
43 | var ageView = new FunctionView<>(age); | ||
44 | |||
45 | var query = Query.of("InputKey", Integer.class, (builder, p1, output) -> builder.clause( | 48 | var query = Query.of("InputKey", Integer.class, (builder, p1, output) -> builder.clause( |
46 | personView.call(p1), | 49 | personView.call(p1), |
47 | ageView.call(p1, output) | 50 | ageView.call(p1, output) |
@@ -77,11 +80,6 @@ class FunctionalQueryTest { | |||
77 | 80 | ||
78 | @QueryEngineTest | 81 | @QueryEngineTest |
79 | void predicateTest(QueryEvaluationHint hint) { | 82 | void predicateTest(QueryEvaluationHint hint) { |
80 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
81 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
82 | var personView = new KeyOnlyView<>(person); | ||
83 | var ageView = new FunctionView<>(age); | ||
84 | |||
85 | var subQuery = Dnf.of("SubQuery", builder -> { | 83 | var subQuery = Dnf.of("SubQuery", builder -> { |
86 | var p1 = builder.parameter("p1"); | 84 | var p1 = builder.parameter("p1"); |
87 | var x = builder.parameter("x", Integer.class); | 85 | var x = builder.parameter("x", Integer.class); |
@@ -125,11 +123,6 @@ class FunctionalQueryTest { | |||
125 | 123 | ||
126 | @QueryEngineTest | 124 | @QueryEngineTest |
127 | void computationTest(QueryEvaluationHint hint) { | 125 | void computationTest(QueryEvaluationHint hint) { |
128 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
129 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
130 | var personView = new KeyOnlyView<>(person); | ||
131 | var ageView = new FunctionView<>(age); | ||
132 | |||
133 | var query = Query.of("Computation", Integer.class, (builder, p1, output) -> builder.clause(() -> { | 126 | var query = Query.of("Computation", Integer.class, (builder, p1, output) -> builder.clause(() -> { |
134 | var x = Variable.of("x", Integer.class); | 127 | var x = Variable.of("x", Integer.class); |
135 | return List.of( | 128 | return List.of( |
@@ -168,11 +161,6 @@ class FunctionalQueryTest { | |||
168 | 161 | ||
169 | @QueryEngineTest | 162 | @QueryEngineTest |
170 | void inputKeyCountTest(QueryEvaluationHint hint) { | 163 | void inputKeyCountTest(QueryEvaluationHint hint) { |
171 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
172 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
173 | var personView = new KeyOnlyView<>(person); | ||
174 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
175 | |||
176 | var query = Query.of("Count", Integer.class, (builder, p1, output) -> builder.clause( | 164 | var query = Query.of("Count", Integer.class, (builder, p1, output) -> builder.clause( |
177 | personView.call(p1), | 165 | personView.call(p1), |
178 | output.assign(friendMustView.count(p1, Variable.of())) | 166 | output.assign(friendMustView.count(p1, Variable.of())) |
@@ -210,11 +198,6 @@ class FunctionalQueryTest { | |||
210 | 198 | ||
211 | @QueryEngineTest | 199 | @QueryEngineTest |
212 | void predicateCountTest(QueryEvaluationHint hint) { | 200 | void predicateCountTest(QueryEvaluationHint hint) { |
213 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
214 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
215 | var personView = new KeyOnlyView<>(person); | ||
216 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
217 | |||
218 | var subQuery = Dnf.of("SubQuery", builder -> { | 201 | var subQuery = Dnf.of("SubQuery", builder -> { |
219 | var p1 = builder.parameter("p1"); | 202 | var p1 = builder.parameter("p1"); |
220 | var p2 = builder.parameter("p2"); | 203 | var p2 = builder.parameter("p2"); |
@@ -261,9 +244,6 @@ class FunctionalQueryTest { | |||
261 | 244 | ||
262 | @QueryEngineTest | 245 | @QueryEngineTest |
263 | void inputKeyAggregationTest(QueryEvaluationHint hint) { | 246 | void inputKeyAggregationTest(QueryEvaluationHint hint) { |
264 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
265 | var ageView = new FunctionView<>(age); | ||
266 | |||
267 | var query = Query.of("Aggregate", Integer.class, (builder, output) -> builder.clause(Integer.class, | 247 | var query = Query.of("Aggregate", Integer.class, (builder, output) -> builder.clause(Integer.class, |
268 | (y) -> List.of(output.assign(ageView.aggregate(y, INT_SUM, Variable.of(), y))))); | 248 | (y) -> List.of(output.assign(ageView.aggregate(y, INT_SUM, Variable.of(), y))))); |
269 | 249 | ||
@@ -288,11 +268,6 @@ class FunctionalQueryTest { | |||
288 | 268 | ||
289 | @QueryEngineTest | 269 | @QueryEngineTest |
290 | void predicateAggregationTest(QueryEvaluationHint hint) { | 270 | void predicateAggregationTest(QueryEvaluationHint hint) { |
291 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
292 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
293 | var personView = new KeyOnlyView<>(person); | ||
294 | var ageView = new FunctionView<>(age); | ||
295 | |||
296 | var subQuery = Dnf.of("SubQuery", builder -> { | 271 | var subQuery = Dnf.of("SubQuery", builder -> { |
297 | var p1 = builder.parameter("p1"); | 272 | var p1 = builder.parameter("p1"); |
298 | var x = builder.parameter("x", Integer.class); | 273 | var x = builder.parameter("x", Integer.class); |
@@ -329,11 +304,6 @@ class FunctionalQueryTest { | |||
329 | 304 | ||
330 | @QueryEngineTest | 305 | @QueryEngineTest |
331 | void extremeValueTest(QueryEvaluationHint hint) { | 306 | void extremeValueTest(QueryEvaluationHint hint) { |
332 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
333 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
334 | var personView = new KeyOnlyView<>(person); | ||
335 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
336 | |||
337 | var subQuery = Dnf.of("SubQuery", builder -> { | 307 | var subQuery = Dnf.of("SubQuery", builder -> { |
338 | var p1 = builder.parameter("p1"); | 308 | var p1 = builder.parameter("p1"); |
339 | var x = builder.parameter("x", Integer.class); | 309 | var x = builder.parameter("x", Integer.class); |
@@ -394,11 +364,6 @@ class FunctionalQueryTest { | |||
394 | 364 | ||
395 | @QueryEngineTest | 365 | @QueryEngineTest |
396 | void invalidComputationTest(QueryEvaluationHint hint) { | 366 | void invalidComputationTest(QueryEvaluationHint hint) { |
397 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
398 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
399 | var personView = new KeyOnlyView<>(person); | ||
400 | var ageView = new FunctionView<>(age); | ||
401 | |||
402 | var query = Query.of("InvalidComputation", Integer.class, | 367 | var query = Query.of("InvalidComputation", Integer.class, |
403 | (builder, p1, output) -> builder.clause(Integer.class, (x) -> List.of( | 368 | (builder, p1, output) -> builder.clause(Integer.class, (x) -> List.of( |
404 | personView.call(p1), | 369 | personView.call(p1), |
@@ -435,11 +400,6 @@ class FunctionalQueryTest { | |||
435 | 400 | ||
436 | @QueryEngineTest | 401 | @QueryEngineTest |
437 | void invalidAssumeTest(QueryEvaluationHint hint) { | 402 | void invalidAssumeTest(QueryEvaluationHint hint) { |
438 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
439 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
440 | var personView = new KeyOnlyView<>(person); | ||
441 | var ageView = new FunctionView<>(age); | ||
442 | |||
443 | var query = Query.of("InvalidAssume", (builder, p1) -> builder.clause(Integer.class, (x) -> List.of( | 403 | var query = Query.of("InvalidAssume", (builder, p1) -> builder.clause(Integer.class, (x) -> List.of( |
444 | personView.call(p1), | 404 | personView.call(p1), |
445 | ageView.call(p1, x), | 405 | ageView.call(p1, x), |
@@ -478,13 +438,6 @@ class FunctionalQueryTest { | |||
478 | 438 | ||
479 | @QueryEngineTest | 439 | @QueryEngineTest |
480 | void notFunctionalTest(QueryEvaluationHint hint) { | 440 | void notFunctionalTest(QueryEvaluationHint hint) { |
481 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
482 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
483 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
484 | var personView = new KeyOnlyView<>(person); | ||
485 | var ageView = new FunctionView<>(age); | ||
486 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
487 | |||
488 | var query = Query.of("NotFunctional", Integer.class, (builder, p1, output) -> builder.clause((p2) -> List.of( | 441 | var query = Query.of("NotFunctional", Integer.class, (builder, p1, output) -> builder.clause((p2) -> List.of( |
489 | personView.call(p1), | 442 | personView.call(p1), |
490 | friendMustView.call(p1, p2), | 443 | friendMustView.call(p1, p2), |
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 a9a2f71c..de0e6da1 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 | |||
@@ -13,6 +13,7 @@ import tools.refinery.store.query.dnf.Dnf; | |||
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; | 15 | import tools.refinery.store.query.viatra.tests.QueryEngineTest; |
16 | import tools.refinery.store.query.view.AnySymbolView; | ||
16 | import tools.refinery.store.query.view.FilteredView; | 17 | import tools.refinery.store.query.view.FilteredView; |
17 | import tools.refinery.store.query.view.FunctionView; | 18 | import tools.refinery.store.query.view.FunctionView; |
18 | import tools.refinery.store.query.view.KeyOnlyView; | 19 | import tools.refinery.store.query.view.KeyOnlyView; |
@@ -30,11 +31,14 @@ import static tools.refinery.store.query.term.int_.IntTerms.greaterEq; | |||
30 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; | 31 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; |
31 | 32 | ||
32 | class QueryTest { | 33 | class QueryTest { |
34 | private static final Symbol<Boolean> person = Symbol.of("Person", 1); | ||
35 | private static final Symbol<TruthValue> friend = Symbol.of("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
36 | private static final AnySymbolView personView = new KeyOnlyView<>(person); | ||
37 | private static final AnySymbolView friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
38 | |||
33 | @QueryEngineTest | 39 | @QueryEngineTest |
34 | void typeConstraintTest(QueryEvaluationHint hint) { | 40 | void typeConstraintTest(QueryEvaluationHint hint) { |
35 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 41 | var asset = Symbol.of("Asset", 1); |
36 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); | ||
37 | var personView = new KeyOnlyView<>(person); | ||
38 | 42 | ||
39 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | 43 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); |
40 | 44 | ||
@@ -67,11 +71,6 @@ class QueryTest { | |||
67 | 71 | ||
68 | @QueryEngineTest | 72 | @QueryEngineTest |
69 | void relationConstraintTest(QueryEvaluationHint hint) { | 73 | void relationConstraintTest(QueryEvaluationHint hint) { |
70 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
71 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
72 | var personView = new KeyOnlyView<>(person); | ||
73 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
74 | |||
75 | var predicate = Query.of("RelationConstraint", (builder, p1, p2) -> builder.clause( | 74 | var predicate = Query.of("RelationConstraint", (builder, p1, p2) -> builder.clause( |
76 | personView.call(p1), | 75 | personView.call(p1), |
77 | personView.call(p2), | 76 | personView.call(p2), |
@@ -111,11 +110,6 @@ class QueryTest { | |||
111 | 110 | ||
112 | @QueryEngineTest | 111 | @QueryEngineTest |
113 | void existTest(QueryEvaluationHint hint) { | 112 | void existTest(QueryEvaluationHint hint) { |
114 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
115 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
116 | var personView = new KeyOnlyView<>(person); | ||
117 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
118 | |||
119 | var predicate = Query.of("Exists", (builder, p1) -> builder.clause((p2) -> List.of( | 113 | var predicate = Query.of("Exists", (builder, p1) -> builder.clause((p2) -> List.of( |
120 | personView.call(p1), | 114 | personView.call(p1), |
121 | personView.call(p2), | 115 | personView.call(p2), |
@@ -155,12 +149,8 @@ class QueryTest { | |||
155 | 149 | ||
156 | @QueryEngineTest | 150 | @QueryEngineTest |
157 | void orTest(QueryEvaluationHint hint) { | 151 | void orTest(QueryEvaluationHint hint) { |
158 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 152 | var animal = Symbol.of("Animal", 1); |
159 | var animal = new Symbol<>("Animal", 1, Boolean.class, false); | ||
160 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
161 | var personView = new KeyOnlyView<>(person); | ||
162 | var animalView = new KeyOnlyView<>(animal); | 153 | var animalView = new KeyOnlyView<>(animal); |
163 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
164 | 154 | ||
165 | var predicate = Query.of("Or", (builder, p1, p2) -> builder.clause( | 155 | var predicate = Query.of("Or", (builder, p1, p2) -> builder.clause( |
166 | personView.call(p1), | 156 | personView.call(p1), |
@@ -209,9 +199,6 @@ class QueryTest { | |||
209 | 199 | ||
210 | @QueryEngineTest | 200 | @QueryEngineTest |
211 | void equalityTest(QueryEvaluationHint hint) { | 201 | void equalityTest(QueryEvaluationHint hint) { |
212 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
213 | var personView = new KeyOnlyView<>(person); | ||
214 | |||
215 | var predicate = Query.of("Equality", (builder, p1, p2) -> builder.clause( | 202 | var predicate = Query.of("Equality", (builder, p1, p2) -> builder.clause( |
216 | personView.call(p1), | 203 | personView.call(p1), |
217 | personView.call(p2), | 204 | personView.call(p2), |
@@ -246,11 +233,6 @@ class QueryTest { | |||
246 | 233 | ||
247 | @QueryEngineTest | 234 | @QueryEngineTest |
248 | void inequalityTest(QueryEvaluationHint hint) { | 235 | void inequalityTest(QueryEvaluationHint hint) { |
249 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
250 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
251 | var personView = new KeyOnlyView<>(person); | ||
252 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
253 | |||
254 | var predicate = Query.of("Inequality", (builder, p1, p2, p3) -> builder.clause( | 236 | var predicate = Query.of("Inequality", (builder, p1, p2, p3) -> builder.clause( |
255 | personView.call(p1), | 237 | personView.call(p1), |
256 | personView.call(p2), | 238 | personView.call(p2), |
@@ -289,11 +271,6 @@ class QueryTest { | |||
289 | 271 | ||
290 | @QueryEngineTest | 272 | @QueryEngineTest |
291 | void patternCallTest(QueryEvaluationHint hint) { | 273 | void patternCallTest(QueryEvaluationHint hint) { |
292 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
293 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
294 | var personView = new KeyOnlyView<>(person); | ||
295 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
296 | |||
297 | var friendPredicate = Dnf.of("Friend", builder -> { | 274 | var friendPredicate = Dnf.of("Friend", builder -> { |
298 | var p1 = builder.parameter("p1"); | 275 | var p1 = builder.parameter("p1"); |
299 | var p2 = builder.parameter("p2"); | 276 | var p2 = builder.parameter("p2"); |
@@ -341,11 +318,6 @@ class QueryTest { | |||
341 | 318 | ||
342 | @QueryEngineTest | 319 | @QueryEngineTest |
343 | void negativeRelationViewTest(QueryEvaluationHint hint) { | 320 | void negativeRelationViewTest(QueryEvaluationHint hint) { |
344 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
345 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
346 | var personView = new KeyOnlyView<>(person); | ||
347 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
348 | |||
349 | var predicate = Query.of("NegativePatternCall", (builder, p1, p2) -> builder.clause( | 321 | var predicate = Query.of("NegativePatternCall", (builder, p1, p2) -> builder.clause( |
350 | personView.call(p1), | 322 | personView.call(p1), |
351 | personView.call(p2), | 323 | personView.call(p2), |
@@ -390,11 +362,6 @@ class QueryTest { | |||
390 | 362 | ||
391 | @QueryEngineTest | 363 | @QueryEngineTest |
392 | void negativePatternCallTest(QueryEvaluationHint hint) { | 364 | void negativePatternCallTest(QueryEvaluationHint hint) { |
393 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
394 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
395 | var personView = new KeyOnlyView<>(person); | ||
396 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
397 | |||
398 | var friendPredicate = Dnf.of("Friend", builder -> { | 365 | var friendPredicate = Dnf.of("Friend", builder -> { |
399 | var p1 = builder.parameter("p1"); | 366 | var p1 = builder.parameter("p1"); |
400 | var p2 = builder.parameter("p2"); | 367 | var p2 = builder.parameter("p2"); |
@@ -448,11 +415,6 @@ class QueryTest { | |||
448 | 415 | ||
449 | @QueryEngineTest | 416 | @QueryEngineTest |
450 | void negativeRelationViewWithQuantificationTest(QueryEvaluationHint hint) { | 417 | void negativeRelationViewWithQuantificationTest(QueryEvaluationHint hint) { |
451 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
452 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
453 | var personView = new KeyOnlyView<>(person); | ||
454 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
455 | |||
456 | var predicate = Query.of("Negative", (builder, p1) -> builder.clause( | 418 | var predicate = Query.of("Negative", (builder, p1) -> builder.clause( |
457 | personView.call(p1), | 419 | personView.call(p1), |
458 | not(friendMustView.call(p1, Variable.of())) | 420 | not(friendMustView.call(p1, Variable.of())) |
@@ -489,11 +451,6 @@ class QueryTest { | |||
489 | 451 | ||
490 | @QueryEngineTest | 452 | @QueryEngineTest |
491 | void negativeWithQuantificationTest(QueryEvaluationHint hint) { | 453 | void negativeWithQuantificationTest(QueryEvaluationHint hint) { |
492 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
493 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
494 | var personView = new KeyOnlyView<>(person); | ||
495 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
496 | |||
497 | var called = Dnf.of("Called", builder -> { | 454 | var called = Dnf.of("Called", builder -> { |
498 | var p1 = builder.parameter("p1"); | 455 | var p1 = builder.parameter("p1"); |
499 | var p2 = builder.parameter("p2"); | 456 | var p2 = builder.parameter("p2"); |
@@ -539,11 +496,6 @@ class QueryTest { | |||
539 | 496 | ||
540 | @QueryEngineTest | 497 | @QueryEngineTest |
541 | void transitiveRelationViewTest(QueryEvaluationHint hint) { | 498 | void transitiveRelationViewTest(QueryEvaluationHint hint) { |
542 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
543 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
544 | var personView = new KeyOnlyView<>(person); | ||
545 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
546 | |||
547 | var predicate = Query.of("Transitive", (builder, p1, p2) -> builder.clause( | 499 | var predicate = Query.of("Transitive", (builder, p1, p2) -> builder.clause( |
548 | personView.call(p1), | 500 | personView.call(p1), |
549 | personView.call(p2), | 501 | personView.call(p2), |
@@ -587,11 +539,6 @@ class QueryTest { | |||
587 | 539 | ||
588 | @QueryEngineTest | 540 | @QueryEngineTest |
589 | void transitivePatternCallTest(QueryEvaluationHint hint) { | 541 | void transitivePatternCallTest(QueryEvaluationHint hint) { |
590 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
591 | var friend = new Symbol<>("friend", 2, TruthValue.class, TruthValue.FALSE); | ||
592 | var personView = new KeyOnlyView<>(person); | ||
593 | var friendMustView = new FilteredView<>(friend, "must", TruthValue::must); | ||
594 | |||
595 | var called = Dnf.of("Called", builder -> { | 542 | var called = Dnf.of("Called", builder -> { |
596 | var p1 = builder.parameter("p1"); | 543 | var p1 = builder.parameter("p1"); |
597 | var p2 = builder.parameter("p2"); | 544 | var p2 = builder.parameter("p2"); |
@@ -644,9 +591,7 @@ class QueryTest { | |||
644 | 591 | ||
645 | @QueryEngineTest | 592 | @QueryEngineTest |
646 | void assumeTest(QueryEvaluationHint hint) { | 593 | void assumeTest(QueryEvaluationHint hint) { |
647 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 594 | var age = Symbol.of("age", 1, Integer.class); |
648 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
649 | var personView = new KeyOnlyView<>(person); | ||
650 | var ageView = new FunctionView<>(age); | 595 | var ageView = new FunctionView<>(age); |
651 | 596 | ||
652 | var query = Query.of("Constraint", (builder, p1) -> builder.clause(Integer.class, (x) -> List.of( | 597 | var query = Query.of("Constraint", (builder, p1) -> builder.clause(Integer.class, (x) -> List.of( |
@@ -684,8 +629,6 @@ class QueryTest { | |||
684 | 629 | ||
685 | @Test | 630 | @Test |
686 | void alwaysFalseTest() { | 631 | void alwaysFalseTest() { |
687 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
688 | |||
689 | var predicate = Query.of("AlwaysFalse", builder -> builder.parameter("p1")); | 632 | var predicate = Query.of("AlwaysFalse", builder -> builder.parameter("p1")); |
690 | 633 | ||
691 | var store = ModelStore.builder() | 634 | var store = ModelStore.builder() |
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java index 6860ece9..66f043c6 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/QueryTransactionTest.java | |||
@@ -11,6 +11,8 @@ import org.junit.jupiter.api.Test; | |||
11 | import tools.refinery.store.model.ModelStore; | 11 | import tools.refinery.store.model.ModelStore; |
12 | import tools.refinery.store.query.ModelQueryAdapter; | 12 | import tools.refinery.store.query.ModelQueryAdapter; |
13 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.dnf.RelationalQuery; | ||
15 | import tools.refinery.store.query.view.AnySymbolView; | ||
14 | import tools.refinery.store.query.view.FilteredView; | 16 | import tools.refinery.store.query.view.FilteredView; |
15 | import tools.refinery.store.query.view.FunctionView; | 17 | import tools.refinery.store.query.view.FunctionView; |
16 | import tools.refinery.store.query.view.KeyOnlyView; | 18 | import tools.refinery.store.query.view.KeyOnlyView; |
@@ -26,13 +28,15 @@ import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertNull | |||
26 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; | 28 | import static tools.refinery.store.query.viatra.tests.QueryAssertions.assertResults; |
27 | 29 | ||
28 | class QueryTransactionTest { | 30 | class QueryTransactionTest { |
31 | private static final Symbol<Boolean> person = Symbol.of("Person", 1); | ||
32 | private static final Symbol<Integer> age = Symbol.of("age", 1, Integer.class); | ||
33 | private static final AnySymbolView personView = new KeyOnlyView<>(person); | ||
34 | private static final AnySymbolView ageView = new FunctionView<>(age); | ||
35 | private static final RelationalQuery predicate = Query.of("TypeConstraint", (builder, p1) -> | ||
36 | builder.clause(personView.call(p1))); | ||
37 | |||
29 | @Test | 38 | @Test |
30 | void flushTest() { | 39 | void flushTest() { |
31 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
32 | var personView = new KeyOnlyView<>(person); | ||
33 | |||
34 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | ||
35 | |||
36 | var store = ModelStore.builder() | 40 | var store = ModelStore.builder() |
37 | .symbols(person) | 41 | .symbols(person) |
38 | .with(ViatraModelQueryAdapter.builder() | 42 | .with(ViatraModelQueryAdapter.builder() |
@@ -95,11 +99,6 @@ class QueryTransactionTest { | |||
95 | 99 | ||
96 | @Test | 100 | @Test |
97 | void localSearchTest() { | 101 | void localSearchTest() { |
98 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
99 | var personView = new KeyOnlyView<>(person); | ||
100 | |||
101 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | ||
102 | |||
103 | var store = ModelStore.builder() | 102 | var store = ModelStore.builder() |
104 | .symbols(person) | 103 | .symbols(person) |
105 | .with(ViatraModelQueryAdapter.builder() | 104 | .with(ViatraModelQueryAdapter.builder() |
@@ -145,11 +144,7 @@ class QueryTransactionTest { | |||
145 | 144 | ||
146 | @Test | 145 | @Test |
147 | void unrelatedChangesTest() { | 146 | void unrelatedChangesTest() { |
148 | var person = new Symbol<>("Person", 1, Boolean.class, false); | 147 | var asset = Symbol.of("Asset", 1); |
149 | var asset = new Symbol<>("Asset", 1, Boolean.class, false); | ||
150 | var personView = new KeyOnlyView<>(person); | ||
151 | |||
152 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | ||
153 | 148 | ||
154 | var store = ModelStore.builder() | 149 | var store = ModelStore.builder() |
155 | .symbols(person, asset) | 150 | .symbols(person, asset) |
@@ -214,11 +209,6 @@ class QueryTransactionTest { | |||
214 | 209 | ||
215 | @Test | 210 | @Test |
216 | void tupleChangingChangeTest() { | 211 | void tupleChangingChangeTest() { |
217 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
218 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
219 | var personView = new KeyOnlyView<>(person); | ||
220 | var ageView = new FunctionView<>(age); | ||
221 | |||
222 | var query = Query.of("TypeConstraint", Integer.class, (builder, p1, output) -> builder.clause( | 212 | var query = Query.of("TypeConstraint", Integer.class, (builder, p1, output) -> builder.clause( |
223 | personView.call(p1), | 213 | personView.call(p1), |
224 | ageView.call(p1, output) | 214 | ageView.call(p1, output) |
@@ -256,9 +246,6 @@ class QueryTransactionTest { | |||
256 | 246 | ||
257 | @Test | 247 | @Test |
258 | void tuplePreservingUnchangedTest() { | 248 | void tuplePreservingUnchangedTest() { |
259 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
260 | var age = new Symbol<>("age", 1, Integer.class, null); | ||
261 | var personView = new KeyOnlyView<>(person); | ||
262 | var adultView = new FilteredView<>(age, "adult", n -> n != null && n >= 18); | 249 | var adultView = new FilteredView<>(age, "adult", n -> n != null && n >= 18); |
263 | 250 | ||
264 | var query = Query.of("TypeConstraint", (builder, p1) -> builder.clause( | 251 | var query = Query.of("TypeConstraint", (builder, p1) -> builder.clause( |
@@ -299,11 +286,6 @@ class QueryTransactionTest { | |||
299 | @Disabled("TODO Fix DiffCursor") | 286 | @Disabled("TODO Fix DiffCursor") |
300 | @Test | 287 | @Test |
301 | void commitAfterFlushTest() { | 288 | void commitAfterFlushTest() { |
302 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
303 | var personView = new KeyOnlyView<>(person); | ||
304 | |||
305 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | ||
306 | |||
307 | var store = ModelStore.builder() | 289 | var store = ModelStore.builder() |
308 | .symbols(person) | 290 | .symbols(person) |
309 | .with(ViatraModelQueryAdapter.builder() | 291 | .with(ViatraModelQueryAdapter.builder() |
@@ -353,11 +335,6 @@ class QueryTransactionTest { | |||
353 | @Disabled("TODO Fix DiffCursor") | 335 | @Disabled("TODO Fix DiffCursor") |
354 | @Test | 336 | @Test |
355 | void commitWithoutFlushTest() { | 337 | void commitWithoutFlushTest() { |
356 | var person = new Symbol<>("Person", 1, Boolean.class, false); | ||
357 | var personView = new KeyOnlyView<>(person); | ||
358 | |||
359 | var predicate = Query.of("TypeConstraint", (builder, p1) -> builder.clause(personView.call(p1))); | ||
360 | |||
361 | var store = ModelStore.builder() | 338 | var store = ModelStore.builder() |
362 | .symbols(person) | 339 | .symbols(person) |
363 | .with(ViatraModelQueryAdapter.builder() | 340 | .with(ViatraModelQueryAdapter.builder() |