@@ -43,7 +43,7 @@ class NullCheckingNodePropertiesTest {
43
43
@ Test
44
44
void shouldWrapDoubleArrayPropertyAccess () {
45
45
var props = new DoubleArrayTestProperties (nodeId -> new double []{nodeId });
46
- var wrappedProps = new NullCheckingNodeProperties (props , "propertyName" , graph );
46
+ var wrappedProps = NullCheckingNodeProperties . create (props , "propertyName" , graph );
47
47
graph .forEachNode (nodeId -> {
48
48
assertThat (wrappedProps .doubleArrayValue (nodeId ))
49
49
.isEqualTo (props .doubleArrayValue (nodeId ));
@@ -55,7 +55,7 @@ void shouldWrapDoubleArrayPropertyAccess() {
55
55
@ Test
56
56
void shouldWrapFloatArrayPropertyAccess () {
57
57
var props = new FloatArrayTestProperties (nodeId -> new float []{nodeId });
58
- var wrappedProps = new NullCheckingNodeProperties (props , "propertyName" , graph );
58
+ var wrappedProps = NullCheckingNodeProperties . create (props , "propertyName" , graph );
59
59
graph .forEachNode (nodeId -> {
60
60
assertThat (wrappedProps .floatArrayValue (nodeId ))
61
61
.isEqualTo (props .floatArrayValue (nodeId ));
@@ -67,7 +67,7 @@ void shouldWrapFloatArrayPropertyAccess() {
67
67
@ Test
68
68
void shouldWrapLongArrayPropertyAccess () {
69
69
var props = new LongArrayTestProperties (nodeId -> new long []{nodeId });
70
- var wrappedProps = new NullCheckingNodeProperties (props , "propertyName" , graph );
70
+ var wrappedProps = NullCheckingNodeProperties . create (props , "propertyName" , graph );
71
71
graph .forEachNode (nodeId -> {
72
72
assertThat (wrappedProps .longArrayValue (nodeId ))
73
73
.isEqualTo (props .longArrayValue (nodeId ));
@@ -79,7 +79,7 @@ void shouldWrapLongArrayPropertyAccess() {
79
79
@ Test
80
80
void shouldThrowUsefullyForNullDoubleArrayValues () {
81
81
var nullProps = new DoubleArrayTestProperties (nodeId -> null );
82
- var nonNullProps = new NullCheckingNodeProperties (nullProps , "propertyName" , graph );
82
+ var nonNullProps = NullCheckingNodeProperties . create (nullProps , "propertyName" , graph );
83
83
assertThatThrownBy (() -> nonNullProps .doubleArrayValue (1 ))
84
84
.isInstanceOf (IllegalArgumentException .class )
85
85
.hasMessageContaining ("Missing `List of Float` node property `propertyName` for node with id `1`." );
@@ -88,7 +88,7 @@ void shouldThrowUsefullyForNullDoubleArrayValues() {
88
88
@ Test
89
89
void shouldThrowUsefullyForNullFloatArrayValues () {
90
90
var nullProps = new FloatArrayTestProperties (nodeId -> null );
91
- var nonNullProps = new NullCheckingNodeProperties (nullProps , "propertyName" , graph );
91
+ var nonNullProps = NullCheckingNodeProperties . create (nullProps , "propertyName" , graph );
92
92
assertThatThrownBy (() -> nonNullProps .floatArrayValue (1 ))
93
93
.isInstanceOf (IllegalArgumentException .class )
94
94
.hasMessageContaining ("Missing `List of Float` node property `propertyName` for node with id `1`." );
@@ -97,9 +97,18 @@ void shouldThrowUsefullyForNullFloatArrayValues() {
97
97
@ Test
98
98
void shouldThrowUsefullyForNullLongArrayValues () {
99
99
var nullProps = new LongArrayTestProperties (nodeId -> null );
100
- var nonNullProps = new NullCheckingNodeProperties (nullProps , "propertyName" , graph );
100
+ var nonNullProps = NullCheckingNodeProperties . create (nullProps , "propertyName" , graph );
101
101
assertThatThrownBy (() -> nonNullProps .longArrayValue (1 ))
102
102
.isInstanceOf (IllegalArgumentException .class )
103
103
.hasMessageContaining ("Missing `List of Integer` node property `propertyName` for node with id `1`." );
104
104
}
105
+
106
+ @ Test
107
+ void shouldThrowNormallyIfTheWrongPropertyIsAccessed () {
108
+ var longProps = new LongArrayTestProperties (i -> new long []{i });
109
+ var wrappedProps = NullCheckingNodeProperties .create (longProps , "propertyName" , graph );
110
+ assertThatThrownBy (() -> wrappedProps .doubleArrayValue (0 ))
111
+ .isInstanceOf (UnsupportedOperationException .class )
112
+ .hasMessage ("Tried to retrieve a value of type DOUBLE_ARRAY value from properties of type LONG_ARRAY" );
113
+ }
105
114
}
0 commit comments