diff options
Diffstat (limited to 'subprojects/store-dse/src/test')
5 files changed, 81 insertions, 7 deletions
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/CRAExamplesTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/CRAExamplesTest.java index 225de32e..b0b416e1 100644 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/CRAExamplesTest.java +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/CRAExamplesTest.java | |||
@@ -8,13 +8,13 @@ package tools.refinery.store.dse; | |||
8 | import org.junit.jupiter.api.Disabled; | 8 | import org.junit.jupiter.api.Disabled; |
9 | import org.junit.jupiter.api.Test; | 9 | import org.junit.jupiter.api.Test; |
10 | import tools.refinery.store.dse.objectives.AlwaysSatisfiedRandomHardObjective; | 10 | import tools.refinery.store.dse.objectives.AlwaysSatisfiedRandomHardObjective; |
11 | import tools.refinery.store.dse.transition.DesignSpaceExplorationAdapter; | ||
11 | import tools.refinery.store.model.ModelStore; | 12 | import tools.refinery.store.model.ModelStore; |
12 | import tools.refinery.store.query.ModelQueryAdapter; | 13 | import tools.refinery.store.query.ModelQueryAdapter; |
13 | import tools.refinery.store.query.dnf.Query; | 14 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.query.dnf.RelationalQuery; | 15 | import tools.refinery.store.query.dnf.RelationalQuery; |
15 | import tools.refinery.store.dse.internal.TransformationRule; | 16 | import tools.refinery.store.dse.transition.TransformationRule; |
16 | import tools.refinery.store.dse.strategy.BestFirstStrategy; | 17 | import tools.refinery.store.dse.strategy.BestFirstStrategy; |
17 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; | ||
18 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; | 18 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; |
19 | import tools.refinery.store.query.view.AnySymbolView; | 19 | import tools.refinery.store.query.view.AnySymbolView; |
20 | import tools.refinery.store.query.view.KeyOnlyView; | 20 | import tools.refinery.store.query.view.KeyOnlyView; |
@@ -282,5 +282,5 @@ class CRAExamplesTest { | |||
282 | var states = dseAdapter.explore(); | 282 | var states = dseAdapter.explore(); |
283 | System.out.println("states size: " + states.size()); | 283 | System.out.println("states size: " + states.size()); |
284 | } | 284 | } |
285 | 285 | */ | |
286 | } | 286 | } |
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DebugTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DebugTest.java index c6da896c..461d9353 100644 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DebugTest.java +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DebugTest.java | |||
@@ -8,11 +8,11 @@ package tools.refinery.store.dse; | |||
8 | import org.junit.jupiter.api.Disabled; | 8 | import org.junit.jupiter.api.Disabled; |
9 | import org.junit.jupiter.api.Test; | 9 | import org.junit.jupiter.api.Test; |
10 | import tools.refinery.store.dse.objectives.AlwaysSatisfiedRandomHardObjective; | 10 | import tools.refinery.store.dse.objectives.AlwaysSatisfiedRandomHardObjective; |
11 | import tools.refinery.store.dse.transition.DesignSpaceExplorationAdapter; | ||
11 | import tools.refinery.store.model.ModelStore; | 12 | import tools.refinery.store.model.ModelStore; |
12 | import tools.refinery.store.query.ModelQueryAdapter; | 13 | import tools.refinery.store.query.ModelQueryAdapter; |
13 | import tools.refinery.store.query.dnf.Query; | 14 | import tools.refinery.store.query.dnf.Query; |
14 | import tools.refinery.store.dse.internal.TransformationRule; | 15 | import tools.refinery.store.dse.transition.TransformationRule; |
15 | import tools.refinery.store.dse.strategy.BestFirstStrategy; | ||
16 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; | 16 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; |
17 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; | 17 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; |
18 | import tools.refinery.store.query.view.AnySymbolView; | 18 | import tools.refinery.store.query.view.AnySymbolView; |
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java index 91e33f4a..083f7ec3 100644 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/DesignSpaceExplorationTest.java | |||
@@ -6,10 +6,11 @@ | |||
6 | package tools.refinery.store.dse; | 6 | package tools.refinery.store.dse; |
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.dse.transition.DesignSpaceExplorationAdapter; | ||
9 | import tools.refinery.store.model.ModelStore; | 10 | import tools.refinery.store.model.ModelStore; |
10 | import tools.refinery.store.query.ModelQueryAdapter; | 11 | import tools.refinery.store.query.ModelQueryAdapter; |
11 | import tools.refinery.store.query.dnf.Query; | 12 | import tools.refinery.store.query.dnf.Query; |
12 | import tools.refinery.store.dse.internal.TransformationRule; | 13 | import tools.refinery.store.dse.transition.TransformationRule; |
13 | import tools.refinery.store.dse.strategy.BestFirstStrategy; | 14 | import tools.refinery.store.dse.strategy.BestFirstStrategy; |
14 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; | 15 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; |
15 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; | 16 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; |
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/TransformationRuleTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/TransformationRuleTest.java index 5d24d712..1672b63a 100644 --- a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/TransformationRuleTest.java +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/TransformationRuleTest.java | |||
@@ -7,10 +7,11 @@ package tools.refinery.store.dse; | |||
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; | 9 | import tools.refinery.store.dse.strategy.DepthFirstStrategy; |
10 | import tools.refinery.store.dse.transition.DesignSpaceExplorationAdapter; | ||
10 | import tools.refinery.store.model.ModelStore; | 11 | import tools.refinery.store.model.ModelStore; |
11 | import tools.refinery.store.query.ModelQueryAdapter; | 12 | import tools.refinery.store.query.ModelQueryAdapter; |
12 | import tools.refinery.store.query.dnf.Query; | 13 | import tools.refinery.store.query.dnf.Query; |
13 | import tools.refinery.store.dse.internal.TransformationRule; | 14 | import tools.refinery.store.dse.transition.TransformationRule; |
14 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; | 15 | import tools.refinery.store.query.viatra.ViatraModelQueryAdapter; |
15 | import tools.refinery.store.query.view.AnySymbolView; | 16 | import tools.refinery.store.query.view.AnySymbolView; |
16 | import tools.refinery.store.query.view.KeyOnlyView; | 17 | import tools.refinery.store.query.view.KeyOnlyView; |
diff --git a/subprojects/store-dse/src/test/java/tools/refinery/store/dse/transition/statespace/internal/ActivationUnitTest.java b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/transition/statespace/internal/ActivationUnitTest.java new file mode 100644 index 00000000..e7960a06 --- /dev/null +++ b/subprojects/store-dse/src/test/java/tools/refinery/store/dse/transition/statespace/internal/ActivationUnitTest.java | |||
@@ -0,0 +1,72 @@ | |||
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.dse.transition.statespace.internal; | ||
7 | |||
8 | import org.junit.jupiter.api.Assertions; | ||
9 | import org.junit.jupiter.params.ParameterizedTest; | ||
10 | import org.junit.jupiter.params.provider.MethodSource; | ||
11 | |||
12 | import java.util.stream.Stream; | ||
13 | |||
14 | class ActivationUnitTest { | ||
15 | private final static int SMALL_SIZE = 5; | ||
16 | |||
17 | private static Stream<ActivationStoreEntry> entries() { | ||
18 | return Stream.of( | ||
19 | new ActivationStoreBitVectorEntry(SMALL_SIZE), | ||
20 | new ActivationStoreListEntry(SMALL_SIZE)); | ||
21 | } | ||
22 | |||
23 | void addTest(ActivationStoreEntry entry, int elementsAdded) { | ||
24 | Assertions.assertEquals(elementsAdded,entry.getNumberOfVisitedActivations()); | ||
25 | Assertions.assertEquals(SMALL_SIZE-elementsAdded,entry.getNumberOfUnvisitedActivations()); | ||
26 | } | ||
27 | |||
28 | @ParameterizedTest | ||
29 | @MethodSource("entries") | ||
30 | void testDifferent(ActivationStoreEntry entry) { | ||
31 | int elementsAdded = 0; | ||
32 | addTest(entry,elementsAdded); | ||
33 | Assertions.assertEquals(2, entry.getAndAddActivationAfter(2)); | ||
34 | addTest(entry,++elementsAdded); | ||
35 | Assertions.assertEquals(3,entry.getAndAddActivationAfter(3)); | ||
36 | addTest(entry,++elementsAdded); | ||
37 | Assertions.assertEquals(1,entry.getAndAddActivationAfter(1)); | ||
38 | addTest(entry,++elementsAdded); | ||
39 | Assertions.assertEquals(4,entry.getAndAddActivationAfter(4)); | ||
40 | addTest(entry,++elementsAdded); | ||
41 | Assertions.assertEquals(0,entry.getAndAddActivationAfter(0)); | ||
42 | addTest(entry,++elementsAdded); | ||
43 | } | ||
44 | |||
45 | @ParameterizedTest | ||
46 | @MethodSource("entries") | ||
47 | void testSame(ActivationStoreEntry entry) { | ||
48 | int elementsAdded = 0; | ||
49 | addTest(entry,elementsAdded); | ||
50 | entry.getAndAddActivationAfter(2); | ||
51 | addTest(entry,++elementsAdded); | ||
52 | entry.getAndAddActivationAfter(2); | ||
53 | addTest(entry,++elementsAdded); | ||
54 | entry.getAndAddActivationAfter(2); | ||
55 | addTest(entry,++elementsAdded); | ||
56 | entry.getAndAddActivationAfter(2); | ||
57 | addTest(entry,++elementsAdded); | ||
58 | entry.getAndAddActivationAfter(2); | ||
59 | addTest(entry,++elementsAdded); | ||
60 | } | ||
61 | |||
62 | @ParameterizedTest | ||
63 | @MethodSource("entries") | ||
64 | void testFilling(ActivationStoreEntry entry) { | ||
65 | int elementsAdded = 0; | ||
66 | while(elementsAdded < SMALL_SIZE) { | ||
67 | entry.getAndAddActivationAfter(2); | ||
68 | elementsAdded++; | ||
69 | } | ||
70 | Assertions.assertThrows(IllegalArgumentException.class,()-> entry.getAndAddActivationAfter(2)); | ||
71 | } | ||
72 | } | ||