remove commons-lang3 usage from DoubleMeanAggregatorFactoryTest (#9578)

This commit is contained in:
Himanshu 2020-03-30 14:31:50 -07:00 committed by GitHub
parent fa5da6693c
commit 839379246a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -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);

View File

@ -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