diff options
author | 2021-08-16 16:12:16 +0200 | |
---|---|---|
committer | 2021-08-16 16:12:26 +0200 | |
commit | a715d06ca0b13da2a52eb6168473515547aef0ba (patch) | |
tree | 22798b0dd52f9e62dcd8706c0996052678c29df8 /model-data | |
parent | First working test for querying models. (diff) | |
download | refinery-a715d06ca0b13da2a52eb6168473515547aef0ba.tar.gz refinery-a715d06ca0b13da2a52eb6168473515547aef0ba.tar.zst refinery-a715d06ca0b13da2a52eb6168473515547aef0ba.zip |
Build fixes, formatting
Diffstat (limited to 'model-data')
-rw-r--r-- | model-data/build.gradle | 2 | ||||
-rw-r--r-- | model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java | 20 |
2 files changed, 10 insertions, 12 deletions
diff --git a/model-data/build.gradle b/model-data/build.gradle index 2d0aef9a..95336602 100644 --- a/model-data/build.gradle +++ b/model-data/build.gradle | |||
@@ -4,5 +4,5 @@ apply from: "${rootDir}/gradle/jmh.gradle" | |||
4 | 4 | ||
5 | dependencies { | 5 | dependencies { |
6 | compile "org.eclipse.viatra:viatra-query-runtime:${viatraVersion}" | 6 | compile "org.eclipse.viatra:viatra-query-runtime:${viatraVersion}" |
7 | compile "org.eclipse.emf:org.eclipse.emf.ecore:2.24.0" | 7 | compile "org.eclipse.emf:org.eclipse.emf.ecore:${ecoreVersion}" |
8 | } | 8 | } |
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 50fcf3f4..ca73b103 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 | |||
@@ -40,17 +40,16 @@ class QueryTest { | |||
40 | RelationView<Boolean> persionView = new TupleRelationView(model, person); | 40 | RelationView<Boolean> persionView = new TupleRelationView(model, person); |
41 | 41 | ||
42 | RelationalScope scope = new RelationalScope(Set.of(persionView)); | 42 | RelationalScope scope = new RelationalScope(Set.of(persionView)); |
43 | 43 | ||
44 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) | 44 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) |
45 | .addParameter("p",persionView) | 45 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); |
46 | .addConstraint(persionView, "p").build(); | 46 | |
47 | |||
48 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); | 47 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); |
49 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); | 48 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); |
50 | 49 | ||
51 | assertEquals(2, personMatcher.countMatches()); | 50 | assertEquals(2, personMatcher.countMatches()); |
52 | } | 51 | } |
53 | 52 | ||
54 | void modelBuildingTest() { | 53 | void modelBuildingTest() { |
55 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 54 | Relation<Boolean> person = new Relation<>("Person", 1, false); |
56 | Relation<Integer> age = new Relation<Integer>("age", 1, null); | 55 | Relation<Integer> age = new Relation<Integer>("age", 1, null); |
@@ -78,15 +77,14 @@ class QueryTest { | |||
78 | RelationView<TruthValue> friendMayView = new FilteredRelationView<TruthValue>(model, friend, (k, v) -> v.may()); | 77 | RelationView<TruthValue> friendMayView = new FilteredRelationView<TruthValue>(model, friend, (k, v) -> v.may()); |
79 | 78 | ||
80 | RelationalScope scope = new RelationalScope(Set.of(persionView, ageView, friendMustView, friendMayView)); | 79 | RelationalScope scope = new RelationalScope(Set.of(persionView, ageView, friendMustView, friendMayView)); |
81 | 80 | ||
82 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) | 81 | GenericQuerySpecification<GenericPatternMatcher> personQuery = (new RelationalQuery("PersonQuery")) |
83 | .addParameter("p",persionView) | 82 | .addParameter("p", persionView).addConstraint(persionView, "p").build(); |
84 | .addConstraint(persionView, "p").build(); | 83 | |
85 | |||
86 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); | 84 | ViatraQueryEngine engine = AdvancedViatraQueryEngine.on(scope); |
87 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); | 85 | GenericPatternMatcher personMatcher = engine.getMatcher(personQuery); |
88 | Collection<GenericPatternMatch> personMatches = personMatcher.getAllMatches(); | 86 | Collection<GenericPatternMatch> personMatches = personMatcher.getAllMatches(); |
89 | for(GenericPatternMatch personMatch : personMatches) { | 87 | for (GenericPatternMatch personMatch : personMatches) { |
90 | System.out.println(personMatch); | 88 | System.out.println(personMatch); |
91 | } | 89 | } |
92 | } | 90 | } |