diff options
author | 2021-08-17 02:41:47 +0200 | |
---|---|---|
committer | 2021-08-17 02:41:47 +0200 | |
commit | 25a077b3c68beb42f40e5a98d5c970435f48cf69 (patch) | |
tree | a0ef62604e0a557212ef9e673355746c98f8cbb9 /model-data | |
parent | organize imports (diff) | |
download | refinery-25a077b3c68beb42f40e5a98d5c970435f48cf69.tar.gz refinery-25a077b3c68beb42f40e5a98d5c970435f48cf69.tar.zst refinery-25a077b3c68beb42f40e5a98d5c970435f48cf69.zip |
changed querytest to highlight query independence from model
Diffstat (limited to 'model-data')
-rw-r--r-- | model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java index 1e0c1d5c..7fa0708f 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java | |||
@@ -31,18 +31,17 @@ class QueryTest { | |||
31 | void minimalTest() { | 31 | void minimalTest() { |
32 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 32 | Relation<Boolean> person = new Relation<>("Person", 1, false); |
33 | 33 | ||
34 | RelationView<Boolean> persionView = new TupleRelationView(person); | ||
35 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) | ||
36 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); | ||
37 | |||
34 | ModelStore store = new ModelStoreImpl(Set.of(person)); | 38 | ModelStore store = new ModelStoreImpl(Set.of(person)); |
35 | Model model = store.createModel(); | 39 | Model model = store.createModel(); |
36 | 40 | ||
37 | model.put(person, Tuple.of(0), true); | 41 | model.put(person, Tuple.of(0), true); |
38 | model.put(person, Tuple.of(1), true); | 42 | model.put(person, Tuple.of(1), true); |
39 | 43 | ||
40 | RelationView<Boolean> persionView = new TupleRelationView(model, person); | 44 | RelationalScope scope = new RelationalScope(model, Set.of(persionView)); |
41 | |||
42 | RelationalScope scope = new RelationalScope(model,Set.of(persionView)); | ||
43 | |||
44 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) | ||
45 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); | ||
46 | 45 | ||
47 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); | 46 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); |
48 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); | 47 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); |
@@ -70,13 +69,12 @@ class QueryTest { | |||
70 | assertTrue(model.get(person, Tuple.of(1))); | 69 | assertTrue(model.get(person, Tuple.of(1))); |
71 | assertFalse(model.get(person, Tuple.of(2))); | 70 | assertFalse(model.get(person, Tuple.of(2))); |
72 | 71 | ||
73 | RelationView<Boolean> persionView = new TupleRelationView(model, person); | 72 | RelationView<Boolean> persionView = new TupleRelationView(person); |
74 | RelationView<Integer> ageView = new FunctionalRelationView<>(model, age); | 73 | RelationView<Integer> ageView = new FunctionalRelationView<>(age); |
75 | RelationView<TruthValue> friendMustView = new FilteredRelationView<TruthValue>(model, friend, | 74 | RelationView<TruthValue> friendMustView = new FilteredRelationView<TruthValue>(friend, (k, v) -> v.must()); |
76 | (k, v) -> v.must()); | 75 | RelationView<TruthValue> friendMayView = new FilteredRelationView<TruthValue>(friend, (k, v) -> v.may()); |
77 | RelationView<TruthValue> friendMayView = new FilteredRelationView<TruthValue>(model, friend, (k, v) -> v.may()); | ||
78 | 76 | ||
79 | RelationalScope scope = new RelationalScope(model,Set.of(persionView, ageView, friendMustView, friendMayView)); | 77 | RelationalScope scope = new RelationalScope(model, Set.of(persionView, ageView, friendMustView, friendMayView)); |
80 | 78 | ||
81 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) | 79 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) |
82 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); | 80 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); |