diff options
Diffstat (limited to 'subprojects/store/src/test/java')
-rw-r--r-- | subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java b/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java index 61dd7c74..a9c2e3f7 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java | |||
@@ -1,26 +1,22 @@ | |||
1 | package tools.refinery.store.model.tests; | 1 | package tools.refinery.store.model.tests; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.assertEquals; | ||
4 | import static org.junit.jupiter.api.Assertions.assertFalse; | ||
5 | import static org.junit.jupiter.api.Assertions.assertTrue; | ||
6 | |||
7 | import java.util.Set; | ||
8 | |||
9 | import org.junit.jupiter.api.Assertions; | ||
10 | import org.junit.jupiter.api.Test; | 3 | import org.junit.jupiter.api.Test; |
11 | |||
12 | import tools.refinery.store.model.Model; | 4 | import tools.refinery.store.model.Model; |
13 | import tools.refinery.store.model.ModelStore; | 5 | import tools.refinery.store.model.ModelStore; |
14 | import tools.refinery.store.model.ModelStoreImpl; | 6 | import tools.refinery.store.model.ModelStoreImpl; |
15 | import tools.refinery.store.tuple.Tuple; | ||
16 | import tools.refinery.store.model.representation.Relation; | 7 | import tools.refinery.store.model.representation.Relation; |
8 | import tools.refinery.store.tuple.Tuple; | ||
9 | |||
10 | import java.util.Set; | ||
11 | |||
12 | import static org.junit.jupiter.api.Assertions.*; | ||
17 | 13 | ||
18 | class ModelTest { | 14 | class ModelTest { |
19 | 15 | ||
20 | @Test | 16 | @Test |
21 | void modelConstructionTest() { | 17 | void modelConstructionTest() { |
22 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 18 | Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false); |
23 | Relation<Boolean> friend = new Relation<>("friend", 2, false); | 19 | Relation<Boolean> friend = new Relation<>("friend", 2, Boolean.class, false); |
24 | 20 | ||
25 | ModelStore store = new ModelStoreImpl(Set.of(person, friend)); | 21 | ModelStore store = new ModelStoreImpl(Set.of(person, friend)); |
26 | Model model = store.createModel(); | 22 | Model model = store.createModel(); |
@@ -30,15 +26,15 @@ class ModelTest { | |||
30 | assertTrue(model.getDataRepresentations().contains(person)); | 26 | assertTrue(model.getDataRepresentations().contains(person)); |
31 | assertTrue(model.getDataRepresentations().contains(friend)); | 27 | assertTrue(model.getDataRepresentations().contains(friend)); |
32 | 28 | ||
33 | Relation<Integer> other = new Relation<Integer>("other", 2, null); | 29 | Relation<Integer> other = new Relation<Integer>("other", 2, Integer.class, null); |
34 | assertFalse(model.getDataRepresentations().contains(other)); | 30 | assertFalse(model.getDataRepresentations().contains(other)); |
35 | } | 31 | } |
36 | 32 | ||
37 | @Test | 33 | @Test |
38 | void modelBuildingTest() { | 34 | void modelBuildingTest() { |
39 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 35 | Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false); |
40 | Relation<Integer> age = new Relation<Integer>("age", 1, null); | 36 | Relation<Integer> age = new Relation<Integer>("age", 1, Integer.class, null); |
41 | Relation<Boolean> friend = new Relation<>("friend", 2, false); | 37 | Relation<Boolean> friend = new Relation<>("friend", 2, Boolean.class, false); |
42 | 38 | ||
43 | ModelStore store = new ModelStoreImpl(Set.of(person, age, friend)); | 39 | ModelStore store = new ModelStoreImpl(Set.of(person, age, friend)); |
44 | Model model = store.createModel(); | 40 | Model model = store.createModel(); |
@@ -56,7 +52,7 @@ class ModelTest { | |||
56 | 52 | ||
57 | assertEquals(3, model.get(age, Tuple.of(0))); | 53 | assertEquals(3, model.get(age, Tuple.of(0))); |
58 | assertEquals(1, model.get(age, Tuple.of(1))); | 54 | assertEquals(1, model.get(age, Tuple.of(1))); |
59 | assertEquals(null, model.get(age, Tuple.of(2))); | 55 | assertNull(model.get(age, Tuple.of(2))); |
60 | 56 | ||
61 | assertTrue(model.get(friend, Tuple.of(0, 1))); | 57 | assertTrue(model.get(friend, Tuple.of(0, 1))); |
62 | assertFalse(model.get(friend, Tuple.of(0, 5))); | 58 | assertFalse(model.get(friend, Tuple.of(0, 5))); |
@@ -64,32 +60,32 @@ class ModelTest { | |||
64 | 60 | ||
65 | @Test | 61 | @Test |
66 | void modelBuildingArityFailTest() { | 62 | void modelBuildingArityFailTest() { |
67 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 63 | Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false); |
68 | ModelStore store = new ModelStoreImpl(Set.of(person)); | 64 | ModelStore store = new ModelStoreImpl(Set.of(person)); |
69 | Model model = store.createModel(); | 65 | Model model = store.createModel(); |
70 | 66 | ||
71 | final Tuple tuple3 = Tuple.of(1, 1, 1); | 67 | final Tuple tuple3 = Tuple.of(1, 1, 1); |
72 | Assertions.assertThrows(IllegalArgumentException.class, () -> model.put(person, tuple3, true)); | 68 | assertThrows(IllegalArgumentException.class, () -> model.put(person, tuple3, true)); |
73 | Assertions.assertThrows(IllegalArgumentException.class, () -> model.get(person, tuple3)); | 69 | assertThrows(IllegalArgumentException.class, () -> model.get(person, tuple3)); |
74 | } | 70 | } |
75 | 71 | ||
76 | @Test | 72 | @Test |
77 | void modelBuildingNullFailTest() { | 73 | void modelBuildingNullFailTest() { |
78 | Relation<Integer> age = new Relation<Integer>("age", 1, null); | 74 | Relation<Integer> age = new Relation<Integer>("age", 1, Integer.class, null); |
79 | ModelStore store = new ModelStoreImpl(Set.of(age)); | 75 | ModelStore store = new ModelStoreImpl(Set.of(age)); |
80 | Model model = store.createModel(); | 76 | Model model = store.createModel(); |
81 | 77 | ||
82 | model.put(age, Tuple.of(1), null); // valid | 78 | model.put(age, Tuple.of(1), null); // valid |
83 | Assertions.assertThrows(IllegalArgumentException.class, () -> model.put(age, null, 1)); | 79 | assertThrows(IllegalArgumentException.class, () -> model.put(age, null, 1)); |
84 | Assertions.assertThrows(IllegalArgumentException.class, () -> model.get(age, null)); | 80 | assertThrows(IllegalArgumentException.class, () -> model.get(age, null)); |
85 | 81 | ||
86 | } | 82 | } |
87 | 83 | ||
88 | @Test | 84 | @Test |
89 | void modelUpdateTest() { | 85 | void modelUpdateTest() { |
90 | Relation<Boolean> person = new Relation<>("Person", 1, false); | 86 | Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false); |
91 | Relation<Integer> age = new Relation<Integer>("age", 1, null); | 87 | Relation<Integer> age = new Relation<Integer>("age", 1, Integer.class, null); |
92 | Relation<Boolean> friend = new Relation<>("friend", 2, false); | 88 | Relation<Boolean> friend = new Relation<>("friend", 2, Boolean.class, false); |
93 | 89 | ||
94 | ModelStore store = new ModelStoreImpl(Set.of(person, age, friend)); | 90 | ModelStore store = new ModelStoreImpl(Set.of(person, age, friend)); |
95 | Model model = store.createModel(); | 91 | Model model = store.createModel(); |
@@ -113,8 +109,8 @@ class ModelTest { | |||
113 | 109 | ||
114 | @Test | 110 | @Test |
115 | void restoreTest() { | 111 | void restoreTest() { |
116 | Relation<Boolean> person = new Relation<Boolean>("Person", 1, false); | 112 | Relation<Boolean> person = new Relation<Boolean>("Person", 1, Boolean.class, false); |
117 | Relation<Boolean> friend = new Relation<Boolean>("friend", 2, false); | 113 | Relation<Boolean> friend = new Relation<Boolean>("friend", 2, Boolean.class, false); |
118 | 114 | ||
119 | ModelStore store = new ModelStoreImpl(Set.of(person, friend)); | 115 | ModelStore store = new ModelStoreImpl(Set.of(person, friend)); |
120 | Model model = store.createModel(); | 116 | Model model = store.createModel(); |