diff options
author | Kristóf Marussy <kristof@marussy.com> | 2023-08-20 19:41:32 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2023-08-20 20:29:02 +0200 |
commit | a3f1e6872f4f768d14899a1e70bbdc14f32e478d (patch) | |
tree | b2daf0c81724f31ee190f5d63eb42988086dabf2 /subprojects/store-query/src/test/java/tools | |
parent | fix: nullary model initialization (diff) | |
download | refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.tar.gz refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.tar.zst refinery-a3f1e6872f4f768d14899a1e70bbdc14f32e478d.zip |
feat: improve semantics error reporting
Also makes model seeds cancellable to reduce server load during semantic
analysis.
Diffstat (limited to 'subprojects/store-query/src/test/java/tools')
4 files changed, 18 insertions, 16 deletions
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java index d75d7f17..12cfaa4e 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java | |||
@@ -50,7 +50,7 @@ class DnfToDefinitionStringTest { | |||
50 | var dnf = Dnf.builder("Example").parameter(p, ParameterDirection.IN).clause().build(); | 50 | var dnf = Dnf.builder("Example").parameter(p, ParameterDirection.IN).clause().build(); |
51 | 51 | ||
52 | assertThat(dnf.toDefinitionString(), is(""" | 52 | assertThat(dnf.toDefinitionString(), is(""" |
53 | pred Example(@In p) <-> | 53 | pred Example(in p) <-> |
54 | <empty>. | 54 | <empty>. |
55 | """)); | 55 | """)); |
56 | } | 56 | } |
@@ -73,7 +73,7 @@ class DnfToDefinitionStringTest { | |||
73 | .build(); | 73 | .build(); |
74 | 74 | ||
75 | assertThat(dnf.toDefinitionString(), is(""" | 75 | assertThat(dnf.toDefinitionString(), is(""" |
76 | pred Example(@In p) <-> | 76 | pred Example(in p) <-> |
77 | !(@RelationView("key") friend(p, q)). | 77 | !(@RelationView("key") friend(p, q)). |
78 | """)); | 78 | """)); |
79 | } | 79 | } |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/TopologicalSortTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/TopologicalSortTest.java index e22dbb21..854bd469 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/TopologicalSortTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/TopologicalSortTest.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.query.dnf; | 6 | package tools.refinery.store.query.dnf; |
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.query.InvalidQueryException; | ||
9 | import tools.refinery.store.query.term.NodeVariable; | 10 | import tools.refinery.store.query.term.NodeVariable; |
10 | import tools.refinery.store.query.term.ParameterDirection; | 11 | import tools.refinery.store.query.term.ParameterDirection; |
11 | import tools.refinery.store.query.term.Variable; | 12 | import tools.refinery.store.query.term.Variable; |
@@ -80,7 +81,7 @@ class TopologicalSortTest { | |||
80 | example.call(r, t, q, s), | 81 | example.call(r, t, q, s), |
81 | friendView.call(r, t) | 82 | friendView.call(r, t) |
82 | ); | 83 | ); |
83 | assertThrows(IllegalArgumentException.class, builder::build); | 84 | assertThrows(InvalidQueryException.class, builder::build); |
84 | } | 85 | } |
85 | 86 | ||
86 | @Test | 87 | @Test |
@@ -93,7 +94,7 @@ class TopologicalSortTest { | |||
93 | example.call(p, q, r, s), | 94 | example.call(p, q, r, s), |
94 | example.call(r, t, q, s) | 95 | example.call(r, t, q, s) |
95 | ); | 96 | ); |
96 | assertThrows(IllegalArgumentException.class, builder::build); | 97 | assertThrows(InvalidQueryException.class, builder::build); |
97 | } | 98 | } |
98 | 99 | ||
99 | @Test | 100 | @Test |
@@ -107,6 +108,6 @@ class TopologicalSortTest { | |||
107 | example.call(r, t, q, s), | 108 | example.call(r, t, q, s), |
108 | example.call(p, q, r, t) | 109 | example.call(p, q, r, t) |
109 | ); | 110 | ); |
110 | assertThrows(IllegalArgumentException.class, builder::build); | 111 | assertThrows(InvalidQueryException.class, builder::build); |
111 | } | 112 | } |
112 | } | 113 | } |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/VariableDirectionTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/VariableDirectionTest.java index bfeaa447..fc3f5d48 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/VariableDirectionTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/VariableDirectionTest.java | |||
@@ -48,7 +48,7 @@ class VariableDirectionTest { | |||
48 | @MethodSource("clausesWithVariableInput") | 48 | @MethodSource("clausesWithVariableInput") |
49 | void unboundOutVariableTest(List<? extends Literal> clause) { | 49 | void unboundOutVariableTest(List<? extends Literal> clause) { |
50 | var builder = Dnf.builder().parameter(p, ParameterDirection.OUT).clause(clause); | 50 | var builder = Dnf.builder().parameter(p, ParameterDirection.OUT).clause(clause); |
51 | assertThrows(IllegalArgumentException.class, builder::build); | 51 | assertThrows(InvalidClauseException.class, builder::build); |
52 | } | 52 | } |
53 | 53 | ||
54 | @ParameterizedTest | 54 | @ParameterizedTest |
@@ -100,7 +100,7 @@ class VariableDirectionTest { | |||
100 | var clauseWithEquivalence = new ArrayList<Literal>(clause); | 100 | var clauseWithEquivalence = new ArrayList<Literal>(clause); |
101 | clauseWithEquivalence.add(r.isEquivalent(p)); | 101 | clauseWithEquivalence.add(r.isEquivalent(p)); |
102 | var builder = Dnf.builder().clause(clauseWithEquivalence); | 102 | var builder = Dnf.builder().clause(clauseWithEquivalence); |
103 | assertThrows(IllegalArgumentException.class, builder::build); | 103 | assertThrows(InvalidClauseException.class, builder::build); |
104 | } | 104 | } |
105 | 105 | ||
106 | static Stream<Arguments> clausesNotBindingVariable() { | 106 | static Stream<Arguments> clausesNotBindingVariable() { |
@@ -118,7 +118,7 @@ class VariableDirectionTest { | |||
118 | @MethodSource("literalsWithPrivateVariable") | 118 | @MethodSource("literalsWithPrivateVariable") |
119 | void unboundTwicePrivateVariableTest(Literal literal) { | 119 | void unboundTwicePrivateVariableTest(Literal literal) { |
120 | var builder = Dnf.builder().clause(not(personView.call(p)), literal); | 120 | var builder = Dnf.builder().clause(not(personView.call(p)), literal); |
121 | assertThrows(IllegalArgumentException.class, builder::build); | 121 | assertThrows(InvalidClauseException.class, builder::build); |
122 | } | 122 | } |
123 | 123 | ||
124 | @ParameterizedTest | 124 | @ParameterizedTest |
@@ -126,7 +126,7 @@ class VariableDirectionTest { | |||
126 | void unboundTwiceByEquivalencePrivateVariableTest(Literal literal) { | 126 | void unboundTwiceByEquivalencePrivateVariableTest(Literal literal) { |
127 | var r = Variable.of("r"); | 127 | var r = Variable.of("r"); |
128 | var builder = Dnf.builder().clause(not(personView.call(r)), r.isEquivalent(p), literal); | 128 | var builder = Dnf.builder().clause(not(personView.call(r)), r.isEquivalent(p), literal); |
129 | assertThrows(IllegalArgumentException.class, builder::build); | 129 | assertThrows(InvalidClauseException.class, builder::build); |
130 | } | 130 | } |
131 | 131 | ||
132 | static Stream<Arguments> literalsWithPrivateVariable() { | 132 | static Stream<Arguments> literalsWithPrivateVariable() { |
@@ -159,7 +159,7 @@ class VariableDirectionTest { | |||
159 | @MethodSource("literalsWithRequiredVariableInput") | 159 | @MethodSource("literalsWithRequiredVariableInput") |
160 | void unboundPrivateVariableTest(Literal literal) { | 160 | void unboundPrivateVariableTest(Literal literal) { |
161 | var builder = Dnf.builder().clause(literal); | 161 | var builder = Dnf.builder().clause(literal); |
162 | assertThrows(IllegalArgumentException.class, builder::build); | 162 | assertThrows(InvalidClauseException.class, builder::build); |
163 | } | 163 | } |
164 | 164 | ||
165 | @ParameterizedTest | 165 | @ParameterizedTest |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/literal/AggregationLiteralTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/literal/AggregationLiteralTest.java index 35910e08..ddd57e96 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/literal/AggregationLiteralTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/literal/AggregationLiteralTest.java | |||
@@ -7,15 +7,16 @@ package tools.refinery.store.query.literal; | |||
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.query.Constraint; | 9 | import tools.refinery.store.query.Constraint; |
10 | import tools.refinery.store.query.InvalidQueryException; | ||
10 | import tools.refinery.store.query.dnf.Dnf; | 11 | import tools.refinery.store.query.dnf.Dnf; |
12 | import tools.refinery.store.query.dnf.InvalidClauseException; | ||
11 | import tools.refinery.store.query.term.*; | 13 | import tools.refinery.store.query.term.*; |
12 | 14 | ||
13 | import java.util.List; | 15 | import java.util.List; |
14 | import java.util.Set; | 16 | import java.util.Set; |
15 | 17 | ||
16 | import static org.hamcrest.MatcherAssert.assertThat; | 18 | import static org.hamcrest.MatcherAssert.assertThat; |
17 | import static org.hamcrest.Matchers.containsInAnyOrder; | 19 | import static org.hamcrest.Matchers.*; |
18 | import static org.hamcrest.Matchers.empty; | ||
19 | import static org.junit.jupiter.api.Assertions.assertAll; | 20 | import static org.junit.jupiter.api.Assertions.assertAll; |
20 | import static org.junit.jupiter.api.Assertions.assertThrows; | 21 | import static org.junit.jupiter.api.Assertions.assertThrows; |
21 | import static tools.refinery.store.query.literal.Literals.not; | 22 | import static tools.refinery.store.query.literal.Literals.not; |
@@ -57,13 +58,13 @@ class AggregationLiteralTest { | |||
57 | @Test | 58 | @Test |
58 | void missingAggregationVariableTest() { | 59 | void missingAggregationVariableTest() { |
59 | var aggregation = fakeConstraint.aggregateBy(y, INT_SUM, p, z); | 60 | var aggregation = fakeConstraint.aggregateBy(y, INT_SUM, p, z); |
60 | assertThrows(IllegalArgumentException.class, () -> x.assign(aggregation)); | 61 | assertThrows(InvalidQueryException.class, () -> x.assign(aggregation)); |
61 | } | 62 | } |
62 | 63 | ||
63 | @Test | 64 | @Test |
64 | void circularAggregationVariableTest() { | 65 | void circularAggregationVariableTest() { |
65 | var aggregation = fakeConstraint.aggregateBy(x, INT_SUM, p, x); | 66 | var aggregation = fakeConstraint.aggregateBy(x, INT_SUM, p, x); |
66 | assertThrows(IllegalArgumentException.class, () -> x.assign(aggregation)); | 67 | assertThrows(InvalidQueryException.class, () -> x.assign(aggregation)); |
67 | } | 68 | } |
68 | 69 | ||
69 | @Test | 70 | @Test |
@@ -73,7 +74,7 @@ class AggregationLiteralTest { | |||
73 | not(fakeConstraint.call(p, y)), | 74 | not(fakeConstraint.call(p, y)), |
74 | x.assign(fakeConstraint.aggregateBy(y, INT_SUM, p, y)) | 75 | x.assign(fakeConstraint.aggregateBy(y, INT_SUM, p, y)) |
75 | ); | 76 | ); |
76 | assertThrows(IllegalArgumentException.class, builder::build); | 77 | assertThrows(InvalidClauseException.class, builder::build); |
77 | } | 78 | } |
78 | 79 | ||
79 | @Test | 80 | @Test |
@@ -83,6 +84,6 @@ class AggregationLiteralTest { | |||
83 | y.assign(constant(27)), | 84 | y.assign(constant(27)), |
84 | x.assign(fakeConstraint.aggregateBy(y, INT_SUM, p, y)) | 85 | x.assign(fakeConstraint.aggregateBy(y, INT_SUM, p, y)) |
85 | ); | 86 | ); |
86 | assertThrows(IllegalArgumentException.class, builder::build); | 87 | assertThrows(InvalidClauseException.class, builder::build); |
87 | } | 88 | } |
88 | } | 89 | } |