@@ -26,9 +26,9 @@ class JSONUtilsTest {
26
26
@Test
27
27
fun `should serialize Geometry and Temporal Data Types` () {
28
28
// Given
29
- val expected = " {\" point2dCartesian\" :{\" crs\" :\" cartesian\" ,\" x\" :1.0,\" y\" :2.0, \" z \" :null }," +
29
+ val expected = " {\" point2dCartesian\" :{\" crs\" :\" cartesian\" ,\" x\" :1.0,\" y\" :2.0}," +
30
30
" \" point3dCartesian\" :{\" crs\" :\" cartesian-3d\" ,\" x\" :1.0,\" y\" :2.0,\" z\" :3.0}," +
31
- " \" point2dWgs84\" :{\" crs\" :\" wgs-84\" ,\" latitude\" :1.0,\" longitude\" :2.0, \" height \" :null }," +
31
+ " \" point2dWgs84\" :{\" crs\" :\" wgs-84\" ,\" latitude\" :1.0,\" longitude\" :2.0}," +
32
32
" \" point3dWgs84\" :{\" crs\" :\" wgs-84-3d\" ,\" latitude\" :1.0,\" longitude\" :2.0,\" height\" :3.0}," +
33
33
" \" time\" :\" 14:00:00Z\" ,\" dateTime\" :\" 2017-12-17T17:14:35.123456789Z\" }"
34
34
val map = linkedMapOf<String , Any >(" point2dCartesian" to pointValue(Cartesian , 1.0 , 2.0 ),
@@ -48,9 +48,9 @@ class JSONUtilsTest {
48
48
@Test
49
49
fun `should serialize driver Point Data Types` () {
50
50
// Given
51
- val expected = " {\" point2dCartesian\" :{\" crs\" :\" cartesian\" ,\" x\" :1.0,\" y\" :2.0, \" z \" :null }," +
51
+ val expected = " {\" point2dCartesian\" :{\" crs\" :\" cartesian\" ,\" x\" :1.0,\" y\" :2.0}," +
52
52
" \" point3dCartesian\" :{\" crs\" :\" cartesian-3d\" ,\" x\" :1.0,\" y\" :2.0,\" z\" :3.0}," +
53
- " \" point2dWgs84\" :{\" crs\" :\" wgs-84\" ,\" latitude\" :1.0,\" longitude\" :2.0, \" height \" :null }," +
53
+ " \" point2dWgs84\" :{\" crs\" :\" wgs-84\" ,\" latitude\" :1.0,\" longitude\" :2.0}," +
54
54
" \" point3dWgs84\" :{\" crs\" :\" wgs-84-3d\" ,\" latitude\" :1.0,\" longitude\" :2.0,\" height\" :3.0}," +
55
55
" \" time\" :\" 14:00:00Z\" ,\" dateTime\" :\" 2017-12-17T17:14:35.123456789Z\" }"
56
56
val map = linkedMapOf<String , Any >(" point2dCartesian" to pointValue(Cartesian , 1.0 , 2.0 ),
@@ -111,6 +111,81 @@ class JSONUtilsTest {
111
111
assertEquals(cdcData, fromString)
112
112
}
113
113
114
+ @Test
115
+ fun `should convert wgs2D with height null to PointValue` () {
116
+ // given
117
+ val timestamp = System .currentTimeMillis()
118
+
119
+ val expected = org.neo4j.values.storable.PointValue .fromMap(mapOf (" crs" to " wgs-84" , " latitude" to 12.78 , " longitude" to 56.7 ).toMapValue())
120
+
121
+ val cdcMap = mapOf<String , Any >(
122
+ " meta" to mapOf (" timestamp" to timestamp,
123
+ " username" to " user" ,
124
+ " txId" to 1 ,
125
+ " txEventId" to 0 ,
126
+ " txEventsCount" to 1 ,
127
+ " operation" to OperationType .created),
128
+ " payload" to mapOf (" id" to " 0" ,
129
+ " before" to null ,
130
+ " after" to NodeChange (properties = mapOf (" location" to mapOf (" crs" to " wgs-84" , " latitude" to 12.78 , " longitude" to 56.7 , " height" to null )),
131
+ labels = listOf (" LabelCDC" )),
132
+ " type" to EntityType .node),
133
+ " schema" to mapOf (" properties" to mapOf (" location" to " PointValue" ))
134
+ )
135
+
136
+ val cdcString = """ {
137
+ |"meta":{"timestamp":$timestamp ,"username":"user","txId":1,"txEventId":0,"txEventsCount":1,"operation":"created"},
138
+ |"payload":{"id":"0","before":null,"after":{"properties":{"location":{"crs":"wgs-84","latitude":12.78,"longitude":56.7,"height":null}},
139
+ |"labels":["LabelCDC"]},"type":"node"},
140
+ |"schema":{"properties":{"location":"PointValue"}}
141
+ |}""" .trimMargin()
142
+
143
+ val fromMap = JSONUtils .asStreamsTransactionEvent(cdcMap)
144
+ val fromMapPointValue = fromMap.payload.after?.properties?.get(" location" ) as org.neo4j.values.storable.PointValue
145
+ assertEquals(expected, fromMapPointValue)
146
+
147
+ val fromString = JSONUtils .asStreamsTransactionEvent(cdcString)
148
+ val fromStringPointValue = fromString.payload.after?.properties?.get(" location" ) as org.neo4j.values.storable.PointValue
149
+ assertEquals(expected, fromStringPointValue)
150
+ }
151
+
152
+ @Test
153
+ fun `should convert cartesian2D with z null to PointValue` () {
154
+ // given
155
+ val timestamp = System .currentTimeMillis()
156
+ val expected = org.neo4j.values.storable.PointValue .fromMap(mapOf (" crs" to " cartesian" , " x" to 12.78 , " y" to 56.7 ).toMapValue())
157
+
158
+ val cdcMap = mapOf<String , Any >(
159
+ " meta" to mapOf (" timestamp" to timestamp,
160
+ " username" to " user" ,
161
+ " txId" to 1 ,
162
+ " txEventId" to 0 ,
163
+ " txEventsCount" to 1 ,
164
+ " operation" to OperationType .created),
165
+ " payload" to mapOf (" id" to " 0" ,
166
+ " before" to null ,
167
+ " after" to NodeChange (properties = mapOf (" location" to mapOf (" crs" to " cartesian" , " x" to 12.78 , " y" to 56.7 , " z" to null )),
168
+ labels = listOf (" LabelCDC" )),
169
+ " type" to EntityType .node),
170
+ " schema" to mapOf (" properties" to mapOf (" location" to " PointValue" ))
171
+ )
172
+
173
+ val cdcString = """ {
174
+ |"meta":{"timestamp":$timestamp ,"username":"user","txId":1,"txEventId":0,"txEventsCount":1,"operation":"created"},
175
+ |"payload":{"id":"0","before":null,"after":{"properties":{"location":{"crs":"cartesian","x":12.78,"y":56.7,"z":null}},
176
+ |"labels":["LabelCDC"]},"type":"node"},
177
+ |"schema":{"properties":{"location":"PointValue"}}
178
+ |}""" .trimMargin()
179
+
180
+ val fromMap = JSONUtils .asStreamsTransactionEvent(cdcMap)
181
+ val fromMapPointValue = fromMap.payload.after?.properties?.get(" location" ) as org.neo4j.values.storable.PointValue
182
+ assertEquals(expected, fromMapPointValue)
183
+
184
+ val fromString = JSONUtils .asStreamsTransactionEvent(cdcString)
185
+ val fromStringPointValue = fromString.payload.after?.properties?.get(" location" ) as org.neo4j.values.storable.PointValue
186
+ assertEquals(expected, fromStringPointValue)
187
+ }
188
+
114
189
@Test
115
190
fun `should deserialize plain values` () {
116
191
assertEquals(" a" , JSONUtils .readValue(" a" , stringWhenFailure = true ))
0 commit comments