From 48823e103609166ff7fc7acea337adb19d3dca53 Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Thu, 30 Jul 2026 23:43:33 +0800 Subject: [PATCH] Replace deprecated JUnit assertThat calls --- codestyle/druid-forbidden-apis.txt | 3 + ...edBigDecimalAggregatorGroupByTestBase.java | 11 ++-- ...igDecimalAggregatorTimeseriesTestBase.java | 2 +- .../MovingAverageIterableTest.java | 3 +- .../movingaverage/MovingAverageQueryTest.java | 5 +- .../DoubleMaxAveragerFactoryTest.java | 4 +- .../DoubleMeanAveragerFactoryTest.java | 4 +- .../DoubleMeanNoNullAveragerFactoryTest.java | 4 +- .../DoubleMinAveragerFactoryTest.java | 4 +- .../DoubleSumAveragerFactoryTest.java | 4 +- .../averagers/LongMaxAveragerFactoryTest.java | 4 +- .../LongMeanAveragerFactoryTest.java | 4 +- .../LongMeanNoNullAveragerFactoryTest.java | 4 +- .../averagers/LongMinAveragerFactoryTest.java | 4 +- .../averagers/LongSumAveragerFactoryTest.java | 4 +- ...bjectVectorColumnProcessorFactoryTest.java | 3 +- .../aggregation/histogram/QuantilesTest.java | 3 +- .../ParallelIndexSupervisorTaskTest.java | 2 +- .../PartialHashSegmentGenerateTaskTest.java | 3 +- ...rtitionMultiPhaseParallelIndexingTest.java | 5 +- .../distribution/StringSketchTest.java | 11 ++-- ...nIndexTaskInputRowIteratorBuilderTest.java | 3 +- .../indexing/input/DruidInputSourceTest.java | 7 +- .../SingleTaskBackgroundRunnerTest.java | 3 +- .../segment/join/HashJoinSegmentTest.java | 3 +- .../druid/utils/CloseableUtilsTest.java | 65 ++++++++++--------- .../druid/curator/CuratorModuleTest.java | 2 +- .../segment/InlineSegmentWranglerTest.java | 3 +- .../segment/LookupSegmentWranglerTest.java | 3 +- .../join/LookupJoinableFactoryTest.java | 3 +- .../server/emitter/EmitterModuleTest.java | 5 +- .../log/LoggingRequestLoggerProviderTest.java | 3 +- .../server/log/RequestLoggerProviderTest.java | 4 +- 33 files changed, 108 insertions(+), 87 deletions(-) diff --git a/codestyle/druid-forbidden-apis.txt b/codestyle/druid-forbidden-apis.txt index 331c1a743527..87692043dcfc 100644 --- a/codestyle/druid-forbidden-apis.txt +++ b/codestyle/druid-forbidden-apis.txt @@ -96,3 +96,6 @@ javax.annotation.concurrent.GuardedBy com.amazonaws.annotation.GuardedBy org.powermock.** @ Use Mockito instead of Powermock for compatibility with newer Java versions + +org.junit.Assert#assertThat(java.lang.Object,org.hamcrest.Matcher) @ Use org.hamcrest.MatcherAssert#assertThat instead +org.junit.Assert#assertThat(java.lang.String,java.lang.Object,org.hamcrest.Matcher) @ Use org.hamcrest.MatcherAssert#assertThat instead diff --git a/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorGroupByTestBase.java b/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorGroupByTestBase.java index 63213de00c61..908957c786ee 100644 --- a/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorGroupByTestBase.java +++ b/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorGroupByTestBase.java @@ -28,6 +28,7 @@ import org.apache.druid.query.aggregation.AggregationTestHelper; import org.apache.druid.query.groupby.GroupByQueryConfig; import org.apache.druid.query.groupby.ResultRow; +import org.hamcrest.MatcherAssert; import org.hamcrest.collection.IsCollectionWithSize; import org.hamcrest.collection.IsMapContaining; import org.hamcrest.collection.IsMapWithSize; @@ -107,7 +108,7 @@ public void testIngestAndGroupByAllQuery() throws IOException, Exception ); List results = seq.toList(); - Assert.assertThat(results, IsCollectionWithSize.hasSize(1)); + MatcherAssert.assertThat(results, IsCollectionWithSize.hasSize(1)); ResultRow row = results.get(0); MapBasedRow mapBasedRow = row.toMapBasedRow(cbdGroupByQueryConfig.getQuery()); Map event = mapBasedRow.getEvent(); @@ -115,8 +116,8 @@ public void testIngestAndGroupByAllQuery() throws IOException, Exception new DateTime("2017-01-01T00:00:00Z", DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))), mapBasedRow.getTimestamp() ); - Assert.assertThat(event, IsMapWithSize.aMapWithSize(3)); - Assert.assertThat( + MatcherAssert.assertThat(event, IsMapWithSize.aMapWithSize(3)); + MatcherAssert.assertThat( event, IsMapContaining.hasEntry( "cbdRevenueFromString", @@ -124,7 +125,7 @@ public void testIngestAndGroupByAllQuery() throws IOException, Exception ) ); // long conversion of 5000000000.000000005 results in null/0 value - Assert.assertThat( + MatcherAssert.assertThat( event, IsMapContaining.hasEntry( "cbdRevenueFromLong", @@ -132,7 +133,7 @@ public void testIngestAndGroupByAllQuery() throws IOException, Exception ) ); // double input changes 5000000000.000000005 to 5000000000.5 to fit in double mantissa space - Assert.assertThat( + MatcherAssert.assertThat( event, IsMapContaining.hasEntry( "cbdRevenueFromDouble", diff --git a/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorTimeseriesTestBase.java b/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorTimeseriesTestBase.java index f2e4921a5002..f9f2073622d5 100644 --- a/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorTimeseriesTestBase.java +++ b/extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/CompressedBigDecimalAggregatorTimeseriesTestBase.java @@ -53,10 +53,10 @@ import java.util.Map; import java.util.TimeZone; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsMapContaining.hasEntry; import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; public abstract class CompressedBigDecimalAggregatorTimeseriesTestBase extends InitializedNullHandlingTest { diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageIterableTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageIterableTest.java index 9463bd87f71f..167ac95a28d6 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageIterableTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageIterableTest.java @@ -35,6 +35,7 @@ import org.apache.druid.query.movingaverage.averagers.LongMeanAveragerFactory; import org.apache.druid.testing.InitializedNullHandlingTest; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.joda.time.DateTime; import org.joda.time.chrono.ISOChronology; import org.junit.Assert; @@ -144,7 +145,7 @@ public void testNext() r = iter.next(); Assert.assertEquals(JAN_3, r.getTimestamp()); Assert.assertEquals("US", r.getRaw(COUNTRY)); - Assert.assertThat(r.getRaw(AGE), CoreMatchers.not(CoreMatchers.equalTo(r2.getRaw(AGE)))); + MatcherAssert.assertThat(r.getRaw(AGE), CoreMatchers.not(CoreMatchers.equalTo(r2.getRaw(AGE)))); Assert.assertTrue(iter.hasNext()); r = iter.next(); diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageQueryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageQueryTest.java index d16895dc7712..7072b974facc 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageQueryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/MovingAverageQueryTest.java @@ -78,6 +78,7 @@ import org.apache.druid.testing.InitializedNullHandlingTest; import org.apache.druid.timeline.TimelineLookup; import org.apache.druid.utils.JvmUtils; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; import org.joda.time.Interval; import org.junit.Assert; @@ -303,11 +304,11 @@ private List consistentTypeCasting(List result) public void testQuery() throws IOException { Query query = jsonMapper.readValue(getQueryString(), Query.class); - Assert.assertThat(query, IsInstanceOf.instanceOf(getExpectedQueryType())); + MatcherAssert.assertThat(query, IsInstanceOf.instanceOf(getExpectedQueryType())); List expectedResults = jsonMapper.readValue(getExpectedResultString(), getExpectedResultType()); Assert.assertNotNull(expectedResults); - Assert.assertThat(expectedResults, IsInstanceOf.instanceOf(List.class)); + MatcherAssert.assertThat(expectedResults, IsInstanceOf.instanceOf(List.class)); DruidHttpClientConfig httpClientConfig = new DruidHttpClientConfig() { diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMaxAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMaxAveragerFactoryTest.java index ef8c8a760408..13a2c30aaa84 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMaxAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMaxAveragerFactoryTest.java @@ -20,7 +20,7 @@ package org.apache.druid.query.movingaverage.averagers; import org.hamcrest.CoreMatchers; -import org.junit.Assert; +import org.hamcrest.MatcherAssert; import org.junit.Test; public class DoubleMaxAveragerFactoryTest @@ -29,6 +29,6 @@ public class DoubleMaxAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new DoubleMaxAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), CoreMatchers.instanceOf(DoubleMaxAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), CoreMatchers.instanceOf(DoubleMaxAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanAveragerFactoryTest.java index d4d85f445508..0a653c4c1673 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class DoubleMeanAveragerFactoryTest @@ -29,6 +29,6 @@ public class DoubleMeanAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new DoubleMeanAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMeanAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMeanAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanNoNullAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanNoNullAveragerFactoryTest.java index 6afbd478b521..37b16ad58d4e 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanNoNullAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMeanNoNullAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class DoubleMeanNoNullAveragerFactoryTest @@ -29,6 +29,6 @@ public class DoubleMeanNoNullAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new DoubleMeanNoNullAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMeanNoNullAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMeanNoNullAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMinAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMinAveragerFactoryTest.java index 61250215afea..ee12ebc212ae 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMinAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleMinAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class DoubleMinAveragerFactoryTest @@ -29,6 +29,6 @@ public class DoubleMinAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new DoubleMinAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMinAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleMinAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleSumAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleSumAveragerFactoryTest.java index bb65e963afa6..de4956a278dc 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleSumAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/DoubleSumAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class DoubleSumAveragerFactoryTest @@ -30,7 +30,7 @@ public class DoubleSumAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new DoubleSumAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleSumAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(DoubleSumAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMaxAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMaxAveragerFactoryTest.java index 0f429e787cff..d276e7be8add 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMaxAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMaxAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class LongMaxAveragerFactoryTest @@ -29,6 +29,6 @@ public class LongMaxAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new LongMaxAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMaxAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMaxAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanAveragerFactoryTest.java index 3b5b3e56be7a..df5c96417f49 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class LongMeanAveragerFactoryTest @@ -29,6 +29,6 @@ public class LongMeanAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new LongMeanAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMeanAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMeanAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanNoNullAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanNoNullAveragerFactoryTest.java index fb3e33eaa5e2..c691794777e4 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanNoNullAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMeanNoNullAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class LongMeanNoNullAveragerFactoryTest @@ -29,6 +29,6 @@ public class LongMeanNoNullAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new LongMeanNoNullAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMeanNoNullAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMeanNoNullAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMinAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMinAveragerFactoryTest.java index 9dca156bc63b..8e5b89a0d172 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMinAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongMinAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class LongMinAveragerFactoryTest @@ -29,6 +29,6 @@ public class LongMinAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new LongMinAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMinAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongMinAverager.class)); } } diff --git a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongSumAveragerFactoryTest.java b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongSumAveragerFactoryTest.java index fb297adf8c5a..2bf0d12faa59 100644 --- a/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongSumAveragerFactoryTest.java +++ b/extensions-contrib/moving-average-query/src/test/java/org/apache/druid/query/movingaverage/averagers/LongSumAveragerFactoryTest.java @@ -19,8 +19,8 @@ package org.apache.druid.query.movingaverage.averagers; +import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsInstanceOf; -import org.junit.Assert; import org.junit.Test; public class LongSumAveragerFactoryTest @@ -30,7 +30,7 @@ public class LongSumAveragerFactoryTest public void testCreateAverager() { AveragerFactory fac = new LongSumAveragerFactory("test", 5, 1, "field"); - Assert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongSumAverager.class)); + MatcherAssert.assertThat(fac.createAverager(), IsInstanceOf.instanceOf(LongSumAverager.class)); } } diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/util/ToObjectVectorColumnProcessorFactoryTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/util/ToObjectVectorColumnProcessorFactoryTest.java index 2fea6774e89d..393dd3fd66a9 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/util/ToObjectVectorColumnProcessorFactoryTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/util/ToObjectVectorColumnProcessorFactoryTest.java @@ -34,6 +34,7 @@ import org.apache.druid.segment.vector.VectorCursor; import org.apache.druid.testing.InitializedNullHandlingTest; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -168,7 +169,7 @@ public void testMultiString() public void testComplexSketch() { final Object sketch = Iterables.getOnlyElement(readColumn("quality_uniques", 1)); - Assert.assertThat(sketch, CoreMatchers.instanceOf(HyperLogLogCollector.class)); + MatcherAssert.assertThat(sketch, CoreMatchers.instanceOf(HyperLogLogCollector.class)); } private CursorHolder makeCursorHolder() diff --git a/extensions-core/histogram/src/test/java/org/apache/druid/query/aggregation/histogram/QuantilesTest.java b/extensions-core/histogram/src/test/java/org/apache/druid/query/aggregation/histogram/QuantilesTest.java index c299d553d878..378cc3271e3a 100644 --- a/extensions-core/histogram/src/test/java/org/apache/druid/query/aggregation/histogram/QuantilesTest.java +++ b/extensions-core/histogram/src/test/java/org/apache/druid/query/aggregation/histogram/QuantilesTest.java @@ -23,6 +23,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; import org.apache.druid.jackson.DefaultObjectMapper; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Test; @@ -46,7 +47,7 @@ public void testSerialization() throws Exception ); Object theObject = mapper.readValue(theString, Object.class); - Assert.assertThat(theObject, CoreMatchers.instanceOf(LinkedHashMap.class)); + MatcherAssert.assertThat(theObject, CoreMatchers.instanceOf(LinkedHashMap.class)); LinkedHashMap theMap = (LinkedHashMap) theObject; diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java index 19dc225b6c98..de2983e0f392 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java @@ -136,7 +136,7 @@ public void sizesPartitionsEvenly() int maxPartitionSize = sortedPartitionSizes.get(sortedPartitionSizes.size() - 1); int partitionSizeRange = maxPartitionSize - minPartitionSize; - Assert.assertThat( + MatcherAssert.assertThat( "partition sizes = " + actualPartitionSizes, partitionSizeRange, Matchers.is(Matchers.both(Matchers.greaterThanOrEqualTo(0)).and(Matchers.lessThanOrEqualTo(1))) diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/PartialHashSegmentGenerateTaskTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/PartialHashSegmentGenerateTaskTest.java index f5b9e952df2e..af30f3b0d563 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/PartialHashSegmentGenerateTaskTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/PartialHashSegmentGenerateTaskTest.java @@ -35,6 +35,7 @@ import org.apache.druid.server.security.Resource; import org.apache.druid.server.security.ResourceAction; import org.apache.druid.server.security.ResourceType; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.joda.time.Interval; import org.junit.Assert; @@ -92,7 +93,7 @@ public void serializesDeserializes() public void hasCorrectPrefixForAutomaticId() { String id = target.getId(); - Assert.assertThat(id, Matchers.startsWith(PartialHashSegmentGenerateTask.TYPE)); + MatcherAssert.assertThat(id, Matchers.startsWith(PartialHashSegmentGenerateTask.TYPE)); } @Test diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/RangePartitionMultiPhaseParallelIndexingTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/RangePartitionMultiPhaseParallelIndexingTest.java index cc3abacba0a7..119d7b527a6f 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/RangePartitionMultiPhaseParallelIndexingTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/RangePartitionMultiPhaseParallelIndexingTest.java @@ -43,6 +43,7 @@ import org.apache.druid.timeline.partition.DimensionRangeShardSpec; import org.apache.druid.timeline.partition.NumberedShardSpec; import org.apache.druid.timeline.partition.SingleDimensionShardSpec; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.joda.time.Interval; import org.junit.Assert; @@ -455,14 +456,14 @@ private static void assertValuesInRange(List values, DataSegment se for (StringTuple value : values) { if (start != null) { - Assert.assertThat(value.compareTo(start), Matchers.greaterThanOrEqualTo(0)); + MatcherAssert.assertThat(value.compareTo(start), Matchers.greaterThanOrEqualTo(0)); } if (end != null) { if (value == null) { Assert.assertNull("null values should be in first partition", start); } else { - Assert.assertThat(value.compareTo(end), Matchers.lessThan(0)); + MatcherAssert.assertThat(value.compareTo(end), Matchers.lessThan(0)); } } } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/distribution/StringSketchTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/distribution/StringSketchTest.java index c37b805c70b9..76be90220bc3 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/distribution/StringSketchTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/distribution/StringSketchTest.java @@ -27,6 +27,7 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.segment.TestHelper; import org.apache.druid.timeline.partition.PartitionBoundaries; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.hamcrest.number.IsCloseTo; import org.junit.Assert; @@ -208,12 +209,12 @@ private static void testHandlesUnevenPartitions(int targetSize) String partitionBoundariesString = PartitionTest.toString(partitionBoundaries); int expectedHighPartitionBoundaryCount = (int) Math.ceil((double) NUM_STRING / targetSize); int expectedLowPartitionBoundaryCount = expectedHighPartitionBoundaryCount - 1; - Assert.assertThat( + MatcherAssert.assertThat( "targetSize=" + targetSize + " " + partitionBoundariesString, partitionBoundaries.size(), Matchers.lessThanOrEqualTo(expectedHighPartitionBoundaryCount + 1) ); - Assert.assertThat( + MatcherAssert.assertThat( "targetSize=" + targetSize + " " + partitionBoundariesString, partitionBoundaries.size(), Matchers.greaterThanOrEqualTo(expectedLowPartitionBoundaryCount + 1) @@ -223,7 +224,7 @@ private static void testHandlesUnevenPartitions(int targetSize) for (int i = 1; i < partitionBoundaries.size() - 1; i++) { int current = Integer.parseInt(partitionBoundaries.get(i).get(0)); int size = current - previous; - Assert.assertThat( + MatcherAssert.assertThat( getErrMsgPrefix(targetSize, i) + partitionBoundariesString, (double) size, IsCloseTo.closeTo(targetSize, Math.ceil(DELTA) * 2) @@ -314,12 +315,12 @@ private static void testHandlesUnevenPartitions(int maxSize) for (int i = 1; i < partitionBoundaries.size() - 1; i++) { int current = Integer.parseInt(partitionBoundaries.get(i).get(0)); int size = current - previous; - Assert.assertThat( + MatcherAssert.assertThat( getErrMsgPrefix(maxSize, i) + partitionBoundariesString, size, Matchers.lessThanOrEqualTo(maxSize) ); - Assert.assertThat( + MatcherAssert.assertThat( getErrMsgPrefix(maxSize, i) + partitionBoundariesString, (double) size, Matchers.greaterThanOrEqualTo(minSize) diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/iterator/RangePartitionIndexTaskInputRowIteratorBuilderTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/iterator/RangePartitionIndexTaskInputRowIteratorBuilderTest.java index f933f5b3c383..ccc3e5f33058 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/iterator/RangePartitionIndexTaskInputRowIteratorBuilderTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/iterator/RangePartitionIndexTaskInputRowIteratorBuilderTest.java @@ -22,6 +22,7 @@ import org.apache.druid.data.input.InputRow; import org.apache.druid.indexer.granularity.GranularitySpec; import org.apache.druid.java.util.common.parsers.CloseableIterator; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.joda.time.DateTime; import org.junit.Assert; @@ -200,6 +201,6 @@ private static void assertNotInHandlerInvocationHistory( IndexTaskInputRowIteratorBuilderTestingFactory.HandlerTester.Handler handler ) { - Assert.assertThat(handlerInvocationHistory, Matchers.not(Matchers.contains(handler))); + MatcherAssert.assertThat(handlerInvocationHistory, Matchers.not(Matchers.contains(handler))); } } diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/input/DruidInputSourceTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/input/DruidInputSourceTest.java index 5e4ecd657cd2..35f819bfe6a4 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/input/DruidInputSourceTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/input/DruidInputSourceTest.java @@ -39,6 +39,7 @@ import org.apache.druid.segment.TestHelper; import org.easymock.EasyMock; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.joda.time.Interval; import org.junit.Assert; import org.junit.Before; @@ -86,7 +87,7 @@ public void testSerdeUsingIntervals() throws Exception final InputSource inputSource = mapper.readValue(json, InputSource.class); - Assert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); + MatcherAssert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); Assert.assertEquals( new DruidInputSource( "foo", @@ -119,7 +120,7 @@ public void testSerdeUsingIntervalsAndLegacyDimensionsMetrics() throws Exception final InputSource inputSource = mapper.readValue(json, InputSource.class); - Assert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); + MatcherAssert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); Assert.assertEquals( new DruidInputSource( "foo", @@ -153,7 +154,7 @@ public void testSerdeUsingSegments() throws Exception final InputSource inputSource = mapper.readValue(json, InputSource.class); - Assert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); + MatcherAssert.assertThat(inputSource, CoreMatchers.instanceOf(DruidInputSource.class)); Assert.assertEquals( new DruidInputSource( "foo", diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java index b628f8a253c6..78519fe33027 100644 --- a/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java +++ b/indexing-service/src/test/java/org/apache/druid/indexing/overlord/SingleTaskBackgroundRunnerTest.java @@ -64,6 +64,7 @@ import org.apache.druid.utils.JvmUtils; import org.easymock.EasyMock; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -181,7 +182,7 @@ public void testGetQueryRunner() throws ExecutionException, InterruptedException .build() .getRunner(runner); - Assert.assertThat(queryRunner, CoreMatchers.instanceOf(SetAndVerifyContextQueryRunner.class)); + MatcherAssert.assertThat(queryRunner, CoreMatchers.instanceOf(SetAndVerifyContextQueryRunner.class)); } @Test diff --git a/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentTest.java b/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentTest.java index bf4de04f7e0b..b39e999f7c37 100644 --- a/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentTest.java +++ b/processing/src/test/java/org/apache/druid/segment/join/HashJoinSegmentTest.java @@ -40,6 +40,7 @@ import org.apache.druid.testing.InitializedNullHandlingTest; import org.apache.druid.timeline.SegmentId; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -248,7 +249,7 @@ public void test_asQueryableIndex() @Test public void test_asCursorFactory() { - Assert.assertThat( + MatcherAssert.assertThat( makeJoinSegment().as(CursorFactory.class), CoreMatchers.instanceOf(HashJoinSegmentCursorFactory.class) ); diff --git a/processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java b/processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java index 68d37f80205f..40c2732c7f66 100644 --- a/processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java +++ b/processing/src/test/java/org/apache/druid/utils/CloseableUtilsTest.java @@ -21,6 +21,7 @@ import com.google.common.base.Throwables; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Test; import org.junit.internal.matchers.ThrowableCauseMatcher; @@ -75,11 +76,11 @@ public void test_closeAll_array_loud() assertClosed(quietCloseable, ioExceptionCloseable, quietCloseable2, runtimeExceptionCloseable); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); } @Test @@ -104,11 +105,11 @@ public void test_closeAll_list_loud() assertClosed(quietCloseable, ioExceptionCloseable, quietCloseable2, runtimeExceptionCloseable); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); } @Test @@ -137,7 +138,7 @@ public void test_closeAndWrapExceptions_ioException() } assertClosed(ioExceptionCloseable); - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); } @Test @@ -152,7 +153,7 @@ public void test_closeAndWrapExceptions_runtimeException() } assertClosed(runtimeExceptionCloseable); - Assert.assertThat(e, CoreMatchers.instanceOf(IllegalArgumentException.class)); + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IllegalArgumentException.class)); } @Test @@ -167,7 +168,7 @@ public void test_closeAndWrapExceptions_assertionError() } assertClosed(assertionErrorCloseable); - Assert.assertThat(e, CoreMatchers.instanceOf(AssertionError.class)); + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(AssertionError.class)); } @Test @@ -223,8 +224,8 @@ public void test_closeInCatch_improper() Assert.assertTrue(quietCloseable.isClosed()); - Assert.assertThat(e, CoreMatchers.instanceOf(IllegalStateException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IllegalStateException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("Must be called with non-null caught exception")) ); @@ -244,8 +245,8 @@ public void test_closeInCatch_quiet() Assert.assertTrue(quietCloseable.isClosed()); - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); @@ -266,15 +267,15 @@ public void test_closeInCatch_ioException() Assert.assertTrue(ioExceptionCloseable.isClosed()); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IOException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IOException.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IOException.class)); } @Test @@ -292,15 +293,15 @@ public void test_closeInCatch_runtimeException() Assert.assertTrue(runtimeExceptionCloseable.isClosed()); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); } @Test @@ -317,8 +318,8 @@ public void test_closeAndWrapInCatch_improper() Assert.assertTrue(quietCloseable.isClosed()); - Assert.assertThat(e, CoreMatchers.instanceOf(IllegalStateException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(IllegalStateException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("Must be called with non-null caught exception")) ); @@ -338,8 +339,8 @@ public void test_closeAndWrapInCatch_quiet() Assert.assertTrue(quietCloseable.isClosed()); - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); @@ -360,13 +361,13 @@ public void test_closeAndWrapInCatch_ioException() Assert.assertTrue(ioExceptionCloseable.isClosed()); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("java.io.IOException: this one was caught")) ); - Assert.assertThat(e, ThrowableCauseMatcher.hasCause(CoreMatchers.instanceOf(IOException.class))); - Assert.assertThat( + MatcherAssert.assertThat(e, ThrowableCauseMatcher.hasCause(CoreMatchers.instanceOf(IOException.class))); + MatcherAssert.assertThat( e, ThrowableCauseMatcher.hasCause( ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) @@ -375,7 +376,7 @@ public void test_closeAndWrapInCatch_ioException() // Second exception Assert.assertEquals(1, e.getCause().getSuppressed().length); - Assert.assertThat(e.getCause().getSuppressed()[0], CoreMatchers.instanceOf(IOException.class)); + MatcherAssert.assertThat(e.getCause().getSuppressed()[0], CoreMatchers.instanceOf(IOException.class)); } @Test @@ -393,15 +394,15 @@ public void test_closeAndWrapInCatch_runtimeException() Assert.assertTrue(runtimeExceptionCloseable.isClosed()); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(IllegalArgumentException.class)); } @Test @@ -419,15 +420,15 @@ public void test_closeAndWrapInCatch_assertionError() Assert.assertTrue(assertionErrorCloseable.isClosed()); // First exception - Assert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); - Assert.assertThat( + MatcherAssert.assertThat(e, CoreMatchers.instanceOf(RuntimeException.class)); + MatcherAssert.assertThat( e, ThrowableMessageMatcher.hasMessage(CoreMatchers.startsWith("this one was caught")) ); // Second exception Assert.assertEquals(1, e.getSuppressed().length); - Assert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(AssertionError.class)); + MatcherAssert.assertThat(e.getSuppressed()[0], CoreMatchers.instanceOf(AssertionError.class)); } @Test diff --git a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java index 8708bbae25d5..03939f38e0ac 100644 --- a/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java +++ b/server/src/test/java/org/apache/druid/curator/CuratorModuleTest.java @@ -135,7 +135,7 @@ private static CuratorFramework createCuratorFramework(Injector injector, int ma { CuratorFramework curatorFramework = injector.getInstance(CuratorFramework.class); RetryPolicy retryPolicy = curatorFramework.getZookeeperClient().getRetryPolicy(); - Assert.assertThat(retryPolicy, CoreMatchers.instanceOf(ExponentialBackoffRetry.class)); + MatcherAssert.assertThat(retryPolicy, CoreMatchers.instanceOf(ExponentialBackoffRetry.class)); RetryPolicy adjustedRetryPolicy = adjustRetryPolicy((BoundedExponentialBackoffRetry) retryPolicy, maxRetries); curatorFramework.getZookeeperClient().setRetryPolicy(adjustedRetryPolicy); return curatorFramework; diff --git a/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java b/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java index 80bd3eb2eb3b..3e2ad02c9d66 100644 --- a/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java +++ b/server/src/test/java/org/apache/druid/segment/InlineSegmentWranglerTest.java @@ -27,6 +27,7 @@ import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -74,6 +75,6 @@ public void test_getSegmentsForIntervals_inline() Assert.assertEquals(1, segments.size()); final Segment segment = Iterables.getOnlyElement(segments); - Assert.assertThat(segment, CoreMatchers.instanceOf(RowBasedSegment.class)); + MatcherAssert.assertThat(segment, CoreMatchers.instanceOf(RowBasedSegment.class)); } } diff --git a/server/src/test/java/org/apache/druid/segment/LookupSegmentWranglerTest.java b/server/src/test/java/org/apache/druid/segment/LookupSegmentWranglerTest.java index 9d8e2653cefb..270700181b4f 100644 --- a/server/src/test/java/org/apache/druid/segment/LookupSegmentWranglerTest.java +++ b/server/src/test/java/org/apache/druid/segment/LookupSegmentWranglerTest.java @@ -30,6 +30,7 @@ import org.apache.druid.query.lookup.LookupSegment; import org.apache.druid.query.lookup.LookupSegmentTest; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -99,7 +100,7 @@ public void test_getSegmentsForIntervals_lookupThatExists() ); Assert.assertEquals(1, segments.size()); - Assert.assertThat(Iterables.getOnlyElement(segments), CoreMatchers.instanceOf(LookupSegment.class)); + MatcherAssert.assertThat(Iterables.getOnlyElement(segments), CoreMatchers.instanceOf(LookupSegment.class)); } @Test diff --git a/server/src/test/java/org/apache/druid/segment/join/LookupJoinableFactoryTest.java b/server/src/test/java/org/apache/druid/segment/join/LookupJoinableFactoryTest.java index 160cf74f9655..4abc496c81a0 100644 --- a/server/src/test/java/org/apache/druid/segment/join/LookupJoinableFactoryTest.java +++ b/server/src/test/java/org/apache/druid/segment/join/LookupJoinableFactoryTest.java @@ -30,6 +30,7 @@ import org.apache.druid.query.lookup.MapLookupExtractorFactory; import org.apache.druid.segment.join.lookup.LookupJoinable; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -125,7 +126,7 @@ public void testBuild() { final Joinable joinable = factory.build(lookupDataSource, makeCondition("x == \"j.k\"")).get(); - Assert.assertThat(joinable, CoreMatchers.instanceOf(LookupJoinable.class)); + MatcherAssert.assertThat(joinable, CoreMatchers.instanceOf(LookupJoinable.class)); Assert.assertEquals(ImmutableList.of("k", "v"), joinable.getAvailableColumns()); Assert.assertEquals(Joinable.CARDINALITY_UNKNOWN, joinable.getCardinality("k")); Assert.assertEquals(Joinable.CARDINALITY_UNKNOWN, joinable.getCardinality("v")); diff --git a/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java b/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java index 7e7d0e60d1be..5fbd1d938e83 100644 --- a/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java +++ b/server/src/test/java/org/apache/druid/server/emitter/EmitterModuleTest.java @@ -54,6 +54,7 @@ import org.apache.druid.server.metrics.LoadSpecHolder; import org.apache.druid.server.metrics.TestTaskHolder; import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -85,7 +86,7 @@ public void testParametrizedUriEmitterConfig() final Emitter emitter = makeInjectorWithProperties(props).getInstance(Emitter.class); // Testing that ParametrizedUriEmitter is successfully deserialized from the above config - Assert.assertThat(emitter, CoreMatchers.instanceOf(ParametrizedUriEmitter.class)); + MatcherAssert.assertThat(emitter, CoreMatchers.instanceOf(ParametrizedUriEmitter.class)); } @Test @@ -95,7 +96,7 @@ public void testMissingEmitterType() props.setProperty("druid.emitter", ""); final Emitter emitter = makeInjectorWithProperties(props).getInstance(Emitter.class); - Assert.assertThat(emitter, CoreMatchers.instanceOf(NoopEmitter.class)); + MatcherAssert.assertThat(emitter, CoreMatchers.instanceOf(NoopEmitter.class)); } @Test diff --git a/server/src/test/java/org/apache/druid/server/log/LoggingRequestLoggerProviderTest.java b/server/src/test/java/org/apache/druid/server/log/LoggingRequestLoggerProviderTest.java index 7642e88a8b2c..304cbac99c58 100644 --- a/server/src/test/java/org/apache/druid/server/log/LoggingRequestLoggerProviderTest.java +++ b/server/src/test/java/org/apache/druid/server/log/LoggingRequestLoggerProviderTest.java @@ -31,6 +31,7 @@ import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.guice.QueryableModule; import org.apache.druid.initialization.Initialization; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; @@ -77,7 +78,7 @@ public void testNoopConfigParsing() final Properties properties = new Properties(); properties.put(propertyPrefix + ".type", "noop"); provider.inject(properties, injector.getInstance(JsonConfigurator.class)); - Assert.assertThat(provider.get().get(), Matchers.instanceOf(NoopRequestLogger.class)); + MatcherAssert.assertThat(provider.get().get(), Matchers.instanceOf(NoopRequestLogger.class)); } private Injector makeInjector() diff --git a/server/src/test/java/org/apache/druid/server/log/RequestLoggerProviderTest.java b/server/src/test/java/org/apache/druid/server/log/RequestLoggerProviderTest.java index 0f9ece45a118..d7c3fe927183 100644 --- a/server/src/test/java/org/apache/druid/server/log/RequestLoggerProviderTest.java +++ b/server/src/test/java/org/apache/druid/server/log/RequestLoggerProviderTest.java @@ -25,7 +25,7 @@ import org.apache.druid.guice.JsonConfigurator; import org.apache.druid.jackson.DefaultObjectMapper; import org.hamcrest.CoreMatchers; -import org.junit.Assert; +import org.hamcrest.MatcherAssert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -69,7 +69,7 @@ public void testNoLoggerAtAll() RequestLoggerProvider.class, NoopRequestLoggerProvider.class ); - Assert.assertThat(provider, CoreMatchers.instanceOf(NoopRequestLoggerProvider.class)); + MatcherAssert.assertThat(provider, CoreMatchers.instanceOf(NoopRequestLoggerProvider.class)); } @Test