absurdfarce commented on code in PR #2052:
URL:
https://github.com/apache/cassandra-java-driver/pull/2052#discussion_r2688672658
##########
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");
Review Comment:
I suppose we _could_ but I question how much benefit we'd get out of it. I
think this test is really the only one that does this sequence of comparing
size of two and then comparing each element individually.
That said, that comparison is pretty verbose. We can replace this with the
following which may be preferred:
```java
for (int i = 0; i < expected.length; ++i) {
JsonNode elemNode = coordinatesArray.get(i);
assertThat(elemNode.isArray()).isTrue();
ArrayNode elemArray = (ArrayNode) elemNode;
double[] arr =
Streams.stream(elemArray.elements())
.mapToDouble(JsonNode::asDouble)
.toArray();
assertThat(arr).isEqualTo(expected[i]);
}
```
Do you like that better? I kinda do... it seems clearer to me without
adding much verbosity.
--
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]