diff options
author | 2023-08-20 19:41:32 +0200 | |
---|---|---|
committer | 2023-08-20 20:29:02 +0200 | |
commit | a3f1e6872f4f768d14899a1e70bbdc14f32e478d (patch) | |
tree | b2daf0c81724f31ee190f5d63eb42988086dabf2 /subprojects/store-reasoning | |
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-reasoning')
16 files changed, 123 insertions, 51 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalConstraint.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalConstraint.java index 6e0e91e1..2235a95d 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalConstraint.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/ModalConstraint.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.literal; | 6 | package tools.refinery.store.reasoning.literal; |
7 | 7 | ||
8 | import tools.refinery.store.query.Constraint; | 8 | import tools.refinery.store.query.Constraint; |
9 | import tools.refinery.store.query.InvalidQueryException; | ||
9 | import tools.refinery.store.query.equality.LiteralEqualityHelper; | 10 | import tools.refinery.store.query.equality.LiteralEqualityHelper; |
10 | import tools.refinery.store.query.literal.Reduction; | 11 | import tools.refinery.store.query.literal.Reduction; |
11 | import tools.refinery.store.query.term.Parameter; | 12 | import tools.refinery.store.query.term.Parameter; |
@@ -17,7 +18,7 @@ public record ModalConstraint(Modality modality, Concreteness concreteness, Cons | |||
17 | implements Constraint { | 18 | implements Constraint { |
18 | public ModalConstraint { | 19 | public ModalConstraint { |
19 | if (constraint instanceof AnySymbolView || constraint instanceof ModalConstraint) { | 20 | if (constraint instanceof AnySymbolView || constraint instanceof ModalConstraint) { |
20 | throw new IllegalArgumentException("Already concrete constraints cannot be abstracted"); | 21 | throw new InvalidQueryException("Already concrete constraints cannot be abstracted"); |
21 | } | 22 | } |
22 | } | 23 | } |
23 | 24 | ||
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/PartialLiterals.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/PartialLiterals.java index 2c879397..2614c26e 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/PartialLiterals.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/literal/PartialLiterals.java | |||
@@ -5,6 +5,7 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.reasoning.literal; | 6 | package tools.refinery.store.reasoning.literal; |
7 | 7 | ||
8 | import tools.refinery.store.query.InvalidQueryException; | ||
8 | import tools.refinery.store.query.literal.CallLiteral; | 9 | import tools.refinery.store.query.literal.CallLiteral; |
9 | 10 | ||
10 | public final class PartialLiterals { | 11 | public final class PartialLiterals { |
@@ -31,7 +32,7 @@ public final class PartialLiterals { | |||
31 | public static CallLiteral addModality(CallLiteral literal, Modality modality, Concreteness concreteness) { | 32 | public static CallLiteral addModality(CallLiteral literal, Modality modality, Concreteness concreteness) { |
32 | var target = literal.getTarget(); | 33 | var target = literal.getTarget(); |
33 | if (target instanceof ModalConstraint) { | 34 | if (target instanceof ModalConstraint) { |
34 | throw new IllegalArgumentException("Literal %s already has modality".formatted(literal)); | 35 | throw new InvalidQueryException("Literal %s already has modality".formatted(literal)); |
35 | } | 36 | } |
36 | var polarity = literal.getPolarity(); | 37 | var polarity = literal.getPolarity(); |
37 | var modalTarget = new ModalConstraint(modality.commute(polarity), concreteness, target); | 38 | var modalTarget = new ModalConstraint(modality.commute(polarity), concreteness, target); |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/seed/ModelSeed.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/seed/ModelSeed.java index 28e6258e..e6b3eaf9 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/seed/ModelSeed.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/seed/ModelSeed.java | |||
@@ -13,6 +13,7 @@ import tools.refinery.store.tuple.Tuple; | |||
13 | import java.util.Collections; | 13 | import java.util.Collections; |
14 | import java.util.LinkedHashMap; | 14 | import java.util.LinkedHashMap; |
15 | import java.util.Map; | 15 | import java.util.Map; |
16 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | 17 | import java.util.function.Consumer; |
17 | 18 | ||
18 | public class ModelSeed { | 19 | public class ModelSeed { |
@@ -43,6 +44,10 @@ public class ModelSeed { | |||
43 | return seeds.containsKey(symbol); | 44 | return seeds.containsKey(symbol); |
44 | } | 45 | } |
45 | 46 | ||
47 | public Set<AnyPartialSymbol> getSeededSymbols() { | ||
48 | return Collections.unmodifiableSet(seeds.keySet()); | ||
49 | } | ||
50 | |||
46 | public <A> Cursor<Tuple, A> getCursor(PartialSymbol<A, ?> partialSymbol, A defaultValue) { | 51 | public <A> Cursor<Tuple, A> getCursor(PartialSymbol<A, ?> partialSymbol, A defaultValue) { |
47 | return getSeed(partialSymbol).getCursor(defaultValue, nodeCount); | 52 | return getSeed(partialSymbol).getCursor(defaultValue, nodeCount); |
48 | } | 53 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/TranslationException.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/TranslationException.java new file mode 100644 index 00000000..edb886ba --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/TranslationException.java | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.reasoning.translator; | ||
7 | |||
8 | import tools.refinery.store.reasoning.representation.AnyPartialSymbol; | ||
9 | |||
10 | public class TranslationException extends RuntimeException { | ||
11 | private final transient AnyPartialSymbol partialSymbol; | ||
12 | |||
13 | public TranslationException(AnyPartialSymbol partialSymbol) { | ||
14 | this.partialSymbol = partialSymbol; | ||
15 | } | ||
16 | |||
17 | public TranslationException(AnyPartialSymbol partialSymbol, String message) { | ||
18 | super(message); | ||
19 | this.partialSymbol = partialSymbol; | ||
20 | } | ||
21 | |||
22 | public TranslationException(AnyPartialSymbol partialSymbol, String message, Throwable cause) { | ||
23 | super(message, cause); | ||
24 | this.partialSymbol = partialSymbol; | ||
25 | } | ||
26 | |||
27 | public TranslationException(AnyPartialSymbol partialSymbol, Throwable cause) { | ||
28 | super(cause); | ||
29 | this.partialSymbol = partialSymbol; | ||
30 | } | ||
31 | |||
32 | public AnyPartialSymbol getPartialSymbol() { | ||
33 | return partialSymbol; | ||
34 | } | ||
35 | } | ||
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/containment/ContainmentInfo.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/containment/ContainmentInfo.java index 1087e54d..e3457fa7 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/containment/ContainmentInfo.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/containment/ContainmentInfo.java | |||
@@ -6,17 +6,18 @@ | |||
6 | package tools.refinery.store.reasoning.translator.containment; | 6 | package tools.refinery.store.reasoning.translator.containment; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | import tools.refinery.store.reasoning.translator.multiplicity.Multiplicity; | 10 | import tools.refinery.store.reasoning.translator.multiplicity.Multiplicity; |
10 | 11 | ||
11 | public record ContainmentInfo(PartialRelation sourceType, Multiplicity multiplicity, | 12 | public record ContainmentInfo(PartialRelation sourceType, Multiplicity multiplicity, |
12 | PartialRelation targetType) { | 13 | PartialRelation targetType) { |
13 | public ContainmentInfo { | 14 | public ContainmentInfo { |
14 | if (sourceType.arity() != 1) { | 15 | if (sourceType.arity() != 1) { |
15 | throw new IllegalArgumentException("Expected source type %s to be of arity 1, got %d instead" | 16 | throw new TranslationException(sourceType, "Expected source type %s to be of arity 1, got %d instead" |
16 | .formatted(sourceType, sourceType.arity())); | 17 | .formatted(sourceType, sourceType.arity())); |
17 | } | 18 | } |
18 | if (targetType.arity() != 1) { | 19 | if (targetType.arity() != 1) { |
19 | throw new IllegalArgumentException("Expected target type %s to be of arity 1, got %d instead" | 20 | throw new TranslationException(targetType, "Expected target type %s to be of arity 1, got %d instead" |
20 | .formatted(targetType, targetType.arity())); | 21 | .formatted(targetType, targetType.arity())); |
21 | } | 22 | } |
22 | } | 23 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/ContainedTypeHierarchyBuilder.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/ContainedTypeHierarchyBuilder.java index cc43bce6..a21da3d4 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/ContainedTypeHierarchyBuilder.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/ContainedTypeHierarchyBuilder.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.translator.metamodel; | 6 | package tools.refinery.store.reasoning.translator.metamodel; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | import tools.refinery.store.reasoning.translator.containment.ContainmentHierarchyTranslator; | 10 | import tools.refinery.store.reasoning.translator.containment.ContainmentHierarchyTranslator; |
10 | import tools.refinery.store.reasoning.translator.typehierarchy.TypeHierarchyBuilder; | 11 | import tools.refinery.store.reasoning.translator.typehierarchy.TypeHierarchyBuilder; |
11 | 12 | ||
@@ -23,7 +24,7 @@ public class ContainedTypeHierarchyBuilder extends TypeHierarchyBuilder { | |||
23 | for (var containedType : containedTypes) { | 24 | for (var containedType : containedTypes) { |
24 | var currentInfo = typeInfoMap.get(containedType); | 25 | var currentInfo = typeInfoMap.get(containedType); |
25 | if (currentInfo == null) { | 26 | if (currentInfo == null) { |
26 | throw new IllegalArgumentException("Invalid contained type: " + containedType); | 27 | throw new TranslationException(containedType, "Invalid contained type: " + containedType); |
27 | } | 28 | } |
28 | var newInfo = currentInfo.addSupertype(ContainmentHierarchyTranslator.CONTAINED_SYMBOL); | 29 | var newInfo = currentInfo.addSupertype(ContainmentHierarchyTranslator.CONTAINED_SYMBOL); |
29 | typeInfoMap.put(containedType, newInfo); | 30 | typeInfoMap.put(containedType, newInfo); |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilder.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilder.java index d0732edc..ad0288ed 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilder.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilder.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.translator.metamodel; | 6 | package tools.refinery.store.reasoning.translator.metamodel; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | import tools.refinery.store.reasoning.translator.containment.ContainmentHierarchyTranslator; | 10 | import tools.refinery.store.reasoning.translator.containment.ContainmentHierarchyTranslator; |
10 | import tools.refinery.store.reasoning.translator.containment.ContainmentInfo; | 11 | import tools.refinery.store.reasoning.translator.containment.ContainmentInfo; |
11 | import tools.refinery.store.reasoning.translator.crossreference.DirectedCrossReferenceInfo; | 12 | import tools.refinery.store.reasoning.translator.crossreference.DirectedCrossReferenceInfo; |
@@ -13,7 +14,6 @@ import tools.refinery.store.reasoning.translator.crossreference.UndirectedCrossR | |||
13 | import tools.refinery.store.reasoning.translator.multiplicity.Multiplicity; | 14 | import tools.refinery.store.reasoning.translator.multiplicity.Multiplicity; |
14 | import tools.refinery.store.reasoning.translator.multiplicity.UnconstrainedMultiplicity; | 15 | import tools.refinery.store.reasoning.translator.multiplicity.UnconstrainedMultiplicity; |
15 | import tools.refinery.store.reasoning.translator.typehierarchy.TypeInfo; | 16 | import tools.refinery.store.reasoning.translator.typehierarchy.TypeInfo; |
16 | import tools.refinery.store.representation.cardinality.CardinalityIntervals; | ||
17 | 17 | ||
18 | import java.util.*; | 18 | import java.util.*; |
19 | 19 | ||
@@ -70,12 +70,13 @@ public class MetamodelBuilder { | |||
70 | 70 | ||
71 | public MetamodelBuilder reference(PartialRelation linkType, ReferenceInfo info) { | 71 | public MetamodelBuilder reference(PartialRelation linkType, ReferenceInfo info) { |
72 | if (linkType.arity() != 2) { | 72 | if (linkType.arity() != 2) { |
73 | throw new IllegalArgumentException("Only references of arity 2 are supported, got %s with %d instead" | 73 | throw new TranslationException(linkType, |
74 | .formatted(linkType, linkType.arity())); | 74 | "Only references of arity 2 are supported, got %s with %d instead".formatted( |
75 | linkType, linkType.arity())); | ||
75 | } | 76 | } |
76 | var putResult = referenceInfoMap.put(linkType, info); | 77 | var putResult = referenceInfoMap.put(linkType, info); |
77 | if (putResult != null && !putResult.equals(info)) { | 78 | if (putResult != null && !putResult.equals(info)) { |
78 | throw new IllegalArgumentException("Duplicate reference info for partial relation: " + linkType); | 79 | throw new TranslationException(linkType, "Duplicate reference info for partial relation: " + linkType); |
79 | } | 80 | } |
80 | return this; | 81 | return this; |
81 | } | 82 | } |
@@ -154,11 +155,11 @@ public class MetamodelBuilder { | |||
154 | var sourceType = info.sourceType(); | 155 | var sourceType = info.sourceType(); |
155 | var targetType = info.targetType(); | 156 | var targetType = info.targetType(); |
156 | if (typeHierarchyBuilder.isInvalidType(sourceType)) { | 157 | if (typeHierarchyBuilder.isInvalidType(sourceType)) { |
157 | throw new IllegalArgumentException("Source type %s of %s is not in type hierarchy" | 158 | throw new TranslationException(linkType, "Source type %s of %s is not in type hierarchy" |
158 | .formatted(sourceType, linkType)); | 159 | .formatted(sourceType, linkType)); |
159 | } | 160 | } |
160 | if (typeHierarchyBuilder.isInvalidType(targetType)) { | 161 | if (typeHierarchyBuilder.isInvalidType(targetType)) { |
161 | throw new IllegalArgumentException("Target type %s of %s is not in type hierarchy" | 162 | throw new TranslationException(linkType, "Target type %s of %s is not in type hierarchy" |
162 | .formatted(targetType, linkType)); | 163 | .formatted(targetType, linkType)); |
163 | } | 164 | } |
164 | var opposite = info.opposite(); | 165 | var opposite = info.opposite(); |
@@ -173,8 +174,9 @@ public class MetamodelBuilder { | |||
173 | } | 174 | } |
174 | if (opposite.equals(linkType)) { | 175 | if (opposite.equals(linkType)) { |
175 | if (!sourceType.equals(targetType)) { | 176 | if (!sourceType.equals(targetType)) { |
176 | throw new IllegalArgumentException("Target %s of undirected reference %s differs from source %s" | 177 | throw new TranslationException(linkType, |
177 | .formatted(targetType, linkType, sourceType)); | 178 | "Target %s of undirected reference %s differs from source %s".formatted( |
179 | targetType, linkType, sourceType)); | ||
178 | } | 180 | } |
179 | undirectedCrossReferences.put(linkType, new UndirectedCrossReferenceInfo(sourceType, | 181 | undirectedCrossReferences.put(linkType, new UndirectedCrossReferenceInfo(sourceType, |
180 | info.multiplicity())); | 182 | info.multiplicity())); |
@@ -183,8 +185,8 @@ public class MetamodelBuilder { | |||
183 | oppositeReferences.put(opposite, linkType); | 185 | oppositeReferences.put(opposite, linkType); |
184 | } | 186 | } |
185 | if (info.containment()) { | 187 | if (info.containment()) { |
186 | if (targetMultiplicity.multiplicity().meet(CardinalityIntervals.ONE).isEmpty()) { | 188 | if (!UnconstrainedMultiplicity.INSTANCE.equals(targetMultiplicity)) { |
187 | throw new IllegalArgumentException("Invalid opposite %s with multiplicity %s of containment %s" | 189 | throw new TranslationException(opposite, "Invalid opposite %s with multiplicity %s of containment %s" |
188 | .formatted(opposite, targetMultiplicity, linkType)); | 190 | .formatted(opposite, targetMultiplicity, linkType)); |
189 | } | 191 | } |
190 | containedTypes.add(targetType); | 192 | containedTypes.add(targetType); |
@@ -200,23 +202,23 @@ public class MetamodelBuilder { | |||
200 | var sourceType = info.sourceType(); | 202 | var sourceType = info.sourceType(); |
201 | var targetType = info.targetType(); | 203 | var targetType = info.targetType(); |
202 | if (oppositeInfo == null) { | 204 | if (oppositeInfo == null) { |
203 | throw new IllegalArgumentException("Opposite %s of %s is not defined" | 205 | throw new TranslationException(linkType, "Opposite %s of %s is not defined" |
204 | .formatted(opposite, linkType)); | 206 | .formatted(opposite, linkType)); |
205 | } | 207 | } |
206 | if (!linkType.equals(oppositeInfo.opposite())) { | 208 | if (!linkType.equals(oppositeInfo.opposite())) { |
207 | throw new IllegalArgumentException("Expected %s to have opposite %s, got %s instead" | 209 | throw new TranslationException(opposite, "Expected %s to have opposite %s, got %s instead" |
208 | .formatted(opposite, linkType, oppositeInfo.opposite())); | 210 | .formatted(opposite, linkType, oppositeInfo.opposite())); |
209 | } | 211 | } |
210 | if (!targetType.equals(oppositeInfo.sourceType())) { | 212 | if (!targetType.equals(oppositeInfo.sourceType())) { |
211 | throw new IllegalArgumentException("Expected %s to have source type %s, got %s instead" | 213 | throw new TranslationException(linkType, "Expected %s to have source type %s, got %s instead" |
212 | .formatted(opposite, targetType, oppositeInfo.sourceType())); | 214 | .formatted(opposite, targetType, oppositeInfo.sourceType())); |
213 | } | 215 | } |
214 | if (!sourceType.equals(oppositeInfo.targetType())) { | 216 | if (!sourceType.equals(oppositeInfo.targetType())) { |
215 | throw new IllegalArgumentException("Expected %s to have target type %s, got %s instead" | 217 | throw new TranslationException(linkType, "Expected %s to have target type %s, got %s instead" |
216 | .formatted(opposite, sourceType, oppositeInfo.targetType())); | 218 | .formatted(opposite, sourceType, oppositeInfo.targetType())); |
217 | } | 219 | } |
218 | if (oppositeInfo.containment() && info.containment()) { | 220 | if (oppositeInfo.containment() && info.containment()) { |
219 | throw new IllegalArgumentException("Opposite %s of containment %s cannot be containment" | 221 | throw new TranslationException(opposite, "Opposite %s of containment %s cannot be containment" |
220 | .formatted(opposite, linkType)); | 222 | .formatted(opposite, linkType)); |
221 | } | 223 | } |
222 | } | 224 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiobject/MultiObjectInitializer.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiobject/MultiObjectInitializer.java index fb84631d..f11ab46b 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiobject/MultiObjectInitializer.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiobject/MultiObjectInitializer.java | |||
@@ -10,6 +10,7 @@ import tools.refinery.store.model.Model; | |||
10 | import tools.refinery.store.reasoning.ReasoningAdapter; | 10 | import tools.refinery.store.reasoning.ReasoningAdapter; |
11 | import tools.refinery.store.reasoning.refinement.PartialModelInitializer; | 11 | import tools.refinery.store.reasoning.refinement.PartialModelInitializer; |
12 | import tools.refinery.store.reasoning.seed.ModelSeed; | 12 | import tools.refinery.store.reasoning.seed.ModelSeed; |
13 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
13 | import tools.refinery.store.representation.Symbol; | 14 | import tools.refinery.store.representation.Symbol; |
14 | import tools.refinery.store.representation.TruthValue; | 15 | import tools.refinery.store.representation.TruthValue; |
15 | import tools.refinery.store.representation.cardinality.CardinalityInterval; | 16 | import tools.refinery.store.representation.cardinality.CardinalityInterval; |
@@ -37,7 +38,8 @@ class MultiObjectInitializer implements PartialModelInitializer { | |||
37 | for (int i = 0; i < intervals.length; i++) { | 38 | for (int i = 0; i < intervals.length; i++) { |
38 | var interval = intervals[i]; | 39 | var interval = intervals[i]; |
39 | if (interval.isEmpty()) { | 40 | if (interval.isEmpty()) { |
40 | throw new IllegalArgumentException("Inconsistent existence or equality for node " + i); | 41 | throw new TranslationException(ReasoningAdapter.EXISTS_SYMBOL, |
42 | "Inconsistent existence or equality for node " + i); | ||
41 | } | 43 | } |
42 | var uniqueInterval = uniqueTable.computeIfAbsent(intervals[i], Function.identity()); | 44 | var uniqueInterval = uniqueTable.computeIfAbsent(intervals[i], Function.identity()); |
43 | countInterpretation.put(Tuple.of(i), uniqueInterval); | 45 | countInterpretation.put(Tuple.of(i), uniqueInterval); |
@@ -58,9 +60,10 @@ class MultiObjectInitializer implements PartialModelInitializer { | |||
58 | } else { | 60 | } else { |
59 | Arrays.fill(intervals, CardinalityIntervals.SET); | 61 | Arrays.fill(intervals, CardinalityIntervals.SET); |
60 | if (!modelSeed.containsSeed(ReasoningAdapter.EXISTS_SYMBOL) || | 62 | if (!modelSeed.containsSeed(ReasoningAdapter.EXISTS_SYMBOL) || |
61 | !modelSeed.containsSeed(ReasoningAdapter.EQUALS_SYMBOL)) { | 63 | !modelSeed.containsSeed(ReasoningAdapter.EQUALS_SYMBOL)) { |
62 | throw new IllegalArgumentException("Seed for %s and %s is required if there is no seed for %s" | 64 | throw new TranslationException(MultiObjectTranslator.COUNT_SYMBOL, |
63 | .formatted(ReasoningAdapter.EXISTS_SYMBOL, ReasoningAdapter.EQUALS_SYMBOL, | 65 | "Seed for %s and %s is required if there is no seed for %s".formatted( |
66 | ReasoningAdapter.EXISTS_SYMBOL, ReasoningAdapter.EQUALS_SYMBOL, | ||
64 | MultiObjectTranslator.COUNT_SYMBOL)); | 67 | MultiObjectTranslator.COUNT_SYMBOL)); |
65 | } | 68 | } |
66 | } | 69 | } |
@@ -78,9 +81,10 @@ class MultiObjectInitializer implements PartialModelInitializer { | |||
78 | switch (cursor.getValue()) { | 81 | switch (cursor.getValue()) { |
79 | case TRUE -> intervals[i] = intervals[i].meet(CardinalityIntervals.SOME); | 82 | case TRUE -> intervals[i] = intervals[i].meet(CardinalityIntervals.SOME); |
80 | case FALSE -> intervals[i] = intervals[i].meet(CardinalityIntervals.NONE); | 83 | case FALSE -> intervals[i] = intervals[i].meet(CardinalityIntervals.NONE); |
81 | case ERROR -> throw new IllegalArgumentException("Inconsistent existence for node " + i); | 84 | case ERROR -> throw new TranslationException(ReasoningAdapter.EXISTS_SYMBOL, |
82 | default -> throw new IllegalArgumentException("Invalid existence truth value %s for node %d" | 85 | "Inconsistent existence for node " + i); |
83 | .formatted(cursor.getValue(), i)); | 86 | default -> throw new TranslationException(ReasoningAdapter.EXISTS_SYMBOL, |
87 | "Invalid existence truth value %s for node %d".formatted(cursor.getValue(), i)); | ||
84 | } | 88 | } |
85 | } | 89 | } |
86 | } | 90 | } |
@@ -96,8 +100,8 @@ class MultiObjectInitializer implements PartialModelInitializer { | |||
96 | int i = key.get(0); | 100 | int i = key.get(0); |
97 | int otherIndex = key.get(1); | 101 | int otherIndex = key.get(1); |
98 | if (i != otherIndex) { | 102 | if (i != otherIndex) { |
99 | throw new IllegalArgumentException("Off-diagonal equivalence (%d, %d) is not permitted" | 103 | throw new TranslationException(ReasoningAdapter.EQUALS_SYMBOL, |
100 | .formatted(i, otherIndex)); | 104 | "Off-diagonal equivalence (%d, %d) is not permitted".formatted(i, otherIndex)); |
101 | } | 105 | } |
102 | checkNodeId(intervals, i); | 106 | checkNodeId(intervals, i); |
103 | switch (cursor.getValue()) { | 107 | switch (cursor.getValue()) { |
@@ -105,14 +109,15 @@ class MultiObjectInitializer implements PartialModelInitializer { | |||
105 | case UNKNOWN -> { | 109 | case UNKNOWN -> { |
106 | // Nothing do to, {@code intervals} is initialized with unknown equality. | 110 | // Nothing do to, {@code intervals} is initialized with unknown equality. |
107 | } | 111 | } |
108 | case ERROR -> throw new IllegalArgumentException("Inconsistent equality for node " + i); | 112 | case ERROR -> throw new TranslationException(ReasoningAdapter.EQUALS_SYMBOL, |
109 | default -> throw new IllegalArgumentException("Invalid equality truth value %s for node %d" | 113 | "Inconsistent equality for node " + i); |
110 | .formatted(cursor.getValue(), i)); | 114 | default -> throw new TranslationException(ReasoningAdapter.EQUALS_SYMBOL, |
115 | "Invalid equality truth value %s for node %d".formatted(cursor.getValue(), i)); | ||
111 | } | 116 | } |
112 | } | 117 | } |
113 | for (int i = 0; i < intervals.length; i++) { | 118 | for (int i = 0; i < intervals.length; i++) { |
114 | if (seed.get(Tuple.of(i, i)) == TruthValue.FALSE) { | 119 | if (seed.get(Tuple.of(i, i)) == TruthValue.FALSE) { |
115 | throw new IllegalArgumentException("Inconsistent equality for node " + i); | 120 | throw new TranslationException(ReasoningAdapter.EQUALS_SYMBOL, "Inconsistent equality for node " + i); |
116 | } | 121 | } |
117 | } | 122 | } |
118 | } | 123 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/ConstrainedMultiplicity.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/ConstrainedMultiplicity.java index e441e41e..9db9cc96 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/ConstrainedMultiplicity.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/ConstrainedMultiplicity.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.translator.multiplicity; | 6 | package tools.refinery.store.reasoning.translator.multiplicity; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | import tools.refinery.store.representation.cardinality.CardinalityInterval; | 10 | import tools.refinery.store.representation.cardinality.CardinalityInterval; |
10 | import tools.refinery.store.representation.cardinality.CardinalityIntervals; | 11 | import tools.refinery.store.representation.cardinality.CardinalityIntervals; |
11 | import tools.refinery.store.representation.cardinality.NonEmptyCardinalityInterval; | 12 | import tools.refinery.store.representation.cardinality.NonEmptyCardinalityInterval; |
@@ -14,17 +15,17 @@ public record ConstrainedMultiplicity(NonEmptyCardinalityInterval multiplicity, | |||
14 | implements Multiplicity { | 15 | implements Multiplicity { |
15 | public ConstrainedMultiplicity { | 16 | public ConstrainedMultiplicity { |
16 | if (multiplicity.equals(CardinalityIntervals.SET)) { | 17 | if (multiplicity.equals(CardinalityIntervals.SET)) { |
17 | throw new IllegalArgumentException("Expected a constrained cardinality interval"); | 18 | throw new TranslationException(errorSymbol, "Expected a constrained cardinality interval"); |
18 | } | 19 | } |
19 | if (errorSymbol.arity() != 1) { | 20 | if (errorSymbol.arity() != 1) { |
20 | throw new IllegalArgumentException("Expected error symbol %s to have arity 1, got %d instead" | 21 | throw new TranslationException(errorSymbol, "Expected error symbol %s to have arity 1, got %d instead" |
21 | .formatted(errorSymbol, errorSymbol.arity())); | 22 | .formatted(errorSymbol, errorSymbol.arity())); |
22 | } | 23 | } |
23 | } | 24 | } |
24 | 25 | ||
25 | public static ConstrainedMultiplicity of(CardinalityInterval multiplicity, PartialRelation errorSymbol) { | 26 | public static ConstrainedMultiplicity of(CardinalityInterval multiplicity, PartialRelation errorSymbol) { |
26 | if (!(multiplicity instanceof NonEmptyCardinalityInterval nonEmptyCardinalityInterval)) { | 27 | if (!(multiplicity instanceof NonEmptyCardinalityInterval nonEmptyCardinalityInterval)) { |
27 | throw new IllegalArgumentException("Inconsistent multiplicity"); | 28 | throw new TranslationException(errorSymbol, "Inconsistent multiplicity"); |
28 | } | 29 | } |
29 | return new ConstrainedMultiplicity(nonEmptyCardinalityInterval, errorSymbol); | 30 | return new ConstrainedMultiplicity(nonEmptyCardinalityInterval, errorSymbol); |
30 | } | 31 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/InvalidMultiplicityErrorTranslator.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/InvalidMultiplicityErrorTranslator.java index 522d8455..c5e5e83e 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/InvalidMultiplicityErrorTranslator.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/multiplicity/InvalidMultiplicityErrorTranslator.java | |||
@@ -14,6 +14,7 @@ import tools.refinery.store.reasoning.lifting.DnfLifter; | |||
14 | import tools.refinery.store.reasoning.literal.*; | 14 | import tools.refinery.store.reasoning.literal.*; |
15 | import tools.refinery.store.reasoning.representation.PartialRelation; | 15 | import tools.refinery.store.reasoning.representation.PartialRelation; |
16 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; | 16 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; |
17 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
17 | import tools.refinery.store.representation.cardinality.FiniteUpperCardinality; | 18 | import tools.refinery.store.representation.cardinality.FiniteUpperCardinality; |
18 | import tools.refinery.store.representation.cardinality.UpperCardinalities; | 19 | import tools.refinery.store.representation.cardinality.UpperCardinalities; |
19 | import tools.refinery.store.representation.cardinality.UpperCardinality; | 20 | import tools.refinery.store.representation.cardinality.UpperCardinality; |
@@ -36,11 +37,11 @@ public class InvalidMultiplicityErrorTranslator implements ModelStoreConfigurati | |||
36 | public InvalidMultiplicityErrorTranslator(PartialRelation nodeType, PartialRelation linkType, | 37 | public InvalidMultiplicityErrorTranslator(PartialRelation nodeType, PartialRelation linkType, |
37 | boolean inverse, Multiplicity multiplicity) { | 38 | boolean inverse, Multiplicity multiplicity) { |
38 | if (nodeType.arity() != 1) { | 39 | if (nodeType.arity() != 1) { |
39 | throw new IllegalArgumentException("Node type must be of arity 1, got %s with arity %d instead" | 40 | throw new TranslationException(linkType, "Node type must be of arity 1, got %s with arity %d instead" |
40 | .formatted(nodeType, nodeType.arity())); | 41 | .formatted(nodeType, nodeType.arity())); |
41 | } | 42 | } |
42 | if (linkType.arity() != 2) { | 43 | if (linkType.arity() != 2) { |
43 | throw new IllegalArgumentException("Link type must be of arity 2, got %s with arity %d instead" | 44 | throw new TranslationException(linkType, "Link type must be of arity 2, got %s with arity %d instead" |
44 | .formatted(linkType, linkType.arity())); | 45 | .formatted(linkType, linkType.arity())); |
45 | } | 46 | } |
46 | this.nodeType = nodeType; | 47 | this.nodeType = nodeType; |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/opposite/OppositeRelationTranslator.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/opposite/OppositeRelationTranslator.java index b25b9d7d..6e15a628 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/opposite/OppositeRelationTranslator.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/opposite/OppositeRelationTranslator.java | |||
@@ -17,6 +17,7 @@ import tools.refinery.store.reasoning.literal.Modality; | |||
17 | import tools.refinery.store.reasoning.refinement.RefinementBasedInitializer; | 17 | import tools.refinery.store.reasoning.refinement.RefinementBasedInitializer; |
18 | import tools.refinery.store.reasoning.representation.PartialRelation; | 18 | import tools.refinery.store.reasoning.representation.PartialRelation; |
19 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; | 19 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; |
20 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
20 | 21 | ||
21 | import java.util.List; | 22 | import java.util.List; |
22 | import java.util.Set; | 23 | import java.util.Set; |
@@ -26,6 +27,16 @@ public class OppositeRelationTranslator implements ModelStoreConfiguration, Part | |||
26 | private final PartialRelation opposite; | 27 | private final PartialRelation opposite; |
27 | 28 | ||
28 | public OppositeRelationTranslator(PartialRelation linkType, PartialRelation opposite) { | 29 | public OppositeRelationTranslator(PartialRelation linkType, PartialRelation opposite) { |
30 | if (linkType.arity() != 2) { | ||
31 | throw new TranslationException(linkType, | ||
32 | "Expected relation with opposite %s to have arity 2, got %d instead" | ||
33 | .formatted(linkType, linkType.arity())); | ||
34 | } | ||
35 | if (opposite.arity() != 2) { | ||
36 | throw new TranslationException(linkType, | ||
37 | "Expected opposite %s of %s to have arity 2, got %d instead" | ||
38 | .formatted(opposite, linkType, opposite.arity())); | ||
39 | } | ||
29 | this.linkType = linkType; | 40 | this.linkType = linkType; |
30 | this.opposite = opposite; | 41 | this.opposite = opposite; |
31 | } | 42 | } |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/predicate/PredicateTranslator.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/predicate/PredicateTranslator.java index ee022f2d..16745da1 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/predicate/PredicateTranslator.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/predicate/PredicateTranslator.java | |||
@@ -17,6 +17,7 @@ import tools.refinery.store.query.view.MayView; | |||
17 | import tools.refinery.store.query.view.MustView; | 17 | import tools.refinery.store.query.view.MustView; |
18 | import tools.refinery.store.reasoning.representation.PartialRelation; | 18 | import tools.refinery.store.reasoning.representation.PartialRelation; |
19 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; | 19 | import tools.refinery.store.reasoning.translator.PartialRelationTranslator; |
20 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
20 | import tools.refinery.store.representation.Symbol; | 21 | import tools.refinery.store.representation.Symbol; |
21 | import tools.refinery.store.representation.TruthValue; | 22 | import tools.refinery.store.representation.TruthValue; |
22 | 23 | ||
@@ -33,11 +34,11 @@ public class PredicateTranslator implements ModelStoreConfiguration { | |||
33 | public PredicateTranslator(PartialRelation relation, RelationalQuery query, boolean mutable, | 34 | public PredicateTranslator(PartialRelation relation, RelationalQuery query, boolean mutable, |
34 | TruthValue defaultValue) { | 35 | TruthValue defaultValue) { |
35 | if (relation.arity() != query.arity()) { | 36 | if (relation.arity() != query.arity()) { |
36 | throw new IllegalArgumentException("Expected arity %d query for partial relation %s, got %d instead" | 37 | throw new TranslationException(relation, "Expected arity %d query for partial relation %s, got %d instead" |
37 | .formatted(relation.arity(), relation, query.arity())); | 38 | .formatted(relation.arity(), relation, query.arity())); |
38 | } | 39 | } |
39 | if (defaultValue.must()) { | 40 | if (defaultValue.must()) { |
40 | throw new IllegalArgumentException("Default value must be UNKNOWN or FALSE"); | 41 | throw new TranslationException(relation, "Default value must be UNKNOWN or FALSE"); |
41 | } | 42 | } |
42 | this.relation = relation; | 43 | this.relation = relation; |
43 | this.query = query; | 44 | this.query = query; |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchy.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchy.java index 35ec54ad..3f918c97 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchy.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchy.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.translator.typehierarchy; | 6 | package tools.refinery.store.reasoning.translator.typehierarchy; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | 10 | ||
10 | import java.util.*; | 11 | import java.util.*; |
11 | 12 | ||
@@ -81,8 +82,9 @@ public class TypeHierarchy { | |||
81 | for (var supertype : allSupertypes) { | 82 | for (var supertype : allSupertypes) { |
82 | var supertypeInfo = extendedTypeInfoMap.get(supertype); | 83 | var supertypeInfo = extendedTypeInfoMap.get(supertype); |
83 | if (supertypeInfo == null) { | 84 | if (supertypeInfo == null) { |
84 | throw new IllegalArgumentException("Supertype %s of %s is missing from the type hierarchy" | 85 | throw new TranslationException(extendedTypeInfo.getType(), |
85 | .formatted(supertype, extendedTypeInfo.getType())); | 86 | "Supertype %s of %s is missing from the type hierarchy" |
87 | .formatted(supertype, extendedTypeInfo.getType())); | ||
86 | } | 88 | } |
87 | found.addAll(supertypeInfo.getAllSupertypes()); | 89 | found.addAll(supertypeInfo.getAllSupertypes()); |
88 | } | 90 | } |
@@ -101,7 +103,7 @@ public class TypeHierarchy { | |||
101 | } | 103 | } |
102 | for (var supertype : extendedTypeInfo.getAllSupertypes()) { | 104 | for (var supertype : extendedTypeInfo.getAllSupertypes()) { |
103 | if (type.equals(supertype)) { | 105 | if (type.equals(supertype)) { |
104 | throw new IllegalArgumentException("%s cannot be a supertype of itself".formatted(type)); | 106 | throw new TranslationException(type, "%s cannot be a supertype of itself".formatted(type)); |
105 | } | 107 | } |
106 | var supertypeInfo = extendedTypeInfoMap.get(supertype); | 108 | var supertypeInfo = extendedTypeInfoMap.get(supertype); |
107 | supertypeInfo.getAllSubtypes().add(type); | 109 | supertypeInfo.getAllSubtypes().add(type); |
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyBuilder.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyBuilder.java index 36efb878..ce8fda05 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyBuilder.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyBuilder.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.reasoning.translator.typehierarchy; | 6 | package tools.refinery.store.reasoning.translator.typehierarchy; |
7 | 7 | ||
8 | import tools.refinery.store.reasoning.representation.PartialRelation; | 8 | import tools.refinery.store.reasoning.representation.PartialRelation; |
9 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
9 | 10 | ||
10 | import java.util.*; | 11 | import java.util.*; |
11 | 12 | ||
@@ -18,12 +19,14 @@ public class TypeHierarchyBuilder { | |||
18 | 19 | ||
19 | public TypeHierarchyBuilder type(PartialRelation partialRelation, TypeInfo typeInfo) { | 20 | public TypeHierarchyBuilder type(PartialRelation partialRelation, TypeInfo typeInfo) { |
20 | if (partialRelation.arity() != 1) { | 21 | if (partialRelation.arity() != 1) { |
21 | throw new IllegalArgumentException("Only types of arity 1 are supported, got %s with %d instead" | 22 | throw new TranslationException(partialRelation, |
22 | .formatted(partialRelation, partialRelation.arity())); | 23 | "Only types of arity 1 are supported, got %s with %d instead" |
24 | .formatted(partialRelation, partialRelation.arity())); | ||
23 | } | 25 | } |
24 | var putResult = typeInfoMap.put(partialRelation, typeInfo); | 26 | var putResult = typeInfoMap.put(partialRelation, typeInfo); |
25 | if (putResult != null && !putResult.equals(typeInfo)) { | 27 | if (putResult != null && !putResult.equals(typeInfo)) { |
26 | throw new IllegalArgumentException("Duplicate type info for partial relation: " + partialRelation); | 28 | throw new TranslationException(partialRelation, |
29 | "Duplicate type info for partial relation: " + partialRelation); | ||
27 | } | 30 | } |
28 | return this; | 31 | return this; |
29 | } | 32 | } |
diff --git a/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilderTest.java b/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilderTest.java index 115ba8cd..0f1a1006 100644 --- a/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilderTest.java +++ b/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/metamodel/MetamodelBuilderTest.java | |||
@@ -7,6 +7,7 @@ package tools.refinery.store.reasoning.translator.metamodel; | |||
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.reasoning.representation.PartialRelation; | 9 | import tools.refinery.store.reasoning.representation.PartialRelation; |
10 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
10 | import tools.refinery.store.reasoning.translator.multiplicity.ConstrainedMultiplicity; | 11 | import tools.refinery.store.reasoning.translator.multiplicity.ConstrainedMultiplicity; |
11 | import tools.refinery.store.representation.cardinality.CardinalityIntervals; | 12 | import tools.refinery.store.representation.cardinality.CardinalityIntervals; |
12 | 13 | ||
@@ -26,7 +27,7 @@ class MetamodelBuilderTest { | |||
26 | .reference(courses, university, course, location) | 27 | .reference(courses, university, course, location) |
27 | .reference(location, course, university); | 28 | .reference(location, course, university); |
28 | 29 | ||
29 | assertThrows(IllegalArgumentException.class, builder::build); | 30 | assertThrows(TranslationException.class, builder::build); |
30 | } | 31 | } |
31 | 32 | ||
32 | @Test | 33 | @Test |
@@ -37,7 +38,7 @@ class MetamodelBuilderTest { | |||
37 | .reference(courses, university, course, location) | 38 | .reference(courses, university, course, location) |
38 | .reference(location, course, course, courses); | 39 | .reference(location, course, course, courses); |
39 | 40 | ||
40 | assertThrows(IllegalArgumentException.class, builder::build); | 41 | assertThrows(TranslationException.class, builder::build); |
41 | } | 42 | } |
42 | 43 | ||
43 | @Test | 44 | @Test |
@@ -52,6 +53,6 @@ class MetamodelBuilderTest { | |||
52 | ConstrainedMultiplicity.of(CardinalityIntervals.atLeast(2), invalidMultiplicity), | 53 | ConstrainedMultiplicity.of(CardinalityIntervals.atLeast(2), invalidMultiplicity), |
53 | university, courses); | 54 | university, courses); |
54 | 55 | ||
55 | assertThrows(IllegalArgumentException.class, builder::build); | 56 | assertThrows(TranslationException.class, builder::build); |
56 | } | 57 | } |
57 | } | 58 | } |
diff --git a/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyTest.java b/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyTest.java index 9fbf2334..931c62dd 100644 --- a/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyTest.java +++ b/subprojects/store-reasoning/src/test/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeHierarchyTest.java | |||
@@ -8,6 +8,7 @@ package tools.refinery.store.reasoning.translator.typehierarchy; | |||
8 | import org.hamcrest.Matchers; | 8 | import org.hamcrest.Matchers; |
9 | import org.junit.jupiter.api.Test; | 9 | import org.junit.jupiter.api.Test; |
10 | import tools.refinery.store.reasoning.representation.PartialRelation; | 10 | import tools.refinery.store.reasoning.representation.PartialRelation; |
11 | import tools.refinery.store.reasoning.translator.TranslationException; | ||
11 | import tools.refinery.store.representation.TruthValue; | 12 | import tools.refinery.store.representation.TruthValue; |
12 | 13 | ||
13 | import java.util.Set; | 14 | import java.util.Set; |
@@ -200,7 +201,7 @@ class TypeHierarchyTest { | |||
200 | .type(c1, c2) | 201 | .type(c1, c2) |
201 | .type(c2, c1); | 202 | .type(c2, c1); |
202 | 203 | ||
203 | assertThrows(IllegalArgumentException.class, builder::build); | 204 | assertThrows(TranslationException.class, builder::build); |
204 | } | 205 | } |
205 | 206 | ||
206 | @Test | 207 | @Test |