diff options
author | 2023-09-19 19:24:29 +0200 | |
---|---|---|
committer | 2023-09-19 19:24:29 +0200 | |
commit | 810b937df6cb1315e0653d763463fd9dc9db9339 (patch) | |
tree | ecbb4d297820fd12460128a057725c7598a3dd38 /subprojects/store-query-interpreter/src/test/java | |
parent | fix(frontend): typo in EditorTheme (diff) | |
download | refinery-810b937df6cb1315e0653d763463fd9dc9db9339.tar.gz refinery-810b937df6cb1315e0653d763463fd9dc9db9339.tar.zst refinery-810b937df6cb1315e0653d763463fd9dc9db9339.zip |
fix(query-interpreter): functional dependencies
Diffstat (limited to 'subprojects/store-query-interpreter/src/test/java')
-rw-r--r-- | subprojects/store-query-interpreter/src/test/java/tools/refinery/store/query/interpreter/FunctionalQueryTest.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/subprojects/store-query-interpreter/src/test/java/tools/refinery/store/query/interpreter/FunctionalQueryTest.java b/subprojects/store-query-interpreter/src/test/java/tools/refinery/store/query/interpreter/FunctionalQueryTest.java index 00721a34..b6c96676 100644 --- a/subprojects/store-query-interpreter/src/test/java/tools/refinery/store/query/interpreter/FunctionalQueryTest.java +++ b/subprojects/store-query-interpreter/src/test/java/tools/refinery/store/query/interpreter/FunctionalQueryTest.java | |||
@@ -510,6 +510,59 @@ class FunctionalQueryTest { | |||
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | @QueryEngineTest | ||
514 | void multipleFunctionalQueriesTest(QueryEvaluationHint hint) { | ||
515 | var subQuery1 = Query.of("SubQuery1", Integer.class, (builder, p1, output) -> builder.clause( | ||
516 | personView.call(p1), | ||
517 | ageView.call(p1, output) | ||
518 | )); | ||
519 | var subQuery2 = Query.of("SubQuery2", Integer.class, (builder, p1, output) -> builder.clause( | ||
520 | personView.call(p1), | ||
521 | output.assign(friendMustView.count(p1, Variable.of())) | ||
522 | )); | ||
523 | var query = Query.of("Query", Integer.class, (builder, p1, output) -> builder | ||
524 | .clause(Integer.class, Integer.class, (v1, v2) -> List.of( | ||
525 | v1.assign(subQuery1.call(p1)), | ||
526 | v2.assign(subQuery2.call(p1)), | ||
527 | output.assign(add(v1, v2)) | ||
528 | ))); | ||
529 | |||
530 | var store = ModelStore.builder() | ||
531 | .symbols(person, age, friend) | ||
532 | .with(QueryInterpreterAdapter.builder() | ||
533 | .defaultHint(hint) | ||
534 | .queries(query)) | ||
535 | .build(); | ||
536 | |||
537 | var model = store.createEmptyModel(); | ||
538 | var personInterpretation = model.getInterpretation(person); | ||
539 | var ageInterpretation = model.getInterpretation(age); | ||
540 | var friendInterpretation = model.getInterpretation(friend); | ||
541 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
542 | var queryResultSet = queryEngine.getResultSet(query); | ||
543 | |||
544 | personInterpretation.put(Tuple.of(0), true); | ||
545 | personInterpretation.put(Tuple.of(1), true); | ||
546 | personInterpretation.put(Tuple.of(2), true); | ||
547 | |||
548 | ageInterpretation.put(Tuple.of(0), 24); | ||
549 | ageInterpretation.put(Tuple.of(1), 30); | ||
550 | ageInterpretation.put(Tuple.of(2), 36); | ||
551 | |||
552 | friendInterpretation.put(Tuple.of(0, 1), TruthValue.TRUE); | ||
553 | friendInterpretation.put(Tuple.of(1, 0), TruthValue.TRUE); | ||
554 | friendInterpretation.put(Tuple.of(1, 2), TruthValue.TRUE); | ||
555 | |||
556 | queryEngine.flushChanges(); | ||
557 | queryEngine.flushChanges(); | ||
558 | assertNullableResults(Map.of( | ||
559 | Tuple.of(0), Optional.of(25), | ||
560 | Tuple.of(1), Optional.of(32), | ||
561 | Tuple.of(2), Optional.of(36), | ||
562 | Tuple.of(3), Optional.empty() | ||
563 | ), queryResultSet); | ||
564 | } | ||
565 | |||
513 | private static void enumerateValues(Cursor<?, ?> cursor) { | 566 | private static void enumerateValues(Cursor<?, ?> cursor) { |
514 | //noinspection StatementWithEmptyBody | 567 | //noinspection StatementWithEmptyBody |
515 | while (cursor.move()) { | 568 | while (cursor.move()) { |