+ Switching Comparison from String to JSON (#15364)

This commit is contained in:
Krishna Anandan 2023-11-14 10:07:19 -06:00 committed by GitHub
parent a134cc30a6
commit 5edeac28df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -19,6 +19,7 @@
package org.apache.druid.query.aggregation.histogram;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.query.Druids;
@ -106,14 +107,12 @@ public class ApproximateHistogramAggregatorTest extends InitializedNullHandlingT
ApproximateHistogramAggregator agg = new ApproximateHistogramAggregator(selector, resolution, 0, 100);
agg.aggregate();
Object finalizedObjectHumanReadable = humanReadableFactory.finalizeComputation(agg.get());
String finalStringHumanReadable = objectMapper.writeValueAsString(finalizedObjectHumanReadable);
Assert.assertEquals(
"{\"breaks\":[23.0,23.0,23.0,23.0,23.0,23.0],\"counts\":[0.0,0.0,0.0,0.0,0.0]}",
finalStringHumanReadable
);
JsonNode expectedJson = objectMapper.readTree(
"{\"breaks\":[23.0,23.0,23.0,23.0,23.0,23.0],\"counts\":[0.0,0.0,0.0,0.0,0.0]}");
JsonNode actualJson = objectMapper.readTree(finalStringHumanReadable);
Assert.assertEquals(expectedJson, actualJson);
Object finalizedObjectBinary = binaryFactory.finalizeComputation(agg.get());
String finalStringBinary = objectMapper.writeValueAsString(finalizedObjectBinary);
Assert.assertEquals(