aboutsummaryrefslogtreecommitdiffstats
path: root/model-data/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-16 16:12:16 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-08-16 16:12:26 +0200
commita715d06ca0b13da2a52eb6168473515547aef0ba (patch)
tree22798b0dd52f9e62dcd8706c0996052678c29df8 /model-data/src
parentFirst working test for querying models. (diff)
downloadrefinery-a715d06ca0b13da2a52eb6168473515547aef0ba.tar.gz
refinery-a715d06ca0b13da2a52eb6168473515547aef0ba.tar.zst
refinery-a715d06ca0b13da2a52eb6168473515547aef0ba.zip
Build fixes, formatting
Diffstat (limited to 'model-data/src')
-rw-r--r--model-data/src/test/java/org/eclipse/viatra/solver/data/query/test/QueryTest.java20
1 files changed, 9 insertions, 11 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 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 }