diff options
2 files changed, 39 insertions, 1 deletions
diff --git a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java index 8110a98f..15c4e0e1 100644 --- a/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java +++ b/subprojects/store-query-viatra/src/main/java/tools/refinery/store/query/viatra/internal/pquery/Dnf2PQuery.java | |||
@@ -190,7 +190,7 @@ public class Dnf2PQuery { | |||
190 | 190 | ||
191 | private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) { | 191 | private void translateConstantLiteral(ConstantLiteral constantLiteral, PBody body) { |
192 | var variable = body.getOrCreateVariableByName(constantLiteral.getVariable().getUniqueName()); | 192 | var variable = body.getOrCreateVariableByName(constantLiteral.getVariable().getUniqueName()); |
193 | new ConstantValue(body, variable, constantLiteral.getNodeId()); | 193 | new ConstantValue(body, variable, tools.refinery.store.tuple.Tuple.of(constantLiteral.getNodeId())); |
194 | } | 194 | } |
195 | 195 | ||
196 | private <T> void translateAssignLiteral(AssignLiteral<T> assignLiteral, PBody body) { | 196 | private <T> void translateAssignLiteral(AssignLiteral<T> assignLiteral, PBody body) { |
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 8ecbe11a..8e945731 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 | |||
@@ -110,6 +110,44 @@ class QueryTest { | |||
110 | } | 110 | } |
111 | 111 | ||
112 | @QueryEngineTest | 112 | @QueryEngineTest |
113 | void isConstantTest(QueryEvaluationHint hint) { | ||
114 | var predicate = Query.of("RelationConstraint", (builder, p1, p2) -> builder.clause( | ||
115 | personView.call(p1), | ||
116 | p1.isConstant(1), | ||
117 | friendMustView.call(p1, p2) | ||
118 | )); | ||
119 | |||
120 | var store = ModelStore.builder() | ||
121 | .symbols(person, friend) | ||
122 | .with(ViatraModelQueryAdapter.builder() | ||
123 | .defaultHint(hint) | ||
124 | .queries(predicate)) | ||
125 | .build(); | ||
126 | |||
127 | var model = store.createEmptyModel(); | ||
128 | var personInterpretation = model.getInterpretation(person); | ||
129 | var friendInterpretation = model.getInterpretation(friend); | ||
130 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
131 | var predicateResultSet = queryEngine.getResultSet(predicate); | ||
132 | |||
133 | personInterpretation.put(Tuple.of(0), true); | ||
134 | personInterpretation.put(Tuple.of(1), true); | ||
135 | personInterpretation.put(Tuple.of(2), true); | ||
136 | |||
137 | friendInterpretation.put(Tuple.of(0, 1), TruthValue.TRUE); | ||
138 | friendInterpretation.put(Tuple.of(1, 0), TruthValue.TRUE); | ||
139 | friendInterpretation.put(Tuple.of(1, 2), TruthValue.TRUE); | ||
140 | |||
141 | queryEngine.flushChanges(); | ||
142 | assertResults(Map.of( | ||
143 | Tuple.of(0, 1), false, | ||
144 | Tuple.of(1, 0), true, | ||
145 | Tuple.of(1, 2), true, | ||
146 | Tuple.of(2, 1), false | ||
147 | ), predicateResultSet); | ||
148 | } | ||
149 | |||
150 | @QueryEngineTest | ||
113 | void existTest(QueryEvaluationHint hint) { | 151 | void existTest(QueryEvaluationHint hint) { |
114 | var predicate = Query.of("Exists", (builder, p1) -> builder.clause((p2) -> List.of( | 152 | var predicate = Query.of("Exists", (builder, p1) -> builder.clause((p2) -> List.of( |
115 | personView.call(p1), | 153 | personView.call(p1), |