aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-10 17:25:24 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-10 17:25:24 +0100
commitfbd2f59a86d8dbd54dae50ca3c3e27d0642d5806 (patch)
tree8430a24c3cdfaf9f07035a56f584055f1e65e8e4 /subprojects
parentfeat(web): backend URL configuration (diff)
downloadrefinery-fbd2f59a86d8dbd54dae50ca3c3e27d0642d5806.tar.gz
refinery-fbd2f59a86d8dbd54dae50ca3c3e27d0642d5806.tar.zst
refinery-fbd2f59a86d8dbd54dae50ca3c3e27d0642d5806.zip
feat(store): DataRepresentation reflective type
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java3
-rw-r--r--subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java48
-rw-r--r--subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java4
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/model/representation/AuxiliaryData.java5
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/model/representation/DataRepresentation.java16
-rw-r--r--subprojects/store/src/main/java/tools/refinery/store/model/representation/Relation.java6
-rw-r--r--subprojects/store/src/test/java/tools/refinery/store/model/tests/ModelTest.java50
7 files changed, 72 insertions, 60 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java
index 0378983c..233cc156 100644
--- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java
+++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/model/ModelInitializer.java
@@ -39,7 +39,8 @@ public class ModelInitializer {
39 var isEqualsRelation = relation == builtinSymbols.equals(); 39 var isEqualsRelation = relation == builtinSymbols.equals();
40 var decisionTree = mergeAssertions(relationInfo, isEqualsRelation); 40 var decisionTree = mergeAssertions(relationInfo, isEqualsRelation);
41 var defaultValue = isEqualsRelation ? TruthValue.FALSE : TruthValue.UNKNOWN; 41 var defaultValue = isEqualsRelation ? TruthValue.FALSE : TruthValue.UNKNOWN;
42 relationTrace.put(relation, new Relation<>(relationInfo.name(), relationInfo.arity(), defaultValue)); 42 relationTrace.put(relation, new Relation<>(relationInfo.name(), relationInfo.arity(), TruthValue.class, defaultValue
43 ));
43 } 44 }
44 } 45 }
45 46
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java
index ea92b223..a7e09023 100644
--- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java
+++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTest.java
@@ -20,8 +20,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
20class QueryTest { 20class QueryTest {
21 @Test 21 @Test
22 void typeConstraintTest() { 22 void typeConstraintTest() {
23 Relation<Boolean> person = new Relation<>("Person", 1, false); 23 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
24 Relation<Boolean> asset = new Relation<>("Asset", 1, false); 24 Relation<Boolean> asset = new Relation<>("Asset", 1, Boolean.class, false);
25 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 25 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
26 26
27 var p1 = new Variable("p1"); 27 var p1 = new Variable("p1");
@@ -46,8 +46,8 @@ class QueryTest {
46 46
47 @Test 47 @Test
48 void relationConstraintTest() { 48 void relationConstraintTest() {
49 Relation<Boolean> person = new Relation<>("Person", 1, false); 49 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
50 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 50 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
51 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 51 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
52 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 52 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
53 TruthValue::must); 53 TruthValue::must);
@@ -85,8 +85,8 @@ class QueryTest {
85 85
86 @Test 86 @Test
87 void andTest() { 87 void andTest() {
88 Relation<Boolean> person = new Relation<>("Person", 1, false); 88 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
89 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 89 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
90 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 90 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
91 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 91 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
92 TruthValue::must); 92 TruthValue::must);
@@ -133,8 +133,8 @@ class QueryTest {
133 133
134 @Test 134 @Test
135 void existTest() { 135 void existTest() {
136 Relation<Boolean> person = new Relation<>("Person", 1, false); 136 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
137 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 137 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
138 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 138 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
139 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 139 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
140 TruthValue::must); 140 TruthValue::must);
@@ -172,9 +172,9 @@ class QueryTest {
172 172
173 @Test 173 @Test
174 void orTest() { 174 void orTest() {
175 Relation<Boolean> person = new Relation<>("Person", 1, false); 175 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
176 Relation<Boolean> animal = new Relation<>("Animal", 1, false); 176 Relation<Boolean> animal = new Relation<>("Animal", 1, Boolean.class, false);
177 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 177 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
178 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 178 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
179 RelationView<Boolean> animalView = new KeyOnlyRelationView(animal); 179 RelationView<Boolean> animalView = new KeyOnlyRelationView(animal);
180 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 180 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
@@ -216,7 +216,7 @@ class QueryTest {
216 216
217 @Test 217 @Test
218 void equalityTest() { 218 void equalityTest() {
219 Relation<Boolean> person = new Relation<>("Person", 1, false); 219 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
220 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 220 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
221 221
222 Variable p1 = new Variable("p1"); 222 Variable p1 = new Variable("p1");
@@ -244,8 +244,8 @@ class QueryTest {
244 244
245 @Test 245 @Test
246 void inequalityTest() { 246 void inequalityTest() {
247 Relation<Boolean> person = new Relation<>("Person", 1, false); 247 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
248 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 248 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
249 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 249 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
250 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 250 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
251 TruthValue::must); 251 TruthValue::must);
@@ -281,8 +281,8 @@ class QueryTest {
281 281
282 @Test 282 @Test
283 void patternCallTest() { 283 void patternCallTest() {
284 Relation<Boolean> person = new Relation<>("Person", 1, false); 284 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
285 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 285 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
286 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 286 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
287 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 287 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
288 TruthValue::must); 288 TruthValue::must);
@@ -327,8 +327,8 @@ class QueryTest {
327 327
328 @Test 328 @Test
329 void negativePatternCallTest() { 329 void negativePatternCallTest() {
330 Relation<Boolean> person = new Relation<>("Person", 1, false); 330 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
331 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 331 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
332 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 332 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
333 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 333 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
334 TruthValue::must); 334 TruthValue::must);
@@ -372,8 +372,8 @@ class QueryTest {
372 372
373 @Test 373 @Test
374 void negativeWithQuantificationTest() { 374 void negativeWithQuantificationTest() {
375 Relation<Boolean> person = new Relation<>("Person", 1, false); 375 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
376 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 376 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
377 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 377 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
378 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 378 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
379 TruthValue::must); 379 TruthValue::must);
@@ -414,8 +414,8 @@ class QueryTest {
414 414
415 @Test 415 @Test
416 void transitivePatternCallTest() { 416 void transitivePatternCallTest() {
417 Relation<Boolean> person = new Relation<>("Person", 1, false); 417 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
418 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 418 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
419 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 419 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
420 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 420 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
421 TruthValue::must); 421 TruthValue::must);
@@ -458,8 +458,8 @@ class QueryTest {
458 458
459 @Test 459 @Test
460 void countMatchTest() { 460 void countMatchTest() {
461 Relation<Boolean> person = new Relation<>("Person", 1, false); 461 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
462 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.FALSE); 462 Relation<TruthValue> friend = new Relation<>("friend", 2, TruthValue.class, TruthValue.FALSE);
463 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 463 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
464 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must", 464 RelationView<TruthValue> friendMustView = new FilteredRelationView<>(friend, "must",
465 TruthValue::must); 465 TruthValue::must);
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java
index a555f024..117edd3e 100644
--- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java
+++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/tests/QueryTransactionTest.java
@@ -19,8 +19,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
19class QueryTransactionTest { 19class QueryTransactionTest {
20 @Test 20 @Test
21 void flushTest() { 21 void flushTest() {
22 Relation<Boolean> person = new Relation<>("Person", 1, false); 22 Relation<Boolean> person = new Relation<>("Person", 1, Boolean.class, false);
23 Relation<Boolean> asset = new Relation<>("Asset", 1, false); 23 Relation<Boolean> asset = new Relation<>("Asset", 1, Boolean.class, false);
24 RelationView<Boolean> personView = new KeyOnlyRelationView(person); 24 RelationView<Boolean> personView = new KeyOnlyRelationView(person);
25 25
26 var p1 = new Variable("p1"); 26 var p1 = new Variable("p1");
diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/representation/AuxiliaryData.java b/subprojects/store/src/main/java/tools/refinery/store/model/representation/AuxiliaryData.java
index 1a968f50..18c38151 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/model/representation/AuxiliaryData.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/model/representation/AuxiliaryData.java
@@ -5,8 +5,9 @@ import tools.refinery.store.map.ContinousHashProvider;
5public final class AuxiliaryData<K, V> extends DataRepresentation<K, V> { 5public final class AuxiliaryData<K, V> extends DataRepresentation<K, V> {
6 private final ContinousHashProvider<K> hashProvider; 6 private final ContinousHashProvider<K> hashProvider;
7 7
8 public AuxiliaryData(String name, ContinousHashProvider<K> hashProvider, V defaultValue) { 8 public AuxiliaryData(String name, Class<K> keyType, ContinousHashProvider<K> hashProvider, Class<V> valueType,
9 super(name, defaultValue); 9 V defaultValue) {
10 super(name, keyType, valueType, defaultValue);
10 this.hashProvider = hashProvider; 11 this.hashProvider = hashProvider;
11 } 12 }
12 13
diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/representation/DataRepresentation.java b/subprojects/store/src/main/java/tools/refinery/store/model/representation/DataRepresentation.java
index 49f74717..61c6291b 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/model/representation/DataRepresentation.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/model/representation/DataRepresentation.java
@@ -7,9 +7,15 @@ public abstract sealed class DataRepresentation<K, V> permits Relation, Auxiliar
7 7
8 private final V defaultValue; 8 private final V defaultValue;
9 9
10 protected DataRepresentation(String name, V defaultValue) { 10 private final Class<K> keyType;
11
12 private final Class<V> valueType;
13
14 protected DataRepresentation(String name, Class<K> keyType, Class<V> valueType, V defaultValue) {
11 this.name = name; 15 this.name = name;
12 this.defaultValue = defaultValue; 16 this.defaultValue = defaultValue;
17 this.keyType = keyType;
18 this.valueType = valueType;
13 } 19 }
14 20
15 public String getName() { 21 public String getName() {
@@ -23,4 +29,12 @@ public abstract sealed class DataRepresentation<K, V> permits Relation, Auxiliar
23 public V getDefaultValue() { 29 public V getDefaultValue() {
24 return defaultValue; 30 return defaultValue;
25 } 31 }
32
33 public Class<K> getKeyType() {
34 return keyType;
35 }
36
37 public Class<V> getValueType() {
38 return valueType;
39 }
26} 40}
diff --git a/subprojects/store/src/main/java/tools/refinery/store/model/representation/Relation.java b/subprojects/store/src/main/java/tools/refinery/store/model/representation/Relation.java
index 2e21ea37..cc32257c 100644
--- a/subprojects/store/src/main/java/tools/refinery/store/model/representation/Relation.java
+++ b/subprojects/store/src/main/java/tools/refinery/store/model/representation/Relation.java
@@ -2,14 +2,14 @@ package tools.refinery.store.model.representation;
2 2
3import tools.refinery.store.map.ContinousHashProvider; 3import tools.refinery.store.map.ContinousHashProvider;
4import tools.refinery.store.model.RelationLike; 4import tools.refinery.store.model.RelationLike;
5import tools.refinery.store.tuple.Tuple;
6import tools.refinery.store.model.TupleHashProvider; 5import tools.refinery.store.model.TupleHashProvider;
6import tools.refinery.store.tuple.Tuple;
7 7
8public final class Relation<D> extends DataRepresentation<Tuple, D> implements RelationLike { 8public final class Relation<D> extends DataRepresentation<Tuple, D> implements RelationLike {
9 private final int arity; 9 private final int arity;
10 10
11 public Relation(String name, int arity, D defaultValue) { 11 public Relation(String name, int arity, Class<D> valueType, D defaultValue) {
12 super(name, defaultValue); 12 super(name, Tuple.class, valueType, defaultValue);
13 this.arity = arity; 13 this.arity = arity;
14 } 14 }
15 15
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 @@
1package tools.refinery.store.model.tests; 1package tools.refinery.store.model.tests;
2 2
3import static org.junit.jupiter.api.Assertions.assertEquals;
4import static org.junit.jupiter.api.Assertions.assertFalse;
5import static org.junit.jupiter.api.Assertions.assertTrue;
6
7import java.util.Set;
8
9import org.junit.jupiter.api.Assertions;
10import org.junit.jupiter.api.Test; 3import org.junit.jupiter.api.Test;
11
12import tools.refinery.store.model.Model; 4import tools.refinery.store.model.Model;
13import tools.refinery.store.model.ModelStore; 5import tools.refinery.store.model.ModelStore;
14import tools.refinery.store.model.ModelStoreImpl; 6import tools.refinery.store.model.ModelStoreImpl;
15import tools.refinery.store.tuple.Tuple;
16import tools.refinery.store.model.representation.Relation; 7import tools.refinery.store.model.representation.Relation;
8import tools.refinery.store.tuple.Tuple;
9
10import java.util.Set;
11
12import static org.junit.jupiter.api.Assertions.*;
17 13
18class ModelTest { 14class 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();