diff options
author | nagilooh <ficsorattila96@gmail.com> | 2023-08-25 17:04:43 +0200 |
---|---|---|
committer | nagilooh <ficsorattila96@gmail.com> | 2023-08-25 17:04:43 +0200 |
commit | 0b3f95bbc05d74b37d7c769bf76f38c25e4b1b73 (patch) | |
tree | 3516135ac5d9fa5cfffabe438e576e6b4e347828 | |
parent | Add delete action and additional tests for equals (diff) | |
download | refinery-0b3f95bbc05d74b37d7c769bf76f38c25e4b1b73.tar.gz refinery-0b3f95bbc05d74b37d7c769bf76f38c25e4b1b73.tar.zst refinery-0b3f95bbc05d74b37d7c769bf76f38c25e4b1b73.zip |
Move equivalence checking to new method
Also:
- Rename Symbol to Variable
- Make fire for InsertAction with low arity faster
10 files changed, 285 insertions, 286 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionSymbol.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionSymbol.java deleted file mode 100644 index a63f60f0..00000000 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionSymbol.java +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | package tools.refinery.store.dse.internal.action; | ||
2 | |||
3 | import tools.refinery.store.tuple.Tuple; | ||
4 | |||
5 | public abstract class ActionSymbol implements AtomicAction { | ||
6 | public abstract Tuple getValue(Tuple activation); | ||
7 | } | ||
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionVariable.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionVariable.java new file mode 100644 index 00000000..51078d15 --- /dev/null +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActionVariable.java | |||
@@ -0,0 +1,7 @@ | |||
1 | package tools.refinery.store.dse.internal.action; | ||
2 | |||
3 | import tools.refinery.store.tuple.Tuple; | ||
4 | |||
5 | public interface ActionVariable extends AtomicAction { | ||
6 | Tuple getValue(); | ||
7 | } | ||
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationSymbol.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationSymbol.java deleted file mode 100644 index 7598de0a..00000000 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationSymbol.java +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | package tools.refinery.store.dse.internal.action; | ||
2 | |||
3 | import tools.refinery.store.model.Model; | ||
4 | import tools.refinery.store.tuple.Tuple; | ||
5 | |||
6 | public class ActivationSymbol extends ActionSymbol { | ||
7 | |||
8 | private final int index; | ||
9 | private Tuple value; | ||
10 | |||
11 | public ActivationSymbol() { | ||
12 | this(0); | ||
13 | } | ||
14 | |||
15 | public ActivationSymbol(int index) { | ||
16 | this.index = index; | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public void fire(Tuple activation) { | ||
21 | value = Tuple.of(activation.get(index)); | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public ActivationSymbol prepare(Model model) { | ||
26 | return this; | ||
27 | } | ||
28 | |||
29 | @Override | ||
30 | public Tuple getValue(Tuple activation) { | ||
31 | return value; | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | public boolean equals(Object obj) { | ||
36 | if (obj == this) { | ||
37 | return true; | ||
38 | } | ||
39 | if (!(obj instanceof ActivationSymbol other)) { | ||
40 | return false; | ||
41 | } | ||
42 | |||
43 | if (index != other.index) { | ||
44 | return false; | ||
45 | } | ||
46 | if (value == null) { | ||
47 | return other.value == null; | ||
48 | } | ||
49 | return value.equals(other.value); | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public int hashCode() { | ||
54 | int result = 17; | ||
55 | result = 31 * result + Integer.hashCode(index); | ||
56 | result = 31 * result + value.hashCode(); | ||
57 | return result; | ||
58 | } | ||
59 | } | ||
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationVariable.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationVariable.java new file mode 100644 index 00000000..148d4156 --- /dev/null +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/ActivationVariable.java | |||
@@ -0,0 +1,49 @@ | |||
1 | package tools.refinery.store.dse.internal.action; | ||
2 | |||
3 | import tools.refinery.store.model.Model; | ||
4 | import tools.refinery.store.tuple.Tuple; | ||
5 | |||
6 | public class ActivationVariable implements ActionVariable { | ||
7 | |||
8 | private final int index; | ||
9 | private Tuple value; | ||
10 | |||
11 | public ActivationVariable() { | ||
12 | this(0); | ||
13 | } | ||
14 | |||
15 | public ActivationVariable(int index) { | ||
16 | this.index = index; | ||
17 | } | ||
18 | |||
19 | @Override | ||
20 | public void fire(Tuple activation) { | ||
21 | value = Tuple.of(activation.get(index)); | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public ActivationVariable prepare(Model model) { | ||
26 | return this; | ||
27 | } | ||
28 | |||
29 | @Override | ||
30 | public Tuple getValue() { | ||
31 | return value; | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | public boolean equalsWithSubstitution(AtomicAction other) { | ||
36 | if (other == null || getClass() != other.getClass()) { | ||
37 | return false; | ||
38 | } | ||
39 | var otherAction = (ActivationVariable) other; | ||
40 | |||
41 | if (index != otherAction.index) { | ||
42 | return false; | ||
43 | } | ||
44 | if (value == null) { | ||
45 | return otherAction.value == null; | ||
46 | } | ||
47 | return value.equals(otherAction.value); | ||
48 | } | ||
49 | } | ||
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/AtomicAction.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/AtomicAction.java index 19de644a..470278ae 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/AtomicAction.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/AtomicAction.java | |||
@@ -8,4 +8,6 @@ public interface AtomicAction { | |||
8 | void fire(Tuple activation); | 8 | void fire(Tuple activation); |
9 | 9 | ||
10 | AtomicAction prepare(Model model); | 10 | AtomicAction prepare(Model model); |
11 | |||
12 | boolean equalsWithSubstitution(AtomicAction other); | ||
11 | } | 13 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/DeleteAction.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/DeleteAction.java index c7cc4600..9fa77df3 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/DeleteAction.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/DeleteAction.java | |||
@@ -6,16 +6,16 @@ import tools.refinery.store.tuple.Tuple; | |||
6 | 6 | ||
7 | public class DeleteAction implements AtomicAction { | 7 | public class DeleteAction implements AtomicAction { |
8 | 8 | ||
9 | private final ActionSymbol symbol; | 9 | private final ActionVariable variable; |
10 | private DesignSpaceExplorationAdapter dseAdapter; | 10 | private DesignSpaceExplorationAdapter dseAdapter; |
11 | 11 | ||
12 | public DeleteAction(ActionSymbol symbol) { | 12 | public DeleteAction(ActionVariable variable) { |
13 | this.symbol = symbol; | 13 | this.variable = variable; |
14 | } | 14 | } |
15 | 15 | ||
16 | @Override | 16 | @Override |
17 | public void fire(Tuple activation) { | 17 | public void fire(Tuple activation) { |
18 | dseAdapter.deleteObject(symbol.getValue(activation)); | 18 | dseAdapter.deleteObject(variable.getValue()); |
19 | } | 19 | } |
20 | 20 | ||
21 | @Override | 21 | @Override |
@@ -25,20 +25,11 @@ public class DeleteAction implements AtomicAction { | |||
25 | } | 25 | } |
26 | 26 | ||
27 | @Override | 27 | @Override |
28 | public boolean equals(Object obj) { | 28 | public boolean equalsWithSubstitution(AtomicAction other) { |
29 | if (obj == this) { | 29 | if (other == null || getClass() != other.getClass()) { |
30 | return true; | ||
31 | } | ||
32 | if (!(obj instanceof DeleteAction other)) { | ||
33 | return false; | 30 | return false; |
34 | } | 31 | } |
35 | return this.symbol.getClass() == other.symbol.getClass(); | 32 | var otherAction = (DeleteAction) other; |
36 | } | 33 | return this.variable.getClass() == otherAction.variable.getClass(); |
37 | |||
38 | @Override | ||
39 | public int hashCode() { | ||
40 | int result = 17; | ||
41 | result = 31 * result + symbol.getClass().hashCode(); | ||
42 | return result; | ||
43 | } | 34 | } |
44 | } | 35 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/InsertAction.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/InsertAction.java index 7adab93b..2335abad 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/InsertAction.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/InsertAction.java | |||
@@ -3,6 +3,7 @@ package tools.refinery.store.dse.internal.action; | |||
3 | import tools.refinery.store.model.Interpretation; | 3 | import tools.refinery.store.model.Interpretation; |
4 | import tools.refinery.store.model.Model; | 4 | import tools.refinery.store.model.Model; |
5 | import tools.refinery.store.tuple.Tuple; | 5 | import tools.refinery.store.tuple.Tuple; |
6 | import tools.refinery.store.tuple.Tuple0; | ||
6 | 7 | ||
7 | import java.util.Arrays; | 8 | import java.util.Arrays; |
8 | 9 | ||
@@ -10,21 +11,42 @@ public class InsertAction<T> implements AtomicAction { | |||
10 | 11 | ||
11 | private final Interpretation<T> interpretation; | 12 | private final Interpretation<T> interpretation; |
12 | private final T value; | 13 | private final T value; |
14 | private final int arity; | ||
15 | private final ActionVariable[] variables; | ||
13 | 16 | ||
14 | private final ActionSymbol[] symbols; | 17 | public InsertAction(Interpretation<T> interpretation, T value, ActionVariable... variables) { |
15 | |||
16 | public InsertAction(Interpretation<T> interpretation, T value, ActionSymbol... symbols) { | ||
17 | this.interpretation = interpretation; | 18 | this.interpretation = interpretation; |
18 | this.value = value; | 19 | this.value = value; |
19 | this.symbols = symbols; | 20 | this.variables = variables; |
20 | 21 | this.arity = interpretation.getSymbol().arity(); | |
22 | if (variables.length != arity) { | ||
23 | throw new IllegalArgumentException("Expected " + arity + " variables, but got " + variables.length); | ||
24 | } | ||
21 | } | 25 | } |
22 | 26 | ||
23 | @Override | 27 | @Override |
24 | public void fire(Tuple activation) { | 28 | public void fire(Tuple activation) { |
25 | var tuple = Tuple.of(Arrays.stream(symbols).map(symbol -> symbol.getValue(activation).get(0)) | 29 | Tuple tuple; |
26 | .mapToInt(Integer::intValue).toArray()); | 30 | if (arity == 0) { |
31 | tuple = Tuple0.INSTANCE; | ||
32 | } | ||
33 | else if (arity == 1) { | ||
34 | tuple = variables[0].getValue(); | ||
35 | } | ||
36 | else if (arity == 2) { | ||
37 | tuple = Tuple.of(variables[0].getValue().get(0), variables[1].getValue().get(0)); | ||
38 | } | ||
39 | else if (arity == 3) { | ||
40 | tuple = Tuple.of(variables[0].getValue().get(0), variables[1].getValue().get(0), variables[2].getValue().get(0)); | ||
41 | } | ||
42 | else { | ||
43 | tuple = Tuple.of(Arrays.stream(variables).map(variable -> variable.getValue().get(0)) | ||
44 | .mapToInt(Integer::intValue).toArray()); | ||
45 | } | ||
46 | interpretation.put(tuple, value); | ||
47 | } | ||
27 | 48 | ||
49 | public void put(Tuple tuple) { | ||
28 | interpretation.put(tuple, value); | 50 | interpretation.put(tuple, value); |
29 | } | 51 | } |
30 | 52 | ||
@@ -33,46 +55,35 @@ public class InsertAction<T> implements AtomicAction { | |||
33 | return this; | 55 | return this; |
34 | } | 56 | } |
35 | 57 | ||
36 | public ActionSymbol[] getSymbols() { | 58 | public ActionVariable[] getVariables() { |
37 | return symbols; | 59 | return variables; |
38 | } | 60 | } |
39 | 61 | ||
40 | @Override | 62 | @Override |
41 | public boolean equals(Object obj) { | 63 | public boolean equalsWithSubstitution(AtomicAction other) { |
42 | if (obj == this) { | 64 | if (other == null || getClass() != other.getClass()) { |
43 | return true; | ||
44 | } | ||
45 | if (!(obj instanceof InsertAction<?> other)) { | ||
46 | return false; | 65 | return false; |
47 | } | 66 | } |
48 | if (symbols.length != other.symbols.length) { | 67 | var otherAction = (InsertAction<?>) other; |
68 | if (variables.length != otherAction.variables.length) { | ||
49 | return false; | 69 | return false; |
50 | } | 70 | } |
51 | if (!interpretation.equals(other.interpretation)) { | 71 | if (!interpretation.equals(otherAction.interpretation)) { |
52 | return false; | 72 | return false; |
53 | } | 73 | } |
54 | if (value == null) { | 74 | if (value == null) { |
55 | if (other.value != null) { | 75 | if (otherAction.value != null) { |
56 | return false; | 76 | return false; |
57 | } | 77 | } |
58 | } | 78 | } |
59 | else if (!value.equals(other.value)) { | 79 | else if (!value.equals(otherAction.value)) { |
60 | return false; | 80 | return false; |
61 | } | 81 | } |
62 | for (var i = 0; i < symbols.length; i++) { | 82 | for (var i = 0; i < variables.length; i++) { |
63 | if (!symbols[i].equals(other.symbols[i])) { | 83 | if (!variables[i].equalsWithSubstitution(otherAction.variables[i])) { |
64 | return false; | 84 | return false; |
65 | } | 85 | } |
66 | } | 86 | } |
67 | return true; | 87 | return true; |
68 | } | 88 | } |
69 | |||
70 | @Override | ||
71 | public int hashCode() { | ||
72 | int result = 17; | ||
73 | result = 31 * result + Arrays.hashCode(symbols); | ||
74 | result = 31 * result + interpretation.hashCode(); | ||
75 | result = 31 * result + value.hashCode(); | ||
76 | return result; | ||
77 | } | ||
78 | } | 89 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/NewItemSymbol.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/NewItemVariable.java index acdc3cae..65b1f544 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/NewItemSymbol.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/NewItemVariable.java | |||
@@ -5,7 +5,7 @@ import tools.refinery.store.model.Model; | |||
5 | import tools.refinery.store.tuple.Tuple; | 5 | import tools.refinery.store.tuple.Tuple; |
6 | import tools.refinery.store.tuple.Tuple1; | 6 | import tools.refinery.store.tuple.Tuple1; |
7 | 7 | ||
8 | public class NewItemSymbol extends ActionSymbol { | 8 | public class NewItemVariable implements ActionVariable { |
9 | private DesignSpaceExplorationAdapter dseAdapter; | 9 | private DesignSpaceExplorationAdapter dseAdapter; |
10 | private Tuple1 value; | 10 | private Tuple1 value; |
11 | 11 | ||
@@ -15,34 +15,26 @@ public class NewItemSymbol extends ActionSymbol { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | @Override | 17 | @Override |
18 | public NewItemSymbol prepare(Model model) { | 18 | public NewItemVariable prepare(Model model) { |
19 | dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | 19 | dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); |
20 | return this; | 20 | return this; |
21 | } | 21 | } |
22 | 22 | ||
23 | @Override | 23 | @Override |
24 | public Tuple1 getValue(Tuple activation) { | 24 | public Tuple1 getValue() { |
25 | return value; | 25 | return value; |
26 | } | 26 | } |
27 | 27 | ||
28 | @Override | 28 | @Override |
29 | public boolean equals(Object obj) { | 29 | public boolean equalsWithSubstitution(AtomicAction other) { |
30 | if (obj == this) { | 30 | if (other == null || getClass() != other.getClass()) { |
31 | return true; | ||
32 | } | ||
33 | if (!(obj instanceof NewItemSymbol other)) { | ||
34 | return false; | 31 | return false; |
35 | } | 32 | } |
33 | var otherAction = (NewItemVariable) other; | ||
36 | if (value == null) { | 34 | if (value == null) { |
37 | return other.value == null; | 35 | return otherAction.value == null; |
38 | } | 36 | } |
39 | return value.equals(other.value); | 37 | return value.equals(otherAction.value); |
40 | } | ||
41 | 38 | ||
42 | @Override | ||
43 | public int hashCode() { | ||
44 | int result = 17; | ||
45 | result = 31 * result + value.hashCode(); | ||
46 | return result; | ||
47 | } | 39 | } |
48 | } | 40 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/TransformationAction.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/TransformationAction.java index 19ab4575..50387f53 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/TransformationAction.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/internal/action/TransformationAction.java | |||
@@ -7,15 +7,15 @@ import tools.refinery.store.tuple.Tuple2; | |||
7 | import java.util.*; | 7 | import java.util.*; |
8 | 8 | ||
9 | public class TransformationAction { | 9 | public class TransformationAction { |
10 | private final List<ActionSymbol> actionSymbols = new ArrayList<>(); | 10 | private final List<ActionVariable> actionVariables = new ArrayList<>(); |
11 | private final List<InsertAction<?>> insertActions = new ArrayList<>(); | 11 | private final List<InsertAction<?>> insertActions = new ArrayList<>(); |
12 | private final List<DeleteAction> deleteActions = new ArrayList<>(); | 12 | private final List<DeleteAction> deleteActions = new ArrayList<>(); |
13 | private boolean configured = false; | 13 | private boolean configured = false; |
14 | private final Map<Integer, List<Tuple2>> activationSymbolUsageMap = new LinkedHashMap<>(); | 14 | private final Map<Integer, List<Tuple2>> actionVariableUsageMap = new LinkedHashMap<>(); |
15 | 15 | ||
16 | public TransformationAction add(ActionSymbol action) { | 16 | public TransformationAction add(ActionVariable action) { |
17 | checkConfigured(); | 17 | checkConfigured(); |
18 | actionSymbols.add(action); | 18 | actionVariables.add(action); |
19 | return this; | 19 | return this; |
20 | } | 20 | } |
21 | 21 | ||
@@ -38,7 +38,7 @@ public class TransformationAction { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | public TransformationAction prepare(Model model) { | 40 | public TransformationAction prepare(Model model) { |
41 | for (ActionSymbol action : actionSymbols) { | 41 | for (ActionVariable action : actionVariables) { |
42 | action.prepare(model); | 42 | action.prepare(model); |
43 | } | 43 | } |
44 | for (InsertAction<?> action : insertActions) { | 44 | for (InsertAction<?> action : insertActions) { |
@@ -50,11 +50,11 @@ public class TransformationAction { | |||
50 | 50 | ||
51 | for (var insertAction : insertActions) { | 51 | for (var insertAction : insertActions) { |
52 | var actionIndex = insertActions.indexOf(insertAction); | 52 | var actionIndex = insertActions.indexOf(insertAction); |
53 | var symbols = insertAction.getSymbols(); | 53 | var variables = insertAction.getVariables(); |
54 | for (var i = 0; i < symbols.length; i++) { | 54 | for (var i = 0; i < variables.length; i++) { |
55 | var symbolGlobalIndex = actionSymbols.indexOf(symbols[i]); | 55 | var variablelGlobalIndex = actionVariables.indexOf(variables[i]); |
56 | activationSymbolUsageMap.computeIfAbsent(symbolGlobalIndex, k -> new ArrayList<>()); | 56 | actionVariableUsageMap.computeIfAbsent(variablelGlobalIndex, k -> new ArrayList<>()); |
57 | activationSymbolUsageMap.get(symbolGlobalIndex).add(Tuple.of(actionIndex, i)); | 57 | actionVariableUsageMap.get(variablelGlobalIndex).add(Tuple.of(actionIndex, i)); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
@@ -63,7 +63,7 @@ public class TransformationAction { | |||
63 | } | 63 | } |
64 | 64 | ||
65 | public boolean fire(Tuple activation) { | 65 | public boolean fire(Tuple activation) { |
66 | for (ActionSymbol action : actionSymbols) { | 66 | for (ActionVariable action : actionVariables) { |
67 | action.fire(activation); | 67 | action.fire(activation); |
68 | } | 68 | } |
69 | for (InsertAction<?> action : insertActions) { | 69 | for (InsertAction<?> action : insertActions) { |
@@ -75,36 +75,50 @@ public class TransformationAction { | |||
75 | return true; | 75 | return true; |
76 | } | 76 | } |
77 | 77 | ||
78 | // True if Symbols and InsertActions are inserted in same order, ActivationSymbols are equal (they have the same | 78 | // Returns true if ActionVariables and InsertActions are inserted in same order, ActionVariables are equal (they |
79 | // index for getting the value from the activation Tuple) and InsertActions are equal (they have the same arity | 79 | // have the same index for getting the value from the activation Tuple) and InsertActions are equal (they have |
80 | // and value to be set). | 80 | // the same arity and value to be set). |
81 | @Override | 81 | public boolean equalsWithSubstitution(TransformationAction other) { |
82 | public boolean equals(Object obj) { | 82 | if (other == this) { |
83 | if (obj == this) { | ||
84 | return true; | 83 | return true; |
85 | } | 84 | } |
86 | if (!(obj instanceof TransformationAction other)) { | 85 | |
86 | if (actionVariables.size() != other.actionVariables.size()) { | ||
87 | return false; | 87 | return false; |
88 | } | 88 | } |
89 | if (!actionSymbols.equals(other.actionSymbols)) { | 89 | |
90 | if (insertActions.size() != other.insertActions.size()) { | ||
90 | return false; | 91 | return false; |
91 | } | 92 | } |
92 | if (!insertActions.equals(other.insertActions)) { | 93 | |
94 | if (deleteActions.size() != other.deleteActions.size()) { | ||
93 | return false; | 95 | return false; |
94 | } | 96 | } |
95 | if (!deleteActions.equals(other.deleteActions)) { | 97 | |
96 | return false; | 98 | for (var i = 0; i < actionVariables.size(); i++) { |
99 | var variable = actionVariables.get(i); | ||
100 | var otherVariable = other.actionVariables.get(i); | ||
101 | if (!variable.equalsWithSubstitution(otherVariable)) { | ||
102 | return false; | ||
103 | } | ||
97 | } | 104 | } |
98 | return this.activationSymbolUsageMap.equals(other.activationSymbolUsageMap); | ||
99 | 105 | ||
100 | } | 106 | for (var i = 0; i < insertActions.size(); i++) { |
107 | var insertAction = insertActions.get(i); | ||
108 | var otherInsertAction = other.insertActions.get(i); | ||
109 | if (!insertAction.equalsWithSubstitution(otherInsertAction)) { | ||
110 | return false; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | for (var i = 0; i < deleteActions.size(); i++) { | ||
115 | var deleteAction = deleteActions.get(i); | ||
116 | var otherDeleteAction = other.deleteActions.get(i); | ||
117 | if (!deleteAction.equalsWithSubstitution(otherDeleteAction)) { | ||
118 | return false; | ||
119 | } | ||
120 | } | ||
121 | return this.actionVariableUsageMap.equals(other.actionVariableUsageMap); | ||
101 | 122 | ||
102 | @Override | ||
103 | public int hashCode() { | ||
104 | var result = 17; | ||
105 | result = 31 * result + actionSymbols.hashCode(); | ||
106 | result = 31 * result + insertActions.hashCode(); | ||
107 | result = 31 * result + deleteActions.hashCode(); | ||
108 | return result; | ||
109 | } | 123 | } |
110 | } | 124 | } |
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/ActionEqualsTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/ActionEqualsTest.java index e29260e9..1489b413 100644 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/ActionEqualsTest.java +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/ActionEqualsTest.java | |||
@@ -14,8 +14,7 @@ import tools.refinery.store.query.view.KeyOnlyView; | |||
14 | import tools.refinery.store.representation.Symbol; | 14 | import tools.refinery.store.representation.Symbol; |
15 | import tools.refinery.store.representation.TruthValue; | 15 | import tools.refinery.store.representation.TruthValue; |
16 | 16 | ||
17 | import static org.junit.jupiter.api.Assertions.assertEquals; | 17 | import static org.junit.jupiter.api.Assertions.*; |
18 | import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
19 | 18 | ||
20 | public class ActionEqualsTest { | 19 | public class ActionEqualsTest { |
21 | 20 | ||
@@ -55,7 +54,6 @@ public class ActionEqualsTest { | |||
55 | .build(); | 54 | .build(); |
56 | 55 | ||
57 | 56 | ||
58 | |||
59 | model = store.createEmptyModel(); | 57 | model = store.createEmptyModel(); |
60 | dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); | 58 | dseAdapter = model.getAdapter(DesignSpaceExplorationAdapter.class); |
61 | } | 59 | } |
@@ -64,40 +62,46 @@ public class ActionEqualsTest { | |||
64 | void emptyActionEqualsTest() { | 62 | void emptyActionEqualsTest() { |
65 | var action1 = new TransformationAction(); | 63 | var action1 = new TransformationAction(); |
66 | var action2 = new TransformationAction(); | 64 | var action2 = new TransformationAction(); |
67 | assertEquals(action1, action1); | 65 | |
68 | assertEquals(action2, action2); | 66 | assertTrue(action1.equalsWithSubstitution(action1)); |
69 | assertEquals(action1, action2); | 67 | assertTrue(action2.equalsWithSubstitution(action2)); |
68 | assertTrue(action1.equalsWithSubstitution(action2)); | ||
70 | } | 69 | } |
71 | 70 | ||
72 | @Test | 71 | @Test |
73 | void actionTrivialTest() { | 72 | void actionTrivialTest() { |
74 | var newItemSymbol1 = new NewItemSymbol(); | 73 | var newItemSymbol1 = new NewItemVariable(); |
75 | var activationSymbol = new ActivationSymbol(); | 74 | var activationSymbol = new ActivationVariable(); |
76 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 75 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1); |
76 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, | ||
77 | activationSymbol); | 77 | activationSymbol); |
78 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 78 | var insertAction3 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1); |
79 | var insertAction4 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, | ||
79 | activationSymbol); | 80 | activationSymbol); |
80 | 81 | ||
81 | var action1 = new TransformationAction(); | 82 | var action1 = new TransformationAction(); |
82 | action1.add(newItemSymbol1); | 83 | action1.add(newItemSymbol1); |
83 | action1.add(activationSymbol); | 84 | action1.add(activationSymbol); |
84 | action1.add(insertAction1); | 85 | action1.add(insertAction1); |
86 | action1.add(insertAction2); | ||
85 | action1.prepare(model); | 87 | action1.prepare(model); |
86 | 88 | ||
87 | var action2 = new TransformationAction(); | 89 | var action2 = new TransformationAction(); |
88 | action2.add(newItemSymbol1); | 90 | action2.add(newItemSymbol1); |
89 | action2.add(activationSymbol); | 91 | action2.add(activationSymbol); |
90 | action2.add(insertAction2); | 92 | action2.add(insertAction3); |
93 | action2.add(insertAction4); | ||
91 | action2.prepare(model); | 94 | action2.prepare(model); |
92 | 95 | ||
93 | assertEquals(action1, action2); | 96 | assertTrue(action1.equalsWithSubstitution(action2)); |
94 | } | 97 | } |
95 | 98 | ||
96 | @Test | 99 | @Test |
97 | void actionIdenticalTest() { | 100 | void actionIdenticalTest() { |
98 | var newItemSymbol1 = new NewItemSymbol(); | 101 | var newItemSymbol1 = new NewItemVariable(); |
99 | var activationSymbol1 = new ActivationSymbol(); | 102 | var activationSymbol1 = new ActivationVariable(); |
100 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, activationSymbol1); | 103 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
104 | activationSymbol1); | ||
101 | 105 | ||
102 | var action1 = new TransformationAction(); | 106 | var action1 = new TransformationAction(); |
103 | action1.add(newItemSymbol1); | 107 | action1.add(newItemSymbol1); |
@@ -105,10 +109,9 @@ public class ActionEqualsTest { | |||
105 | action1.add(insertAction1); | 109 | action1.add(insertAction1); |
106 | action1.prepare(model); | 110 | action1.prepare(model); |
107 | 111 | ||
108 | 112 | var newItemSymbol2 = new NewItemVariable(); | |
109 | var newItemSymbol2 = new NewItemSymbol(); | 113 | var activationSymbol2 = new ActivationVariable(); |
110 | var activationSymbol2 = new ActivationSymbol(); | 114 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
111 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | ||
112 | activationSymbol2); | 115 | activationSymbol2); |
113 | 116 | ||
114 | var action2 = new TransformationAction(); | 117 | var action2 = new TransformationAction(); |
@@ -117,14 +120,14 @@ public class ActionEqualsTest { | |||
117 | action2.add(insertAction2); | 120 | action2.add(insertAction2); |
118 | action2.prepare(model); | 121 | action2.prepare(model); |
119 | 122 | ||
120 | assertEquals(action1, action2); | 123 | assertTrue(action1.equalsWithSubstitution(action2)); |
121 | } | 124 | } |
122 | 125 | ||
123 | @Test | 126 | @Test |
124 | void actionSymbolGlobalOrderTest() { | 127 | void actionSymbolGlobalOrderTest() { |
125 | var newItemSymbol1 = new NewItemSymbol(); | 128 | var newItemSymbol1 = new NewItemVariable(); |
126 | var activationSymbol1 = new ActivationSymbol(); | 129 | var activationSymbol1 = new ActivationVariable(); |
127 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 130 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
128 | activationSymbol1); | 131 | activationSymbol1); |
129 | 132 | ||
130 | var action1 = new TransformationAction(); | 133 | var action1 = new TransformationAction(); |
@@ -133,10 +136,9 @@ public class ActionEqualsTest { | |||
133 | action1.add(insertAction1); | 136 | action1.add(insertAction1); |
134 | action1.prepare(model); | 137 | action1.prepare(model); |
135 | 138 | ||
136 | 139 | var newItemSymbol2 = new NewItemVariable(); | |
137 | var newItemSymbol2 = new NewItemSymbol(); | 140 | var activationSymbol2 = new ActivationVariable(); |
138 | var activationSymbol2 = new ActivationSymbol(); | 141 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
139 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | ||
140 | activationSymbol2); | 142 | activationSymbol2); |
141 | 143 | ||
142 | var action2 = new TransformationAction(); | 144 | var action2 = new TransformationAction(); |
@@ -145,43 +147,39 @@ public class ActionEqualsTest { | |||
145 | action2.add(insertAction2); | 147 | action2.add(insertAction2); |
146 | action2.prepare(model); | 148 | action2.prepare(model); |
147 | 149 | ||
148 | assertNotEquals(action1, action2); | 150 | assertFalse(action1.equalsWithSubstitution(action2)); |
149 | } | 151 | } |
150 | 152 | ||
151 | @Test | 153 | @Test |
152 | void actionSymbolInInsertActionOrderTest() { | 154 | void actionSymbolRepeatedInInsertActionTest() { |
153 | var newItemSymbol1 = new NewItemSymbol(); | 155 | var newItemSymbol1 = new NewItemVariable(); |
154 | var activationSymbol1 = new ActivationSymbol(); | 156 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
155 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, activationSymbol1); | 157 | newItemSymbol1); |
156 | 158 | ||
157 | var action1 = new TransformationAction(); | 159 | var action1 = new TransformationAction(); |
158 | action1.add(newItemSymbol1); | 160 | action1.add(newItemSymbol1); |
159 | action1.add(activationSymbol1); | ||
160 | action1.add(insertAction1); | 161 | action1.add(insertAction1); |
161 | action1.prepare(model); | 162 | action1.prepare(model); |
162 | 163 | ||
163 | 164 | var newItemSymbol2 = new NewItemVariable(); | |
164 | var newItemSymbol2 = new NewItemSymbol(); | 165 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
165 | var activationSymbol2 = new ActivationSymbol(); | ||
166 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, activationSymbol2, | ||
167 | newItemSymbol2); | 166 | newItemSymbol2); |
168 | 167 | ||
169 | var action2 = new TransformationAction(); | 168 | var action2 = new TransformationAction(); |
170 | action2.add(newItemSymbol2); | 169 | action2.add(newItemSymbol2); |
171 | action2.add(activationSymbol2); | ||
172 | action2.add(insertAction2); | 170 | action2.add(insertAction2); |
173 | action2.prepare(model); | 171 | action2.prepare(model); |
174 | 172 | ||
175 | assertNotEquals(action1, action2); | 173 | assertTrue(action1.equalsWithSubstitution(action2)); |
176 | } | 174 | } |
177 | 175 | ||
178 | @Test | 176 | @Test |
179 | void identicalInsertActionInDifferentOrderTest() { | 177 | void identicalInsertActionInDifferentOrderTest() { |
180 | var newItemSymbol1 = new NewItemSymbol(); | 178 | var newItemSymbol1 = new NewItemVariable(); |
181 | var activationSymbol1 = new ActivationSymbol(); | 179 | var activationSymbol1 = new ActivationVariable(); |
182 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 180 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
183 | activationSymbol1); | 181 | activationSymbol1); |
184 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 182 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
185 | activationSymbol1); | 183 | activationSymbol1); |
186 | 184 | ||
187 | var action1 = new TransformationAction(); | 185 | var action1 = new TransformationAction(); |
@@ -198,19 +196,20 @@ public class ActionEqualsTest { | |||
198 | action2.add(insertAction1); | 196 | action2.add(insertAction1); |
199 | action2.prepare(model); | 197 | action2.prepare(model); |
200 | 198 | ||
201 | assertEquals(action1, action2); | 199 | assertTrue(action1.equalsWithSubstitution(action2)); |
202 | } | 200 | } |
203 | 201 | ||
204 | @Test | 202 | @Test |
205 | void identicalActionAndSymbolDifferentOrderTest() { | 203 | void identicalActionAndSymbolDifferentOrderTest() { |
206 | var newItemSymbol1 = new NewItemSymbol(); | 204 | var newItemSymbol1 = new NewItemVariable(); |
207 | var activationSymbol1 = new ActivationSymbol(); | 205 | var newItemSymbol2 = new NewItemVariable(); |
208 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 206 | var activationSymbol1 = new ActivationVariable(); |
207 | var activationSymbol2 = new ActivationVariable(); | ||
208 | |||
209 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, | ||
209 | activationSymbol1); | 210 | activationSymbol1); |
210 | 211 | ||
211 | var newItemSymbol2 = new NewItemSymbol(); | 212 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
212 | var activationSymbol2 = new ActivationSymbol(); | ||
213 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | ||
214 | activationSymbol2); | 213 | activationSymbol2); |
215 | 214 | ||
216 | var action1 = new TransformationAction(); | 215 | var action1 = new TransformationAction(); |
@@ -231,19 +230,19 @@ public class ActionEqualsTest { | |||
231 | action2.add(insertAction1); | 230 | action2.add(insertAction1); |
232 | action2.prepare(model); | 231 | action2.prepare(model); |
233 | 232 | ||
234 | assertEquals(action1, action2); | 233 | assertTrue(action1.equalsWithSubstitution(action2)); |
235 | } | 234 | } |
236 | 235 | ||
237 | @Test | 236 | @Test |
238 | void identicalActionAndSymbolMixedOrderTest() { | 237 | void identicalActionAndSymbolMixedOrderTest() { |
239 | var newItemSymbol1 = new NewItemSymbol(); | 238 | var newItemSymbol1 = new NewItemVariable(); |
240 | var activationSymbol1 = new ActivationSymbol(); | 239 | var activationSymbol1 = new ActivationVariable(); |
241 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 240 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
242 | activationSymbol1); | 241 | activationSymbol1); |
243 | 242 | ||
244 | var newItemSymbol2 = new NewItemSymbol(); | 243 | var newItemSymbol2 = new NewItemVariable(); |
245 | var activationSymbol2 = new ActivationSymbol(); | 244 | var activationSymbol2 = new ActivationVariable(); |
246 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | 245 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
247 | activationSymbol2); | 246 | activationSymbol2); |
248 | 247 | ||
249 | var action1 = new TransformationAction(); | 248 | var action1 = new TransformationAction(); |
@@ -264,16 +263,16 @@ public class ActionEqualsTest { | |||
264 | action2.add(activationSymbol2); | 263 | action2.add(activationSymbol2); |
265 | action2.prepare(model); | 264 | action2.prepare(model); |
266 | 265 | ||
267 | assertEquals(action1, action2); | 266 | assertTrue(action1.equalsWithSubstitution(action2)); |
268 | } | 267 | } |
269 | 268 | ||
270 | @Test | 269 | @Test |
271 | void insertActionInterpretationTest() { | 270 | void insertActionInterpretationTest() { |
272 | var newItemSymbol1 = new NewItemSymbol(); | 271 | var newItemSymbol1 = new NewItemVariable(); |
273 | var activationSymbol1 = new ActivationSymbol(); | 272 | var activationSymbol1 = new ActivationVariable(); |
274 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 273 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
275 | activationSymbol1); | 274 | activationSymbol1); |
276 | var insertAction2 = new InsertAction<>(model.getInterpretation(type2), true, newItemSymbol1, | 275 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation2), true, newItemSymbol1, |
277 | activationSymbol1); | 276 | activationSymbol1); |
278 | 277 | ||
279 | var action1 = new TransformationAction(); | 278 | var action1 = new TransformationAction(); |
@@ -288,16 +287,16 @@ public class ActionEqualsTest { | |||
288 | action2.add(insertAction2); | 287 | action2.add(insertAction2); |
289 | action2.prepare(model); | 288 | action2.prepare(model); |
290 | 289 | ||
291 | assertNotEquals(action1, action2); | 290 | assertFalse(action1.equalsWithSubstitution(action2)); |
292 | } | 291 | } |
293 | 292 | ||
294 | @Test | 293 | @Test |
295 | void insertActionValueTest() { | 294 | void insertActionValueTest() { |
296 | var newItemSymbol1 = new NewItemSymbol(); | 295 | var newItemSymbol1 = new NewItemVariable(); |
297 | var activationSymbol1 = new ActivationSymbol(); | 296 | var activationSymbol1 = new ActivationVariable(); |
298 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 297 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
299 | activationSymbol1); | 298 | activationSymbol1); |
300 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol1, | 299 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol1, |
301 | activationSymbol1); | 300 | activationSymbol1); |
302 | 301 | ||
303 | var action1 = new TransformationAction(); | 302 | var action1 = new TransformationAction(); |
@@ -312,17 +311,17 @@ public class ActionEqualsTest { | |||
312 | action2.add(insertAction2); | 311 | action2.add(insertAction2); |
313 | action2.prepare(model); | 312 | action2.prepare(model); |
314 | 313 | ||
315 | assertNotEquals(action1, action2); | 314 | assertFalse(action1.equalsWithSubstitution(action2)); |
316 | } | 315 | } |
317 | 316 | ||
318 | @Test | 317 | @Test |
319 | void newItemSymbolDuplicateTest() { | 318 | void newItemSymbolDuplicateTest() { |
320 | var newItemSymbol1 = new NewItemSymbol(); | 319 | var newItemSymbol1 = new NewItemVariable(); |
321 | var newItemSymbol2 = new NewItemSymbol(); | 320 | var newItemSymbol2 = new NewItemVariable(); |
322 | var activationSymbol1 = new ActivationSymbol(); | 321 | var activationSymbol1 = new ActivationVariable(); |
323 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 322 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
324 | activationSymbol1); | 323 | activationSymbol1); |
325 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | 324 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
326 | activationSymbol1); | 325 | activationSymbol1); |
327 | 326 | ||
328 | var action1 = new TransformationAction(); | 327 | var action1 = new TransformationAction(); |
@@ -337,17 +336,17 @@ public class ActionEqualsTest { | |||
337 | action2.add(insertAction2); | 336 | action2.add(insertAction2); |
338 | action2.prepare(model); | 337 | action2.prepare(model); |
339 | 338 | ||
340 | assertEquals(action1, action2); | 339 | assertTrue(action1.equalsWithSubstitution(action2)); |
341 | } | 340 | } |
342 | 341 | ||
343 | @Test | 342 | @Test |
344 | void activationSymbolDuplicateTest() { | 343 | void activationSymbolDuplicateTest() { |
345 | var newItemSymbol1 = new NewItemSymbol(); | 344 | var newItemSymbol1 = new NewItemVariable(); |
346 | var activationSymbol1 = new ActivationSymbol(); | 345 | var activationSymbol1 = new ActivationVariable(); |
347 | var activationSymbol2 = new ActivationSymbol(); | 346 | var activationSymbol2 = new ActivationVariable(); |
348 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 347 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
349 | activationSymbol1); | 348 | activationSymbol1); |
350 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 349 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
351 | activationSymbol2); | 350 | activationSymbol2); |
352 | 351 | ||
353 | var action1 = new TransformationAction(); | 352 | var action1 = new TransformationAction(); |
@@ -362,17 +361,17 @@ public class ActionEqualsTest { | |||
362 | action2.add(insertAction2); | 361 | action2.add(insertAction2); |
363 | action2.prepare(model); | 362 | action2.prepare(model); |
364 | 363 | ||
365 | assertEquals(action1, action2); | 364 | assertTrue(action1.equalsWithSubstitution(action2)); |
366 | } | 365 | } |
367 | 366 | ||
368 | @Test | 367 | @Test |
369 | void activationSymbolIndexTest() { | 368 | void activationSymbolIndexTest() { |
370 | var newItemSymbol1 = new NewItemSymbol(); | 369 | var newItemSymbol1 = new NewItemVariable(); |
371 | var activationSymbol1 = new ActivationSymbol(0); | 370 | var activationSymbol1 = new ActivationVariable(0); |
372 | var activationSymbol2 = new ActivationSymbol(1); | 371 | var activationSymbol2 = new ActivationVariable(1); |
373 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 372 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
374 | activationSymbol1); | 373 | activationSymbol1); |
375 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 374 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
376 | activationSymbol2); | 375 | activationSymbol2); |
377 | 376 | ||
378 | var action1 = new TransformationAction(); | 377 | var action1 = new TransformationAction(); |
@@ -387,14 +386,14 @@ public class ActionEqualsTest { | |||
387 | action2.add(insertAction2); | 386 | action2.add(insertAction2); |
388 | action2.prepare(model); | 387 | action2.prepare(model); |
389 | 388 | ||
390 | assertNotEquals(action1, action2); | 389 | assertFalse(action1.equalsWithSubstitution(action2)); |
391 | } | 390 | } |
392 | 391 | ||
393 | @Test | 392 | @Test |
394 | void deleteActionTest() { | 393 | void deleteActionTest() { |
395 | var newItemSymbol = new NewItemSymbol(); | 394 | var newItemSymbol = new NewItemVariable(); |
396 | var activationSymbol = new ActivationSymbol(0); | 395 | var activationSymbol = new ActivationVariable(0); |
397 | var insertAction = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol, | 396 | var insertAction = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol, |
398 | activationSymbol); | 397 | activationSymbol); |
399 | var deleteAction = new DeleteAction(activationSymbol); | 398 | var deleteAction = new DeleteAction(activationSymbol); |
400 | 399 | ||
@@ -412,14 +411,14 @@ public class ActionEqualsTest { | |||
412 | action2.add(deleteAction); | 411 | action2.add(deleteAction); |
413 | action2.prepare(model); | 412 | action2.prepare(model); |
414 | 413 | ||
415 | assertEquals(action1, action2); | 414 | assertTrue(action1.equalsWithSubstitution(action2)); |
416 | } | 415 | } |
417 | 416 | ||
418 | @Test | 417 | @Test |
419 | void deleteActionMissingTest() { | 418 | void deleteActionMissingTest() { |
420 | var newItemSymbol = new NewItemSymbol(); | 419 | var newItemSymbol = new NewItemVariable(); |
421 | var activationSymbol = new ActivationSymbol(0); | 420 | var activationSymbol = new ActivationVariable(0); |
422 | var insertAction = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol, | 421 | var insertAction = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol, |
423 | activationSymbol); | 422 | activationSymbol); |
424 | var deleteAction = new DeleteAction(activationSymbol); | 423 | var deleteAction = new DeleteAction(activationSymbol); |
425 | 424 | ||
@@ -436,14 +435,14 @@ public class ActionEqualsTest { | |||
436 | action2.add(insertAction); | 435 | action2.add(insertAction); |
437 | action2.prepare(model); | 436 | action2.prepare(model); |
438 | 437 | ||
439 | assertNotEquals(action1, action2); | 438 | assertFalse(action1.equalsWithSubstitution(action2)); |
440 | } | 439 | } |
441 | 440 | ||
442 | @Test | 441 | @Test |
443 | void deleteActionIdenticalTest() { | 442 | void deleteActionIdenticalTest() { |
444 | var newItemSymbol = new NewItemSymbol(); | 443 | var newItemSymbol = new NewItemVariable(); |
445 | var activationSymbol = new ActivationSymbol(0); | 444 | var activationSymbol = new ActivationVariable(0); |
446 | var insertAction = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol, | 445 | var insertAction = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol, |
447 | activationSymbol); | 446 | activationSymbol); |
448 | var deleteAction1 = new DeleteAction(activationSymbol); | 447 | var deleteAction1 = new DeleteAction(activationSymbol); |
449 | var deleteAction2 = new DeleteAction(activationSymbol); | 448 | var deleteAction2 = new DeleteAction(activationSymbol); |
@@ -462,14 +461,14 @@ public class ActionEqualsTest { | |||
462 | action2.add(deleteAction2); | 461 | action2.add(deleteAction2); |
463 | action2.prepare(model); | 462 | action2.prepare(model); |
464 | 463 | ||
465 | assertEquals(action1, action2); | 464 | assertTrue(action1.equalsWithSubstitution(action2)); |
466 | } | 465 | } |
467 | 466 | ||
468 | @Test | 467 | @Test |
469 | void deleteActionSymbolTypeTest() { | 468 | void deleteActionSymbolTypeTest() { |
470 | var newItemSymbol = new NewItemSymbol(); | 469 | var newItemSymbol = new NewItemVariable(); |
471 | var activationSymbol = new ActivationSymbol(0); | 470 | var activationSymbol = new ActivationVariable(0); |
472 | var insertAction = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol, | 471 | var insertAction = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol, |
473 | activationSymbol); | 472 | activationSymbol); |
474 | var deleteAction1 = new DeleteAction(activationSymbol); | 473 | var deleteAction1 = new DeleteAction(activationSymbol); |
475 | var deleteAction2 = new DeleteAction(newItemSymbol); | 474 | var deleteAction2 = new DeleteAction(newItemSymbol); |
@@ -488,14 +487,14 @@ public class ActionEqualsTest { | |||
488 | action2.add(deleteAction2); | 487 | action2.add(deleteAction2); |
489 | action2.prepare(model); | 488 | action2.prepare(model); |
490 | 489 | ||
491 | assertNotEquals(action1, action2); | 490 | assertFalse(action1.equalsWithSubstitution(action2)); |
492 | } | 491 | } |
493 | 492 | ||
494 | @Test | 493 | @Test |
495 | void deleteActionOrderTest() { | 494 | void deleteActionOrderTest() { |
496 | var newItemSymbol = new NewItemSymbol(); | 495 | var newItemSymbol = new NewItemVariable(); |
497 | var activationSymbol = new ActivationSymbol(0); | 496 | var activationSymbol = new ActivationVariable(0); |
498 | var insertAction = new InsertAction<>(model.getInterpretation(type1), false, newItemSymbol, | 497 | var insertAction = new InsertAction<>(model.getInterpretation(relation1), false, newItemSymbol, |
499 | activationSymbol); | 498 | activationSymbol); |
500 | var deleteAction1 = new DeleteAction(activationSymbol); | 499 | var deleteAction1 = new DeleteAction(activationSymbol); |
501 | var deleteAction2 = new DeleteAction(newItemSymbol); | 500 | var deleteAction2 = new DeleteAction(newItemSymbol); |
@@ -516,20 +515,20 @@ public class ActionEqualsTest { | |||
516 | action2.add(deleteAction1); | 515 | action2.add(deleteAction1); |
517 | action2.prepare(model); | 516 | action2.prepare(model); |
518 | 517 | ||
519 | assertNotEquals(action1, action2); | 518 | assertFalse(action1.equalsWithSubstitution(action2)); |
520 | } | 519 | } |
521 | 520 | ||
522 | @Test | 521 | @Test |
523 | void actionsMixedOrderTest() { | 522 | void actionsMixedOrderTest() { |
524 | var newItemSymbol1 = new NewItemSymbol(); | 523 | var newItemSymbol1 = new NewItemVariable(); |
525 | var activationSymbol1 = new ActivationSymbol(); | 524 | var activationSymbol1 = new ActivationVariable(); |
526 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 525 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
527 | activationSymbol1); | 526 | activationSymbol1); |
528 | var deleteAction1 = new DeleteAction(newItemSymbol1); | 527 | var deleteAction1 = new DeleteAction(newItemSymbol1); |
529 | 528 | ||
530 | var newItemSymbol2 = new NewItemSymbol(); | 529 | var newItemSymbol2 = new NewItemVariable(); |
531 | var activationSymbol2 = new ActivationSymbol(); | 530 | var activationSymbol2 = new ActivationVariable(); |
532 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | 531 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
533 | activationSymbol2); | 532 | activationSymbol2); |
534 | var deleteAction2 = new DeleteAction(activationSymbol2); | 533 | var deleteAction2 = new DeleteAction(activationSymbol2); |
535 | 534 | ||
@@ -555,20 +554,20 @@ public class ActionEqualsTest { | |||
555 | action2.add(activationSymbol2); | 554 | action2.add(activationSymbol2); |
556 | action2.prepare(model); | 555 | action2.prepare(model); |
557 | 556 | ||
558 | assertEquals(action1, action2); | 557 | assertTrue(action1.equalsWithSubstitution(action2)); |
559 | } | 558 | } |
560 | 559 | ||
561 | @Test | 560 | @Test |
562 | void twoUnpreparedActionsTest() { | 561 | void twoUnpreparedActionsTest() { |
563 | var newItemSymbol1 = new NewItemSymbol(); | 562 | var newItemSymbol1 = new NewItemVariable(); |
564 | var activationSymbol1 = new ActivationSymbol(); | 563 | var activationSymbol1 = new ActivationVariable(); |
565 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 564 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
566 | activationSymbol1); | 565 | activationSymbol1); |
567 | var deleteAction1 = new DeleteAction(newItemSymbol1); | 566 | var deleteAction1 = new DeleteAction(newItemSymbol1); |
568 | 567 | ||
569 | var newItemSymbol2 = new NewItemSymbol(); | 568 | var newItemSymbol2 = new NewItemVariable(); |
570 | var activationSymbol2 = new ActivationSymbol(); | 569 | var activationSymbol2 = new ActivationVariable(); |
571 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | 570 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
572 | activationSymbol2); | 571 | activationSymbol2); |
573 | var deleteAction2 = new DeleteAction(activationSymbol2); | 572 | var deleteAction2 = new DeleteAction(activationSymbol2); |
574 | 573 | ||
@@ -592,20 +591,20 @@ public class ActionEqualsTest { | |||
592 | action2.add(insertAction2); | 591 | action2.add(insertAction2); |
593 | action2.add(activationSymbol2); | 592 | action2.add(activationSymbol2); |
594 | 593 | ||
595 | assertEquals(action1, action2); | 594 | assertTrue(action1.equalsWithSubstitution(action2)); |
596 | } | 595 | } |
597 | 596 | ||
598 | @Test | 597 | @Test |
599 | void oneUnpreparedActionTest() { | 598 | void oneUnpreparedActionTest() { |
600 | var newItemSymbol1 = new NewItemSymbol(); | 599 | var newItemSymbol1 = new NewItemVariable(); |
601 | var activationSymbol1 = new ActivationSymbol(); | 600 | var activationSymbol1 = new ActivationVariable(); |
602 | var insertAction1 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol1, | 601 | var insertAction1 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol1, |
603 | activationSymbol1); | 602 | activationSymbol1); |
604 | var deleteAction1 = new DeleteAction(newItemSymbol1); | 603 | var deleteAction1 = new DeleteAction(newItemSymbol1); |
605 | 604 | ||
606 | var newItemSymbol2 = new NewItemSymbol(); | 605 | var newItemSymbol2 = new NewItemVariable(); |
607 | var activationSymbol2 = new ActivationSymbol(); | 606 | var activationSymbol2 = new ActivationVariable(); |
608 | var insertAction2 = new InsertAction<>(model.getInterpretation(type1), true, newItemSymbol2, | 607 | var insertAction2 = new InsertAction<>(model.getInterpretation(relation1), true, newItemSymbol2, |
609 | activationSymbol2); | 608 | activationSymbol2); |
610 | var deleteAction2 = new DeleteAction(activationSymbol2); | 609 | var deleteAction2 = new DeleteAction(activationSymbol2); |
611 | 610 | ||
@@ -630,6 +629,6 @@ public class ActionEqualsTest { | |||
630 | action2.add(insertAction2); | 629 | action2.add(insertAction2); |
631 | action2.add(activationSymbol2); | 630 | action2.add(activationSymbol2); |
632 | 631 | ||
633 | assertNotEquals(action1, action2); | 632 | assertFalse(action1.equalsWithSubstitution(action2)); |
634 | } | 633 | } |
635 | } | 634 | } |