From 839379246a59221664cef1c482455ffe98e6e562 Mon Sep 17 00:00:00 2001 From: Himanshu Date: Mon, 30 Mar 2020 14:31:50 -0700 Subject: [PATCH] remove commons-lang3 usage from DoubleMeanAggregatorFactoryTest (#9578) --- .../aggregation/mean/DoubleMeanHolder.java | 21 +++++++++++++++++++ .../mean/DoubleMeanAggregatorFactoryTest.java | 5 ++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/query/aggregation/mean/DoubleMeanHolder.java b/processing/src/main/java/org/apache/druid/query/aggregation/mean/DoubleMeanHolder.java index 06aac1a9bb4..f04150fcede 100644 --- a/processing/src/main/java/org/apache/druid/query/aggregation/mean/DoubleMeanHolder.java +++ b/processing/src/main/java/org/apache/druid/query/aggregation/mean/DoubleMeanHolder.java @@ -27,6 +27,7 @@ import com.google.common.primitives.Doubles; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Comparator; +import java.util.Objects; public class DoubleMeanHolder { @@ -68,6 +69,26 @@ public class DoubleMeanHolder return buf.array(); } + @Override + public boolean equals(Object o) + { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DoubleMeanHolder that = (DoubleMeanHolder) o; + return Double.compare(that.sum, sum) == 0 && + count == that.count; + } + + @Override + public int hashCode() + { + return Objects.hash(sum, count); + } + public static DoubleMeanHolder fromBytes(byte[] data) { ByteBuffer buf = ByteBuffer.wrap(data); diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/mean/DoubleMeanAggregatorFactoryTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/mean/DoubleMeanAggregatorFactoryTest.java index 0e49363f16e..01dabaaca7f 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/mean/DoubleMeanAggregatorFactoryTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/mean/DoubleMeanAggregatorFactoryTest.java @@ -19,7 +19,6 @@ package org.apache.druid.query.aggregation.mean; -import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.Assert; import org.junit.Test; @@ -40,10 +39,10 @@ public class DoubleMeanAggregatorFactoryTest DoubleMeanHolder expectedHolder = new DoubleMeanHolder(50.0, 10L); DoubleMeanHolder actualHolder = (DoubleMeanHolder) factory.deserialize(expectedHolder); - Assert.assertTrue(EqualsBuilder.reflectionEquals(expectedHolder, actualHolder)); + Assert.assertEquals(expectedHolder, actualHolder); actualHolder = (DoubleMeanHolder) factory.deserialize(expectedHolder.toBytes()); - Assert.assertTrue(EqualsBuilder.reflectionEquals(expectedHolder, actualHolder)); + Assert.assertEquals(expectedHolder, actualHolder); } @Test