Skip to content

Commit

Permalink
+ Switching Comparison from String to JSON (apache#15364)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnanand5 authored Nov 14, 2023
1 parent a134cc3 commit 5edeac2
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -106,14 +107,12 @@ public void testFinalize() throws Exception

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(
Expand Down

0 comments on commit 5edeac2

Please sign in to comment.