absurdfarce commented on code in PR #2052:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2052#discussion_r2292883925


##########
core/src/test/java/com/datastax/dse/driver/internal/core/data/geometry/DefaultLineStringTest.java:
##########
@@ -101,8 +104,26 @@ public void should_parse_valid_geo_json() {
   }
 
   @Test
-  public void should_convert_to_geo_json() {
-    assertThat(lineString.asGeoJson()).isEqualTo(json);
+  public void should_convert_to_geo_json() throws Exception {
+
+    ObjectMapper mapper = new ObjectMapper();
+    JsonNode root = mapper.readTree(lineString.asGeoJson());
+    assertThat(root.get("type").toString()).isEqualTo("\"LineString\"");
+
+    double expected[][] = {{30.0, 10.0}, {10.0, 30.0}, {40.0, 40.0}};
+    JsonNode coordinatesNode = root.get("coordinates");
+    assertThat(coordinatesNode.isArray()).isTrue();
+    ArrayNode coordinatesArray = (ArrayNode) coordinatesNode;
+    assertThat(coordinatesArray.size()).isEqualTo(3);
+    for (int i = 0; i < expected.length; ++i) {
+
+      JsonNode elemNode = coordinatesArray.get(i);
+      assertThat(elemNode.isArray()).isTrue();
+      ArrayNode elemArray = (ArrayNode) elemNode;
+      assertThat(elemArray.size()).isEqualTo(2);
+      assertThat(elemArray.get(0).asDouble()).isEqualTo(expected[i][0]);
+      assertThat(elemArray.get(1).asDouble()).isEqualTo(expected[i][1]);
+    }

Review Comment:
   Perhaps the most contentious change in the whole PR.  With this code we no 
longer concern ourselves with the format of the GeoJSON returned by ESRI... we 
only seek to confirm that we can find the fields we expect at the places we 
expect them.  Any additional content or formatting isn't our concern.
   
   My rationale is that this is really the heart of the matter.  We don't claim 
to follow a specific GeoJSON spec or that any responses will contain only some 
properties but not any others.  With that in mind our objective _should be_ to 
make sure we don't see any regressions on the props customers actually expect, 
specifically the "type" and "coordinates" fields.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to