diff --git a/processing/src/test/java/org/apache/druid/common/utils/SerializerUtilsTest.java b/processing/src/test/java/org/apache/druid/common/utils/SerializerUtilsTest.java index efd28e2e8dca..b53ffe50cd08 100644 --- a/processing/src/test/java/org/apache/druid/common/utils/SerializerUtilsTest.java +++ b/processing/src/test/java/org/apache/druid/common/utils/SerializerUtilsTest.java @@ -20,10 +20,10 @@ package org.apache.druid.common.utils; import org.apache.druid.java.util.common.StringUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -47,7 +47,7 @@ public class SerializerUtilsTest private byte[] longsByte; private ByteArrayOutputStream outStream; - @Before + @BeforeEach public void setUpByteArrays() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -97,7 +97,7 @@ public void testWriteInts() throws IOException { serializerUtils.writeInts(outStream, ints); byte[] actuals = outStream.toByteArray(); - Assert.assertArrayEquals(intsByte, actuals); + Assertions.assertArrayEquals(intsByte, actuals); } @Test @@ -105,7 +105,7 @@ public void testWriteFloats() throws IOException { serializerUtils.writeFloats(outStream, floats); byte[] actuals = outStream.toByteArray(); - Assert.assertArrayEquals(floatsByte, actuals); + Assertions.assertArrayEquals(floatsByte, actuals); } @Test @@ -120,7 +120,7 @@ public void testChannelWritefloat() throws IOException } float expected = serializerUtils.readFloat(inputstream); float actuals = floats[index]; - Assert.assertEquals(expected, actuals, delta); + Assertions.assertEquals(expected, actuals, delta); } @Test @@ -128,7 +128,7 @@ public void testWriteLongs() throws IOException { serializerUtils.writeLongs(outStream, longs); byte[] actuals = outStream.toByteArray(); - Assert.assertArrayEquals(longsByte, actuals); + Assertions.assertArrayEquals(longsByte, actuals); } @Test @@ -142,7 +142,7 @@ public void testChannelWritelong() throws IOException inputstream.close(); long expected = serializerUtils.readLong(inputstream); long actuals = longs[index]; - Assert.assertEquals(expected, actuals); + Assertions.assertEquals(expected, actuals); } @Test @@ -151,7 +151,7 @@ public void testReadInts() throws IOException ByteArrayInputStream inputstream = new ByteArrayInputStream(intsByte); int[] actuals = serializerUtils.readInts(inputstream); inputstream.close(); - Assert.assertArrayEquals(ints, actuals); + Assertions.assertArrayEquals(ints, actuals); } @Test @@ -160,7 +160,7 @@ public void testReadFloats() throws IOException ByteArrayInputStream inputstream = new ByteArrayInputStream(floatsByte); float[] actuals = serializerUtils.readFloats(inputstream); inputstream.close(); - Assert.assertArrayEquals(floats, actuals, delta); + Assertions.assertArrayEquals(floats, actuals, delta); } @Test @@ -169,7 +169,7 @@ public void testReadLongs() throws IOException ByteArrayInputStream inputstream = new ByteArrayInputStream(longsByte); long[] actuals = serializerUtils.readLongs(inputstream); inputstream.close(); - Assert.assertArrayEquals(longs, actuals); + Assertions.assertArrayEquals(longs, actuals); } @Test @@ -178,7 +178,7 @@ public void testReadStrings() throws IOException ByteArrayInputStream inputstream = new ByteArrayInputStream(stringsByte); String[] actuals = serializerUtils.readStrings(inputstream); inputstream.close(); - Assert.assertArrayEquals(strings, actuals); + Assertions.assertArrayEquals(strings, actuals); } @Test @@ -192,7 +192,7 @@ public void testChannelWriteString() throws IOException inputstream.close(); String expected = serializerUtils.readString(inputstream); String actuals = strings[index]; - Assert.assertEquals(expected, actuals); + Assertions.assertEquals(expected, actuals); } @Test @@ -202,10 +202,10 @@ public void testByteBufferReadStrings() buffer.put(stringsByte); buffer.flip(); String[] actuals = serializerUtils.readStrings(buffer); - Assert.assertArrayEquals(strings, actuals); + Assertions.assertArrayEquals(strings, actuals); } - @After + @AfterEach public void tearDown() throws IOException { serializerUtils = null; diff --git a/processing/src/test/java/org/apache/druid/data/input/impl/CsvInputFormatTest.java b/processing/src/test/java/org/apache/druid/data/input/impl/CsvInputFormatTest.java index 0a65862579d5..b7d7f983b2a4 100644 --- a/processing/src/test/java/org/apache/druid/data/input/impl/CsvInputFormatTest.java +++ b/processing/src/test/java/org/apache/druid/data/input/impl/CsvInputFormatTest.java @@ -26,20 +26,15 @@ import org.apache.druid.utils.CompressionUtils; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; import org.junit.internal.matchers.ThrowableMessageMatcher; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; public class CsvInputFormatTest extends InitializedNullHandlingTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testSerde() throws IOException { @@ -47,7 +42,7 @@ public void testSerde() throws IOException final CsvInputFormat format = new CsvInputFormat(Collections.singletonList("a"), "|", null, true, 10, null); final byte[] bytes = mapper.writeValueAsBytes(format); final CsvInputFormat fromJson = (CsvInputFormat) mapper.readValue(bytes, InputFormat.class); - Assert.assertEquals(format, fromJson); + Assertions.assertEquals(format, fromJson); } @Test @@ -58,7 +53,7 @@ public void testDeserializeWithoutColumnsWithHasHeaderRow() throws IOException "{\"type\":\"csv\",\"hasHeaderRow\":true}", InputFormat.class ); - Assert.assertTrue(inputFormat.isFindColumnsFromHeader()); + Assertions.assertTrue(inputFormat.isFindColumnsFromHeader()); } @Test @@ -69,14 +64,14 @@ public void testDeserializeWithoutColumnsWithFindColumnsFromHeaderTrue() throws "{\"type\":\"csv\",\"findColumnsFromHeader\":true}", InputFormat.class ); - Assert.assertTrue(inputFormat.isFindColumnsFromHeader()); + Assertions.assertTrue(inputFormat.isFindColumnsFromHeader()); } @Test public void testDeserializeWithoutColumnsWithFindColumnsFromHeaderFalse() { final ObjectMapper mapper = new ObjectMapper(); - final JsonProcessingException e = Assert.assertThrows( + final JsonProcessingException e = Assertions.assertThrows( JsonProcessingException.class, () -> mapper.readValue( "{\"type\":\"csv\",\"findColumnsFromHeader\":false}", @@ -96,7 +91,7 @@ public void testDeserializeWithoutColumnsWithFindColumnsFromHeaderFalse() public void testDeserializeWithoutColumnsWithBothHeaderProperties() { final ObjectMapper mapper = new ObjectMapper(); - final JsonProcessingException e = Assert.assertThrows( + final JsonProcessingException e = Assertions.assertThrows( JsonProcessingException.class, () -> mapper.readValue( "{\"type\":\"csv\",\"findColumnsFromHeader\":true,\"hasHeaderRow\":true}", @@ -115,7 +110,7 @@ public void testDeserializeWithoutColumnsWithBothHeaderProperties() public void testDeserializeWithoutAnyProperties() { final ObjectMapper mapper = new ObjectMapper(); - final JsonProcessingException e = Assert.assertThrows( + final JsonProcessingException e = Assertions.assertThrows( JsonProcessingException.class, () -> mapper.readValue("{\"type\":\"csv\"}", InputFormat.class) ); @@ -135,67 +130,75 @@ public void testDeserializeWithTryParseNumbers() throws IOException "{\"type\":\"csv\",\"hasHeaderRow\":true,\"tryParseNumbers\":true}", InputFormat.class ); - Assert.assertTrue(inputFormat.shouldTryParseNumbers()); + Assertions.assertTrue(inputFormat.shouldTryParseNumbers()); } @Test public void testComma() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Column[a,] cannot have the delimiter[,] in its name"); - new CsvInputFormat(Collections.singletonList("a,"), "|", null, false, 0, null); + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new CsvInputFormat(Collections.singletonList("a,"), "|", null, false, 0, null) + ); + Assertions.assertTrue(e.getMessage().contains("Column[a,] cannot have the delimiter[,] in its name")); } @Test public void testDelimiter() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Cannot have same delimiter and list delimiter of [,]"); - new CsvInputFormat(Collections.singletonList("a\t"), ",", null, false, 0, null); + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new CsvInputFormat(Collections.singletonList("a\t"), ",", null, false, 0, null) + ); + Assertions.assertTrue(e.getMessage().contains("Cannot have same delimiter and list delimiter of [,]")); } @Test public void testFindColumnsFromHeaderWithColumnsReturningItsValue() { final CsvInputFormat format = new CsvInputFormat(Collections.singletonList("a"), null, null, true, 0, null); - Assert.assertTrue(format.isFindColumnsFromHeader()); + Assertions.assertTrue(format.isFindColumnsFromHeader()); } @Test public void testFindColumnsFromHeaderWithMissingColumnsReturningItsValue() { final CsvInputFormat format = new CsvInputFormat(null, null, null, true, 0, null); - Assert.assertTrue(format.isFindColumnsFromHeader()); + Assertions.assertTrue(format.isFindColumnsFromHeader()); } @Test public void testMissingFindColumnsFromHeaderWithMissingColumnsThrowingError() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either [columns] or [findColumnsFromHeader] must be set"); - new CsvInputFormat(null, null, null, null, 0, null); + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new CsvInputFormat(null, null, null, null, 0, null) + ); + Assertions.assertTrue(e.getMessage().contains("Either [columns] or [findColumnsFromHeader] must be set")); } @Test public void testMissingFindColumnsFromHeaderWithColumnsReturningFalse() { final CsvInputFormat format = new CsvInputFormat(Collections.singletonList("a"), null, null, null, 0, null); - Assert.assertFalse(format.isFindColumnsFromHeader()); + Assertions.assertFalse(format.isFindColumnsFromHeader()); } @Test public void testHasHeaderRowWithMissingFindColumnsThrowingError() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Cannot accept both [findColumnsFromHeader] and [hasHeaderRow]"); - new CsvInputFormat(null, null, true, false, 0, null); + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new CsvInputFormat(null, null, true, false, 0, null) + ); + Assertions.assertTrue(e.getMessage().contains("Cannot accept both [findColumnsFromHeader] and [hasHeaderRow]")); } @Test public void testHasHeaderRowWithMissingColumnsReturningItsValue() { final CsvInputFormat format = new CsvInputFormat(null, null, true, null, 0, null); - Assert.assertTrue(format.isFindColumnsFromHeader()); + Assertions.assertTrue(format.isFindColumnsFromHeader()); } @Test @@ -203,7 +206,7 @@ public void test_getWeightedSize_withoutCompression() { final CsvInputFormat format = new CsvInputFormat(null, null, true, null, 0, null); final long unweightedSize = 100L; - Assert.assertEquals(unweightedSize, format.getWeightedSize("file.csv", unweightedSize)); + Assertions.assertEquals(unweightedSize, format.getWeightedSize("file.csv", unweightedSize)); } @Test @@ -211,7 +214,7 @@ public void test_getWeightedSize_withGzCompression() { final CsvInputFormat format = new CsvInputFormat(null, null, true, null, 0, null); final long unweightedSize = 100L; - Assert.assertEquals( + Assertions.assertEquals( unweightedSize * CompressionUtils.COMPRESSED_TEXT_WEIGHT_FACTOR, format.getWeightedSize("file.csv.gz", unweightedSize) ); diff --git a/processing/src/test/java/org/apache/druid/data/input/impl/HttpEntityTest.java b/processing/src/test/java/org/apache/druid/data/input/impl/HttpEntityTest.java index 8776cd275730..c911a7e944f6 100644 --- a/processing/src/test/java/org/apache/druid/data/input/impl/HttpEntityTest.java +++ b/processing/src/test/java/org/apache/druid/data/input/impl/HttpEntityTest.java @@ -25,11 +25,9 @@ import com.sun.net.httpserver.HttpServer; import org.apache.commons.io.IOUtils; import org.apache.druid.java.util.common.StringUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.AdditionalAnswers; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; @@ -54,7 +52,7 @@ public class HttpEntityTest private URLConnection urlConnection; private InputStream inputStreamMock; - @Before + @BeforeEach public void setup() throws IOException { uri = Mockito.mock(URI.class); @@ -67,9 +65,6 @@ public void setup() throws IOException Mockito.when(inputStreamMock.skip(ArgumentMatchers.anyLong())).then(AdditionalAnswers.returnsFirstArg()); } - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testOpenInputStream() throws IOException, URISyntaxException { @@ -103,7 +98,7 @@ public void testOpenInputStream() throws IOException, URISyntaxException inputStream = HttpEntity.openInputStream(url, "", null, 0, Collections.emptyMap()); inputStreamPartial = HttpEntity.openInputStream(url, "", null, 5, Collections.emptyMap()); inputStream.skip(5); - Assert.assertTrue(IOUtils.contentEquals(inputStream, inputStreamPartial)); + Assertions.assertTrue(IOUtils.contentEquals(inputStream, inputStreamPartial)); } finally { IOUtils.closeQuietly(inputStream); @@ -136,8 +131,8 @@ public void testRequestHeaders() throws IOException, URISyntaxException (httpExchange) -> { Headers headers = httpExchange.getRequestHeaders(); for (Map.Entry entry : requestHeaders.entrySet()) { - Assert.assertTrue(headers.containsKey(entry.getKey())); - Assert.assertEquals(headers.get(entry.getKey()).get(0), entry.getValue()); + Assertions.assertTrue(headers.containsKey(entry.getKey())); + Assertions.assertEquals(headers.get(entry.getKey()).get(0), entry.getValue()); } String payload = "12345678910"; byte[] outputBytes = payload.getBytes(StandardCharsets.UTF_8); @@ -156,7 +151,7 @@ public void testRequestHeaders() throws IOException, URISyntaxException inputStream = HttpEntity.openInputStream(url, "", null, 0, requestHeaders); inputStreamPartial = HttpEntity.openInputStream(url, "", null, 5, requestHeaders); inputStream.skip(5); - Assert.assertTrue(IOUtils.contentEquals(inputStream, inputStreamPartial)); + Assertions.assertTrue(IOUtils.contentEquals(inputStream, inputStreamPartial)); } finally { IOUtils.closeQuietly(inputStream); diff --git a/processing/src/test/java/org/apache/druid/data/input/impl/HttpInputSourceTest.java b/processing/src/test/java/org/apache/druid/data/input/impl/HttpInputSourceTest.java index c11cb96f34d4..0d6ee765169a 100644 --- a/processing/src/test/java/org/apache/druid/data/input/impl/HttpInputSourceTest.java +++ b/processing/src/test/java/org/apache/druid/data/input/impl/HttpInputSourceTest.java @@ -31,10 +31,8 @@ import org.apache.druid.data.input.impl.systemfield.SystemFields; import org.apache.druid.error.DruidException; import org.apache.druid.metadata.DefaultPasswordProvider; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URI; @@ -44,9 +42,6 @@ public class HttpInputSourceTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testSerde() throws IOException { @@ -63,7 +58,7 @@ public void testSerde() throws IOException ); final byte[] json = mapper.writeValueAsBytes(source); final HttpInputSource fromJson = (HttpInputSource) mapper.readValue(json, InputSource.class); - Assert.assertEquals(source, fromJson); + Assertions.assertEquals(source, fromJson); } @Test @@ -87,16 +82,19 @@ public void testConstructorAllowsOnlyDefaultProtocols() new HttpInputSourceConfig(null, null) ); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Only [http, https] protocols are allowed"); - new HttpInputSource( - ImmutableList.of(URI.create("my-protocol:///")), - "myName", - new DefaultPasswordProvider("myPassword"), - null, - null, - new HttpInputSourceConfig(null, null) + IllegalArgumentException e1 = Assertions.assertThrows( + IllegalArgumentException.class, + //noinspection ResultOfObjectAllocationIgnored + () -> new HttpInputSource( + ImmutableList.of(URI.create("my-protocol:///")), + "myName", + new DefaultPasswordProvider("myPassword"), + null, + null, + new HttpInputSourceConfig(null, null) + ) ); + Assertions.assertTrue(e1.getMessage().contains("Only [http, https] protocols are allowed")); } @Test @@ -112,16 +110,19 @@ public void testConstructorAllowsOnlyCustomProtocols() customConfig ); - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Only [druid] protocols are allowed"); - new HttpInputSource( - ImmutableList.of(URI.create("https:///")), - "myName", - new DefaultPasswordProvider("myPassword"), - null, - null, - customConfig + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + //noinspection ResultOfObjectAllocationIgnored + () -> new HttpInputSource( + ImmutableList.of(URI.create("https:///")), + "myName", + new DefaultPasswordProvider("myPassword"), + null, + null, + customConfig + ) ); + Assertions.assertTrue(e.getMessage().contains("Only [druid] protocols are allowed")); } @Test @@ -137,16 +138,16 @@ public void testSystemFields() httpInputSourceConfig ); - Assert.assertEquals( + Assertions.assertEquals( EnumSet.of(SystemField.URI, SystemField.PATH), inputSource.getConfiguredSystemFields() ); final HttpEntity entity = new HttpEntity(URI.create("https://example.com/foo"), null, null, null); - Assert.assertEquals("https://example.com/foo", inputSource.getSystemFieldValue(entity, SystemField.URI)); - Assert.assertEquals("/foo", inputSource.getSystemFieldValue(entity, SystemField.PATH)); - Assert.assertEquals(inputSource.getRequestHeaders(), Collections.emptyMap()); + Assertions.assertEquals("https://example.com/foo", inputSource.getSystemFieldValue(entity, SystemField.URI)); + Assertions.assertEquals("/foo", inputSource.getSystemFieldValue(entity, SystemField.PATH)); + Assertions.assertEquals(inputSource.getRequestHeaders(), Collections.emptyMap()); } @Test @@ -156,19 +157,22 @@ public void testEmptyAllowedHeaders() null, new HashSet<>() ); - expectedException.expect(DruidException.class); - expectedException.expectMessage( - "Got forbidden header [r-Cookie], allowed headers are only [[]]. " - + "You can control the allowed headers by updating druid.ingestion.http.allowedHeaders"); - - final HttpInputSource inputSource = new HttpInputSource( - ImmutableList.of(URI.create("http://test.com/http-test")), - "myName", - new DefaultPasswordProvider("myPassword"), - new SystemFields(EnumSet.of(SystemField.URI, SystemField.PATH)), - ImmutableMap.of("r-Cookie", "test", "Content-Type", "application/json"), - httpInputSourceConfig + DruidException e = Assertions.assertThrows( + DruidException.class, + //noinspection ResultOfObjectAllocationIgnored + () -> new HttpInputSource( + ImmutableList.of(URI.create("http://test.com/http-test")), + "myName", + new DefaultPasswordProvider("myPassword"), + new SystemFields(EnumSet.of(SystemField.URI, SystemField.PATH)), + ImmutableMap.of("r-Cookie", "test", "Content-Type", "application/json"), + httpInputSourceConfig + ) ); + Assertions.assertTrue(e.getMessage().contains( + "Got forbidden header [r-Cookie], allowed headers are only [[]]. " + + "You can control the allowed headers by updating druid.ingestion.http.allowedHeaders" + )); } @Test @@ -178,17 +182,21 @@ public void shouldFailOnForbiddenHeaders() null, Sets.newHashSet("R-cookie", "Content-type") ); - expectedException.expect(DruidException.class); - expectedException.expectMessage( - "Got forbidden header [G-Cookie], allowed headers are only [[r-cookie, content-type]]"); - new HttpInputSource( - ImmutableList.of(URI.create("http://test.com/http-test")), - "myName", - new DefaultPasswordProvider("myPassword"), - new SystemFields(EnumSet.of(SystemField.URI, SystemField.PATH)), - ImmutableMap.of("G-Cookie", "test", "Content-Type", "application/json"), - httpInputSourceConfig + DruidException e = Assertions.assertThrows( + DruidException.class, + //noinspection ResultOfObjectAllocationIgnored + () -> new HttpInputSource( + ImmutableList.of(URI.create("http://test.com/http-test")), + "myName", + new DefaultPasswordProvider("myPassword"), + new SystemFields(EnumSet.of(SystemField.URI, SystemField.PATH)), + ImmutableMap.of("G-Cookie", "test", "Content-Type", "application/json"), + httpInputSourceConfig + ) ); + Assertions.assertTrue(e.getMessage().contains( + "Got forbidden header [G-Cookie], allowed headers are only [[r-cookie, content-type]]" + )); } @Test diff --git a/processing/src/test/java/org/apache/druid/data/input/impl/JsonInputFormatTest.java b/processing/src/test/java/org/apache/druid/data/input/impl/JsonInputFormatTest.java index 490362fab4c1..de3ce89b4a62 100644 --- a/processing/src/test/java/org/apache/druid/data/input/impl/JsonInputFormatTest.java +++ b/processing/src/test/java/org/apache/druid/data/input/impl/JsonInputFormatTest.java @@ -30,10 +30,8 @@ import org.apache.druid.java.util.common.parsers.JSONPathFieldType; import org.apache.druid.java.util.common.parsers.JSONPathSpec; import org.apache.druid.utils.CompressionUtils; -import org.hamcrest.CoreMatchers; -import org.hamcrest.MatcherAssert; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Arrays; @@ -65,7 +63,7 @@ public void testSerde() throws IOException ); final byte[] bytes = mapper.writeValueAsBytes(format); final JsonInputFormat fromJson = (JsonInputFormat) mapper.readValue(bytes, InputFormat.class); - Assert.assertEquals(format, fromJson); + Assertions.assertEquals(format, fromJson); } @Test @@ -91,8 +89,8 @@ public void testWithLineSplittable() false ); - Assert.assertTrue(format.isLineSplittable()); - Assert.assertFalse(format.withLineSplittable(false).isLineSplittable()); + Assertions.assertTrue(format.isLineSplittable()); + Assertions.assertFalse(format.withLineSplittable(false).isLineSplittable()); } @Test @@ -118,12 +116,12 @@ public void testWithLineSplittableStatic() false ); - Assert.assertTrue(format.isLineSplittable()); - Assert.assertFalse(((JsonInputFormat) JsonInputFormat.withLineSplittable(format, false)).isLineSplittable()); + Assertions.assertTrue(format.isLineSplittable()); + Assertions.assertFalse(((JsonInputFormat) JsonInputFormat.withLineSplittable(format, false)).isLineSplittable()); // Other formats than json are passed-through unchanged final InputFormat noopInputFormat = JsonInputFormat.withLineSplittable(new NoopInputFormat(), false); - MatcherAssert.assertThat(noopInputFormat, CoreMatchers.instanceOf(NoopInputFormat.class)); + Assertions.assertInstanceOf(NoopInputFormat.class, noopInputFormat); } @Test @@ -150,7 +148,7 @@ public void test_unsetUseFieldDiscovery_unsetKeepNullColumnsByDefault() null, null ); - Assert.assertFalse(format.isKeepNullColumns()); + Assertions.assertFalse(format.isKeepNullColumns()); } @Test @@ -163,7 +161,7 @@ public void testUseFieldDiscovery_setKeepNullColumnsByDefault() null, null ); - Assert.assertTrue(format.isKeepNullColumns()); + Assertions.assertTrue(format.isKeepNullColumns()); } @Test @@ -176,7 +174,7 @@ public void testUseFieldDiscovery_doNotChangeKeepNullColumnsUserSets() null, null ); - Assert.assertFalse(format.isKeepNullColumns()); + Assertions.assertFalse(format.isKeepNullColumns()); } @Test @@ -190,7 +188,7 @@ public void test_getWeightedSize_withoutCompression() null ); final long unweightedSize = 100L; - Assert.assertEquals(unweightedSize, format.getWeightedSize("file.json", unweightedSize)); + Assertions.assertEquals(unweightedSize, format.getWeightedSize("file.json", unweightedSize)); } @Test @@ -204,7 +202,7 @@ public void test_getWeightedSize_withGzCompression() null ); final long unweightedSize = 100L; - Assert.assertEquals( + Assertions.assertEquals( unweightedSize * CompressionUtils.COMPRESSED_TEXT_WEIGHT_FACTOR, format.getWeightedSize("file.json.gz", unweightedSize) ); diff --git a/processing/src/test/java/org/apache/druid/frame/field/ComplexFieldReaderTest.java b/processing/src/test/java/org/apache/druid/frame/field/ComplexFieldReaderTest.java index d4970d9bd0cd..e4c65ec543b8 100644 --- a/processing/src/test/java/org/apache/druid/frame/field/ComplexFieldReaderTest.java +++ b/processing/src/test/java/org/apache/druid/frame/field/ComplexFieldReaderTest.java @@ -33,43 +33,39 @@ import org.apache.druid.testing.InitializedNullHandlingTest; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; import org.junit.internal.matchers.ThrowableMessageMatcher; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.mockito.quality.Strictness; +import org.mockito.junit.jupiter.MockitoExtension; import javax.annotation.Nullable; import java.nio.ByteBuffer; +@ExtendWith(MockitoExtension.class) public class ComplexFieldReaderTest extends InitializedNullHandlingTest { private static final ComplexMetricSerde SERDE = new StringComplexMetricSerde(); private static final long MEMORY_POSITION = 1; - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock public BaseObjectColumnValueSelector writeSelector; private WritableMemory memory; private FieldWriter fieldWriter; - @Before + @BeforeEach public void setUp() { memory = WritableMemory.allocate(1000); fieldWriter = new ComplexFieldWriter(SERDE, writeSelector); } - @After + @AfterEach public void tearDown() { fieldWriter.close(); @@ -78,7 +74,7 @@ public void tearDown() @Test public void test_createFromType_notComplex() { - final IllegalStateException e = Assert.assertThrows( + final IllegalStateException e = Assertions.assertThrows( IllegalStateException.class, () -> ComplexFieldReader.createFromType(ColumnType.LONG) ); @@ -92,7 +88,7 @@ public void test_createFromType_notComplex() @Test public void test_createFromType_noComplexSerde() { - final IllegalStateException e = Assert.assertThrows( + final IllegalStateException e = Assertions.assertThrows( IllegalStateException.class, () -> ComplexFieldReader.createFromType(ColumnType.ofComplex("no-serde")) ); @@ -107,14 +103,14 @@ public void test_createFromType_noComplexSerde() public void test_isNull_null() { writeToMemory(null); - Assert.assertTrue(new ComplexFieldReader(SERDE).isNull(memory, MEMORY_POSITION)); + Assertions.assertTrue(new ComplexFieldReader(SERDE).isNull(memory, MEMORY_POSITION)); } @Test public void test_isNull_aValue() { writeToMemory("foo"); - Assert.assertFalse(new ComplexFieldReader(SERDE).isNull(memory, MEMORY_POSITION)); + Assertions.assertFalse(new ComplexFieldReader(SERDE).isNull(memory, MEMORY_POSITION)); } @Test @@ -125,7 +121,7 @@ public void test_makeColumnValueSelector_null() final ColumnValueSelector readSelector = new ComplexFieldReader(SERDE).makeColumnValueSelector(memory, new ConstantFieldPointer(MEMORY_POSITION, -1)); - Assert.assertNull(readSelector.getObject()); + Assertions.assertNull(readSelector.getObject()); } @Test @@ -136,7 +132,7 @@ public void test_makeColumnValueSelector_aValue() final ColumnValueSelector readSelector = new ComplexFieldReader(SERDE).makeColumnValueSelector(memory, new ConstantFieldPointer(MEMORY_POSITION, -1)); - Assert.assertEquals("foo", readSelector.getObject()); + Assertions.assertEquals("foo", readSelector.getObject()); } private void writeToMemory(final String value) diff --git a/processing/src/test/java/org/apache/druid/frame/field/LongArrayFieldReaderTest.java b/processing/src/test/java/org/apache/druid/frame/field/LongArrayFieldReaderTest.java index f679bb2b3ed9..dff4a0342045 100644 --- a/processing/src/test/java/org/apache/druid/frame/field/LongArrayFieldReaderTest.java +++ b/processing/src/test/java/org/apache/druid/frame/field/LongArrayFieldReaderTest.java @@ -24,16 +24,14 @@ import org.apache.druid.java.util.common.ISE; import org.apache.druid.segment.ColumnValueSelector; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; -import org.mockito.quality.Strictness; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.ArrayList; import java.util.Arrays; @@ -41,13 +39,11 @@ import java.util.List; import java.util.stream.Collectors; +@ExtendWith(MockitoExtension.class) public class LongArrayFieldReaderTest extends InitializedNullHandlingTest { private static final long MEMORY_POSITION = 1; - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS); - @Mock public ColumnValueSelector writeSelector; @@ -82,14 +78,14 @@ public class LongArrayFieldReaderTest extends InitializedNullHandlingTest LONGS_LIST_2 = Arrays.stream(LONGS_ARRAY_2).map(val -> (Long) val).collect(Collectors.toList()); } - @Before + @BeforeEach public void setUp() { memory = WritableMemory.allocate(1000); fieldWriter = NumericArrayFieldWriter.getLongArrayFieldWriter(writeSelector); } - @After + @AfterEach public void tearDown() { fieldWriter.close(); @@ -99,28 +95,28 @@ public void tearDown() public void test_isNull_null() { writeToMemory(null, MEMORY_POSITION); - Assert.assertTrue(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); + Assertions.assertTrue(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); } @Test public void test_isNull_aValue() { writeToMemory(LONGS_ARRAY_1, MEMORY_POSITION); - Assert.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); + Assertions.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); } @Test public void test_isNull_emptyArray() { writeToMemory(new Object[]{}, MEMORY_POSITION); - Assert.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); + Assertions.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); } @Test public void test_isNull_arrayWithSingleNullElement() { writeToMemory(new Object[]{null}, MEMORY_POSITION); - Assert.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); + Assertions.assertFalse(new LongArrayFieldReader().isNull(memory, MEMORY_POSITION)); } @Test @@ -131,7 +127,7 @@ public void test_makeColumnValueSelector_null() final ColumnValueSelector readSelector = new LongArrayFieldReader().makeColumnValueSelector(memory, new ConstantFieldPointer(MEMORY_POSITION, sz)); - Assert.assertTrue(readSelector.isNull()); + Assertions.assertTrue(readSelector.isNull()); } @Test @@ -198,14 +194,14 @@ private long writeToMemory(final Object value, final long initialPosition) private void assertResults(List expected, Object actual) { if (expected == null) { - Assert.assertNull(actual); + Assertions.assertNull(actual); } - Assert.assertTrue(actual instanceof Object[]); + Assertions.assertTrue(actual instanceof Object[]); List actualList = new ArrayList<>(); for (Object val : (Object[]) actual) { actualList.add((Long) val); } - Assert.assertEquals(expected, actualList); + Assertions.assertEquals(expected, actualList); } } diff --git a/processing/src/test/java/org/apache/druid/frame/key/RowKeyReaderTest.java b/processing/src/test/java/org/apache/druid/frame/key/RowKeyReaderTest.java index e5da585cd7ec..393823fedec4 100644 --- a/processing/src/test/java/org/apache/druid/frame/key/RowKeyReaderTest.java +++ b/processing/src/test/java/org/apache/druid/frame/key/RowKeyReaderTest.java @@ -26,9 +26,9 @@ import org.apache.druid.testing.InitializedNullHandlingTest; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; -import org.junit.Assert; -import org.junit.Test; import org.junit.internal.matchers.ThrowableMessageMatcher; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -81,17 +81,17 @@ public void test_read_oneField() final Object keyPart = keyReader.read(key, i); if (objects.get(i) instanceof Object[]) { - MatcherAssert.assertThat(keyPart, CoreMatchers.instanceOf(Object[].class)); - Assert.assertArrayEquals( - "read: " + signature.getColumnName(i), + Assertions.assertInstanceOf(Object[].class, keyPart); + Assertions.assertArrayEquals( (Object[]) objects.get(i), - (Object[]) keyPart + (Object[]) keyPart, + "read: " + signature.getColumnName(i) ); } else { - Assert.assertEquals( - "read: " + signature.getColumnName(i), + Assertions.assertEquals( objects.get(i), - keyPart + keyPart, + "read: " + signature.getColumnName(i) ); } } @@ -101,10 +101,10 @@ public void test_read_oneField() public void test_hasMultipleValues() { for (int i = 0; i < signature.size(); i++) { - Assert.assertEquals( - "hasMultipleValues: " + signature.getColumnName(i), + Assertions.assertEquals( objects.get(i) instanceof List || objects.get(i) instanceof Object[], - keyReader.hasMultipleValues(key, i) + keyReader.hasMultipleValues(key, i), + "hasMultipleValues: " + signature.getColumnName(i) ); } } @@ -112,13 +112,13 @@ public void test_hasMultipleValues() @Test public void test_trim_zero() { - Assert.assertEquals(RowKey.empty(), keyReader.trim(key, 0)); + Assertions.assertEquals(RowKey.empty(), keyReader.trim(key, 0)); } @Test public void test_trim_one() { - Assert.assertEquals( + Assertions.assertEquals( KeyTestUtils.createKey( RowSignature.builder().add(signature.getColumnName(0), signature.getColumnType(0).get()).build(), FrameType.latestRowBased(), @@ -136,7 +136,7 @@ public void test_trim_oneLessThanFullLength() IntStream.range(0, numFields) .forEach(i -> trimmedSignature.add(signature.getColumnName(i), signature.getColumnType(i).get())); - Assert.assertEquals( + Assertions.assertEquals( KeyTestUtils.createKey( trimmedSignature.build(), FrameType.latestRowBased(), @@ -149,13 +149,13 @@ public void test_trim_oneLessThanFullLength() @Test public void test_trim_fullLength() { - Assert.assertEquals(key, keyReader.trim(key, signature.size())); + Assertions.assertEquals(key, keyReader.trim(key, signature.size())); } @Test public void test_trim_beyondFullLength() { - final IllegalArgumentException e = Assert.assertThrows( + final IllegalArgumentException e = Assertions.assertThrows( IllegalArgumentException.class, () -> keyReader.trim(key, signature.size() + 1) ); @@ -169,7 +169,7 @@ public void test_trimmedKeyReader_zero() RowKey trimmedKey = keyReader.trim(key, 0); RowKeyReader trimmedKeyReader = keyReader.trimmedKeyReader(0); - Assert.assertEquals( + Assertions.assertEquals( Collections.emptyList(), trimmedKeyReader.read(trimmedKey) ); @@ -181,7 +181,7 @@ public void test_trimmedKeyReader_one() RowKey trimmedKey = keyReader.trim(key, 1); RowKeyReader trimmedKeyReader = keyReader.trimmedKeyReader(1); - Assert.assertEquals( + Assertions.assertEquals( objects.subList(0, 1), trimmedKeyReader.read(trimmedKey) ); @@ -194,7 +194,7 @@ public void test_trimmedKeyReader_oneLessThanFullLength() RowKey trimmedKey = keyReader.trim(key, numFields); RowKeyReader trimmedKeyReader = keyReader.trimmedKeyReader(numFields); - Assert.assertEquals( + Assertions.assertEquals( objects.subList(0, numFields), trimmedKeyReader.read(trimmedKey) ); diff --git a/processing/src/test/java/org/apache/druid/frame/processor/TournamentTreeTest.java b/processing/src/test/java/org/apache/druid/frame/processor/TournamentTreeTest.java index 287dc37eb0ee..d6550236098b 100644 --- a/processing/src/test/java/org/apache/druid/frame/processor/TournamentTreeTest.java +++ b/processing/src/test/java/org/apache/druid/frame/processor/TournamentTreeTest.java @@ -23,8 +23,8 @@ import com.google.common.collect.Ordering; import it.unimi.dsi.fastutil.ints.IntComparator; import it.unimi.dsi.fastutil.ints.IntComparators; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.ArrayDeque; import java.util.ArrayList; @@ -40,11 +40,11 @@ public void test_construction_oneElement() final IntComparator intComparator = IntComparators.NATURAL_COMPARATOR; final TournamentTree tree = new TournamentTree(1, intComparator); - Assert.assertEquals(0, tree.getMin()); - Assert.assertArrayEquals( - "construction", + Assertions.assertEquals(0, tree.getMin()); + Assertions.assertArrayEquals( new int[]{0}, - tree.backingArray() + tree.backingArray(), + "construction" ); } @@ -54,11 +54,11 @@ public void test_construction_tenElements_natural() final IntComparator intComparator = IntComparators.NATURAL_COMPARATOR; final TournamentTree tree = new TournamentTree(10, intComparator); - Assert.assertEquals(0, tree.getMin()); - Assert.assertArrayEquals( - "construction", + Assertions.assertEquals(0, tree.getMin()); + Assertions.assertArrayEquals( new int[]{0, 8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15}, - tree.backingArray() + tree.backingArray(), + "construction" ); } @@ -68,11 +68,11 @@ public void test_construction_tenElements_reverse() final IntComparator intComparator = IntComparators.OPPOSITE_COMPARATOR; final TournamentTree tree = new TournamentTree(10, intComparator); - Assert.assertEquals(9, tree.getMin()); - Assert.assertArrayEquals( - "construction", + Assertions.assertEquals(9, tree.getMin()); + Assertions.assertArrayEquals( new int[]{9, 7, 3, 12, 1, 5, 10, 14, 0, 2, 4, 6, 8, 11, 13, 15}, - tree.backingArray() + tree.backingArray(), + "construction" ); } @@ -82,11 +82,11 @@ public void test_construction_sixteenElements_reverse() final IntComparator intComparator = IntComparators.OPPOSITE_COMPARATOR; final TournamentTree tree = new TournamentTree(16, intComparator); - Assert.assertEquals(15, tree.getMin()); - Assert.assertArrayEquals( - "construction", + Assertions.assertEquals(15, tree.getMin()); + Assertions.assertArrayEquals( new int[]{15, 7, 3, 11, 1, 5, 9, 13, 0, 2, 4, 6, 8, 10, 12, 14}, - tree.backingArray() + tree.backingArray(), + "construction" ); } @@ -138,7 +138,7 @@ public void test_merge_eightLists() expected.addAll(Arrays.asList(8, 8)); expected.addAll(Arrays.asList(9, 9)); - Assert.assertEquals(expected, intsRead); + Assertions.assertEquals(expected, intsRead); } @Test @@ -191,6 +191,6 @@ public void test_merge_tenLists() expected.addAll(Arrays.asList(8, 8)); expected.addAll(Arrays.asList(9, 9)); - Assert.assertEquals(expected, intsRead); + Assertions.assertEquals(expected, intsRead); } } diff --git a/processing/src/test/java/org/apache/druid/indexer/partitions/DimensionRangePartitionsSpecTest.java b/processing/src/test/java/org/apache/druid/indexer/partitions/DimensionRangePartitionsSpecTest.java index 7e31569c42d8..f13f1666219e 100644 --- a/processing/src/test/java/org/apache/druid/indexer/partitions/DimensionRangePartitionsSpecTest.java +++ b/processing/src/test/java/org/apache/druid/indexer/partitions/DimensionRangePartitionsSpecTest.java @@ -21,10 +21,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -45,15 +43,12 @@ public class DimensionRangePartitionsSpecTest ); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void serde() { String json = serialize(SPEC); DimensionRangePartitionsSpec spec = deserialize(json); - Assert.assertEquals(SPEC, spec); + Assertions.assertEquals(SPEC, spec); } @Test @@ -109,7 +104,7 @@ public void resolvesMaxFromTargetRowsPerSegment() DimensionRangePartitionsSpec spec = new TestSpecBuilder() .targetRowsPerSegment(123) .build(); - Assert.assertEquals(184, spec.getMaxRowsPerSegment().intValue()); + Assertions.assertEquals(184, spec.getMaxRowsPerSegment().intValue()); } @Test @@ -118,7 +113,7 @@ public void resolvesMaxFromMaxRowsPerSegment() DimensionRangePartitionsSpec spec = new TestSpecBuilder() .maxRowsPerSegment(123) .build(); - Assert.assertEquals(123, spec.getMaxRowsPerSegment().intValue()); + Assertions.assertEquals(123, spec.getMaxRowsPerSegment().intValue()); } @Test @@ -138,7 +133,7 @@ public void getPartitionDimensionFromNonNull() .targetRowsPerSegment(10) .partitionDimensions(partitionDimensions) .build(); - Assert.assertEquals(partitionDimensions, spec.getPartitionDimensions()); + Assertions.assertEquals(partitionDimensions, spec.getPartitionDimensions()); } private static String serialize(Object object) @@ -164,7 +159,7 @@ private static DimensionRangePartitionsSpec deserialize(String serialized) /** * Spec builder used in this test. */ - private class TestSpecBuilder + private static class TestSpecBuilder { private Integer targetRowsPerSegment; private Integer maxRowsPerSegment; @@ -190,9 +185,8 @@ TestSpecBuilder partitionDimensions(List partitionDimensions) void testIllegalArgumentException(String exceptionExpectedMessage) { - exception.expect(IllegalArgumentException.class); - exception.expectMessage(exceptionExpectedMessage); - build(); + Throwable t = Assertions.assertThrows(IllegalArgumentException.class, this::build); + Assertions.assertEquals(exceptionExpectedMessage, t.getMessage()); } DimensionRangePartitionsSpec build() diff --git a/processing/src/test/java/org/apache/druid/java/util/common/RetryUtilsTest.java b/processing/src/test/java/org/apache/druid/java/util/common/RetryUtilsTest.java index 8d0271397d7f..4d267ba4c54f 100644 --- a/processing/src/test/java/org/apache/druid/java/util/common/RetryUtilsTest.java +++ b/processing/src/test/java/org/apache/druid/java/util/common/RetryUtilsTest.java @@ -24,13 +24,15 @@ import org.apache.commons.lang3.mutable.MutableInt; import org.apache.druid.java.util.RetryableException; import org.apache.druid.java.util.common.concurrent.Execs; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class RetryUtilsTest @@ -50,8 +52,8 @@ public void testImmediateSuccess() throws Exception IS_TRANSIENT, 2 ); - Assert.assertEquals("result", "hey", result); - Assert.assertEquals("count", 1, count.get()); + Assertions.assertEquals("hey", result, "result"); + Assertions.assertEquals(1, count.get(), "count"); } @Test @@ -72,8 +74,8 @@ public void testEventualFailure() throws Exception catch (IOException e) { threwExpectedException = e.getMessage().equals("what"); } - Assert.assertTrue("threw expected exception", threwExpectedException); - Assert.assertEquals("count", 2, count.get()); + Assertions.assertTrue(threwExpectedException, "threw expected exception"); + Assertions.assertEquals(2, count.get(), "count"); } @Test @@ -91,15 +93,15 @@ public void testEventualSuccess() throws Exception IS_TRANSIENT, 3 ); - Assert.assertEquals("result", "hey", result); - Assert.assertEquals("count", 2, count.get()); + Assertions.assertEquals("hey", result, "result"); + Assertions.assertEquals(2, count.get(), "count"); } @Test public void testExceptionPredicateNotMatching() { final AtomicInteger count = new AtomicInteger(); - Assert.assertThrows("uhh", IOException.class, () -> { + Assertions.assertThrows(IOException.class, () -> { RetryUtils.retry( () -> { if (count.incrementAndGet() >= 2) { @@ -112,10 +114,11 @@ public void testExceptionPredicateNotMatching() 3 ); }); - Assert.assertEquals("count", 1, count.get()); + Assertions.assertEquals(1, count.get(), "count"); } - @Test(timeout = 5000L) + @Test + @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) public void testInterruptWhileSleepingBetweenTries() { ExecutorService exec = Execs.singleThreaded("test-interrupt"); @@ -133,14 +136,15 @@ public void testInterruptWhileSleepingBetweenTries() Integer.MAX_VALUE )); - Assert.assertThrows("sleep interrupted", ExecutionException.class, future::get); + Assertions.assertThrows(ExecutionException.class, future::get); } finally { exec.shutdownNow(); } } - @Test(timeout = 5000L) + @Test + @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) public void testInterruptRetryLoop() { ExecutorService exec = Execs.singleThreaded("test-interrupt"); @@ -161,7 +165,7 @@ public void testInterruptRetryLoop() true )); - Assert.assertThrows("Current thread is interrupted after [2] tries", ExecutionException.class, future::get); + Assertions.assertThrows(ExecutionException.class, future::get); } finally { exec.shutdownNow(); @@ -183,8 +187,8 @@ public void testExceptionPredicateForRetryableException() throws Exception e -> e instanceof RetryableException, 3 ); - Assert.assertEquals(result, "hey"); - Assert.assertEquals("count", 2, count.get()); + Assertions.assertEquals(result, "hey"); + Assertions.assertEquals(2, count.get(), "count"); } @Test @@ -194,21 +198,21 @@ public void testNextRetrySleepMillis() for (int i = 1; i < 7; ++i) { final long nextSleepMillis = RetryUtils.nextRetrySleepMillis(i); - Assert.assertTrue(nextSleepMillis >= 0); - Assert.assertTrue(nextSleepMillis <= (2_000 * Math.pow(2, i - 1))); + Assertions.assertTrue(nextSleepMillis >= 0); + Assertions.assertTrue(nextSleepMillis <= (2_000 * Math.pow(2, i - 1))); totalSleepTimeMillis += nextSleepMillis; } for (int i = 7; i < 11; ++i) { final long nextSleepMillis = RetryUtils.nextRetrySleepMillis(i); - Assert.assertTrue(nextSleepMillis >= 0); - Assert.assertTrue(nextSleepMillis <= 120_000); + Assertions.assertTrue(nextSleepMillis >= 0); + Assertions.assertTrue(nextSleepMillis <= 120_000); totalSleepTimeMillis += nextSleepMillis; } - Assert.assertTrue(totalSleepTimeMillis > 3 * 60_000); - Assert.assertTrue(totalSleepTimeMillis < 8 * 60_000); + Assertions.assertTrue(totalSleepTimeMillis > 3 * 60_000); + Assertions.assertTrue(totalSleepTimeMillis < 8 * 60_000); } } diff --git a/processing/src/test/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMakerTest.java b/processing/src/test/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMakerTest.java index b471c24b40d1..6f1d87a8c35e 100644 --- a/processing/src/test/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMakerTest.java +++ b/processing/src/test/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMakerTest.java @@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.apache.druid.java.util.common.StringUtils; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.nio.charset.CharsetEncoder; @@ -52,14 +52,14 @@ public void testStrings() throws JsonProcessingException String s1 = "hello"; node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(s1)); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(s1, result); + Assertions.assertEquals(s1, result); String s2 = "hello \uD900"; String s2Json = "\"hello \uD900\""; node = OBJECT_MAPPER.readTree(s2Json); result = FLATTENER_MAKER.finalizeConversionForMap(node); // normal equals doesn't pass for this, so check using the same - Assert.assertArrayEquals(StringUtils.toUtf8(s2), StringUtils.toUtf8((String) result)); + Assertions.assertArrayEquals(StringUtils.toUtf8(s2), StringUtils.toUtf8((String) result)); } @Test @@ -69,35 +69,35 @@ public void testNumbers() throws JsonProcessingException Object result; Integer i1 = 123; node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(i1)); - Assert.assertTrue(node.isInt()); + Assertions.assertTrue(node.isInt()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(i1.longValue(), result); + Assertions.assertEquals(i1.longValue(), result); Long l1 = 1L + Integer.MAX_VALUE; node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(l1)); - Assert.assertTrue(node.isLong()); + Assertions.assertTrue(node.isLong()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(l1, result); + Assertions.assertEquals(l1, result); Float f1 = 230.333f; node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(f1)); - Assert.assertTrue(node.isNumber()); + Assertions.assertTrue(node.isNumber()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(230.333, result); + Assertions.assertEquals(230.333, result); // float.max value plus some (using float max constant, even in a comment makes checkstyle sad) Double d1 = 0x1.fffffeP+127 + 100.0; node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(d1)); - Assert.assertTrue(node.isDouble()); + Assertions.assertTrue(node.isDouble()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(d1, result); + Assertions.assertEquals(d1, result); BigInteger bigInt = new BigInteger(String.valueOf(Long.MAX_VALUE)); BigInteger bigInt2 = new BigInteger(String.valueOf(Long.MAX_VALUE)); node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(bigInt.add(bigInt2))); - Assert.assertTrue(node.isBigInteger()); + Assertions.assertTrue(node.isBigInteger()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(bigInt.add(bigInt).doubleValue(), result); + Assertions.assertEquals(bigInt.add(bigInt).doubleValue(), result); } @Test @@ -105,9 +105,9 @@ public void testBoolean() throws JsonProcessingException { Boolean bool = true; JsonNode node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(bool)); - Assert.assertTrue(node.isBoolean()); + Assertions.assertTrue(node.isBoolean()); Object result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(bool, result); + Assertions.assertEquals(bool, result); } @Test @@ -117,7 +117,7 @@ public void testBinary() // make binary node directly for test, object mapper used in tests deserializes to TextNode with base64 string JsonNode node = new BinaryNode(data); Object result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(data, result); + Assertions.assertEquals(data, result); } @Test @@ -128,9 +128,9 @@ public void testNested() throws JsonProcessingException List intArray = ImmutableList.of(1, 2, 3); List expectedIntArray = ImmutableList.of(1L, 2L, 3L); node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(intArray)); - Assert.assertTrue(node.isArray()); + Assertions.assertTrue(node.isArray()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(expectedIntArray, result); + Assertions.assertEquals(expectedIntArray, result); Map theMap = ImmutableMap.builder() @@ -156,9 +156,9 @@ public void testNested() throws JsonProcessingException .put("anotherList", expectedIntArray) .build(); node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(theMap)); - Assert.assertTrue(node.isObject()); + Assertions.assertTrue(node.isObject()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(expectedMap, result); + Assertions.assertEquals(expectedMap, result); List theList = ImmutableList.of( theMap, @@ -169,9 +169,9 @@ public void testNested() throws JsonProcessingException expectedMap ); node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(theList)); - Assert.assertTrue(node.isArray()); + Assertions.assertTrue(node.isArray()); result = FLATTENER_MAKER.finalizeConversionForMap(node); - Assert.assertEquals(expectedList, result); + Assertions.assertEquals(expectedList, result); } @Test @@ -191,12 +191,12 @@ public void testDiscovery() throws JsonProcessingException .build(); JsonNode node = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(theMap)); - Assert.assertTrue(node.isObject()); - Assert.assertEquals( + Assertions.assertTrue(node.isObject()); + Assertions.assertEquals( ImmutableSet.of("bool", "int", "long", "float", "double", "binary", "list", "anotherList"), ImmutableSet.copyOf(FLATTENER_MAKER.discoverRootFields(node)) ); - Assert.assertEquals( + Assertions.assertEquals( ImmutableSet.of("bool", "int", "long", "float", "double", "binary", "list", "anotherList", "nested"), ImmutableSet.copyOf(FLATTENER_MAKER_NESTED.discoverRootFields(node)) ); @@ -206,12 +206,12 @@ public void testDiscovery() throws JsonProcessingException public void testCharsetFix() { final CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder(); - Assert.assertEquals("hello", JSONFlattenerMaker.charsetFix("hello", encoder)); - Assert.assertEquals("Apache® Druid", JSONFlattenerMaker.charsetFix("Apache® Druid", encoder)); - Assert.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uD900", encoder)); - Assert.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uD83D", encoder)); - Assert.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uDCAF", encoder)); - Assert.assertEquals("hello💯", JSONFlattenerMaker.charsetFix("hello\uD83D\uDCAF", encoder)); - Assert.assertEquals("héllö", JSONFlattenerMaker.charsetFix("héllö", encoder)); + Assertions.assertEquals("hello", JSONFlattenerMaker.charsetFix("hello", encoder)); + Assertions.assertEquals("Apache® Druid", JSONFlattenerMaker.charsetFix("Apache® Druid", encoder)); + Assertions.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uD900", encoder)); + Assertions.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uD83D", encoder)); + Assertions.assertEquals("hello?", JSONFlattenerMaker.charsetFix("hello\uDCAF", encoder)); + Assertions.assertEquals("hello💯", JSONFlattenerMaker.charsetFix("hello\uD83D\uDCAF", encoder)); + Assertions.assertEquals("héllö", JSONFlattenerMaker.charsetFix("héllö", encoder)); } } diff --git a/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java b/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java index b29cf44ef41b..61974d424d2f 100644 --- a/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java +++ b/processing/src/test/java/org/apache/druid/java/util/emitter/core/LoggingEmitterTest.java @@ -24,12 +24,11 @@ import org.apache.druid.java.util.common.logger.Logger; import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; import org.apache.druid.java.util.emitter.service.UnitEvent; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.io.IOException; @@ -42,14 +41,14 @@ public class LoggingEmitterTest { - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public File tempFolder; private List serializedObjects; private ObjectMapper trackingMapper; private LoggingEmitter emitter; - @Before + @BeforeEach public void setUp() { serializedObjects = new ArrayList<>(); @@ -82,7 +81,7 @@ private LoggingEmitter createEmitter(boolean shouldFilterMetrics, String allowed return emitter; } - @After + @AfterEach public void tearDown() { if (emitter != null) { @@ -103,7 +102,7 @@ public void testEmitAllWhenFilteringDisabled() emitter.emit(ServiceMetricEvent.builder().setMetric("jvm/mem/used", 512).build("test", "localhost")); emitter.emit(ServiceMetricEvent.builder().setMetric("some/random/metric", 1).build("test", "localhost")); - Assert.assertEquals("All events should be serialized (logged)", 3, serializedObjects.size()); + Assertions.assertEquals(3, serializedObjects.size(), "All events should be serialized (logged)"); } /** @@ -121,7 +120,7 @@ public void testFilterWithDefaultResource() // "some/unlisted/metric" is NOT in the default list emitter.emit(ServiceMetricEvent.builder().setMetric("some/unlisted/metric", 1).build("test", "localhost")); - Assert.assertEquals("Only the allowed metric should be serialized", 1, serializedObjects.size()); + Assertions.assertEquals(1, serializedObjects.size(), "Only the allowed metric should be serialized"); } /** @@ -137,7 +136,7 @@ public void testFilterWithCustomFilePath() throws IOException emitter.emit(ServiceMetricEvent.builder().setMetric("jvm/mem/used", 512).build("test", "localhost")); emitter.emit(ServiceMetricEvent.builder().setMetric("query/bytes", 2048).build("test", "localhost")); - Assert.assertEquals("Only allowed metrics should be serialized", 2, serializedObjects.size()); + Assertions.assertEquals(2, serializedObjects.size(), "Only allowed metrics should be serialized"); } /** @@ -153,7 +152,7 @@ public void testNonMetricEventsAlwaysPassThrough() throws IOException // This is NOT a ServiceMetricEvent, so it should bypass the allowlist filter emitter.emit(new UnitEvent("alerts", 42)); - Assert.assertEquals("Non-metric events should bypass the allowlist filter", 1, serializedObjects.size()); + Assertions.assertEquals(1, serializedObjects.size(), "Non-metric events should bypass the allowlist filter"); } /** @@ -169,7 +168,7 @@ public void testMissingCustomPathFallsBackToDefault() emitter.emit(ServiceMetricEvent.builder().setMetric("query/time", 100).build("test", "localhost")); emitter.emit(ServiceMetricEvent.builder().setMetric("some/unlisted/metric", 1).build("test", "localhost")); - Assert.assertEquals("Fallback to default should allow listed metrics only", 1, serializedObjects.size()); + Assertions.assertEquals(1, serializedObjects.size(), "Fallback to default should allow listed metrics only"); } /** @@ -184,7 +183,7 @@ public void testEmptyAllowlistBlocksAllMetrics() throws IOException emitter.emit(ServiceMetricEvent.builder().setMetric("query/time", 100).build("test", "localhost")); emitter.emit(new UnitEvent("alerts", 42)); - Assert.assertEquals("Only non-metric event should pass through", 1, serializedObjects.size()); + Assertions.assertEquals(1, serializedObjects.size(), "Only non-metric event should pass through"); } /** @@ -199,12 +198,12 @@ public void testFilterDisabledIgnoresPath() throws IOException emitter.emit(ServiceMetricEvent.builder().setMetric("query/time", 100).build("test", "localhost")); emitter.emit(ServiceMetricEvent.builder().setMetric("jvm/mem/used", 512).build("test", "localhost")); - Assert.assertEquals("All events should pass when filtering is disabled", 2, serializedObjects.size()); + Assertions.assertEquals(2, serializedObjects.size(), "All events should pass when filtering is disabled"); } private File createAllowlistFile(String jsonContent) throws IOException { - final File file = tempFolder.newFile("allowedMetrics.json"); + final File file = new File(tempFolder, "allowedMetrics.json"); try (Writer writer = new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8)) { writer.write(jsonContent); } diff --git a/processing/src/test/java/org/apache/druid/math/expr/ExpressionTypeTest.java b/processing/src/test/java/org/apache/druid/math/expr/ExpressionTypeTest.java index 2f6a4bd4dca2..52c8994c779e 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/ExpressionTypeTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/ExpressionTypeTest.java @@ -23,92 +23,87 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.ValueType; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class ExpressionTypeTest { private static final ObjectMapper MAPPER = new ObjectMapper(); private static final ExpressionType SOME_COMPLEX = new ExpressionType(ExprType.COMPLEX, "foo", null); - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - @Test public void testSerde() throws JsonProcessingException { - Assert.assertEquals(ExpressionType.STRING, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.STRING), ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.LONG), ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.DOUBLE), ExpressionType.class)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.STRING_ARRAY), ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.LONG_ARRAY), ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.DOUBLE_ARRAY), ExpressionType.class)); - Assert.assertEquals(SOME_COMPLEX, MAPPER.readValue(MAPPER.writeValueAsString(SOME_COMPLEX), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.STRING), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.LONG), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.DOUBLE), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.STRING_ARRAY), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.LONG_ARRAY), ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue(MAPPER.writeValueAsString(ExpressionType.DOUBLE_ARRAY), ExpressionType.class)); + Assertions.assertEquals(SOME_COMPLEX, MAPPER.readValue(MAPPER.writeValueAsString(SOME_COMPLEX), ExpressionType.class)); } @Test public void testSerdeFromString() throws JsonProcessingException { - Assert.assertEquals(ExpressionType.STRING, MAPPER.readValue("\"STRING\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG, MAPPER.readValue("\"LONG\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("\"DOUBLE\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING, MAPPER.readValue("\"STRING\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG, MAPPER.readValue("\"LONG\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("\"DOUBLE\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); ExpressionType whatHaveIdone = new ExpressionType(ExprType.ARRAY, null, new ExpressionType(ExprType.ARRAY, null, SOME_COMPLEX)); - Assert.assertEquals(whatHaveIdone, MAPPER.readValue("\"ARRAY>>\"", ExpressionType.class)); + Assertions.assertEquals(whatHaveIdone, MAPPER.readValue("\"ARRAY>>\"", ExpressionType.class)); - Assert.assertEquals(SOME_COMPLEX, MAPPER.readValue("\"COMPLEX\"", ExpressionType.class)); + Assertions.assertEquals(SOME_COMPLEX, MAPPER.readValue("\"COMPLEX\"", ExpressionType.class)); // make sure legacy works too - Assert.assertEquals(ExpressionType.STRING, MAPPER.readValue("\"string\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG, MAPPER.readValue("\"long\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("\"double\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"STRING_ARRAY\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"LONG_ARRAY\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"DOUBLE_ARRAY\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"string_array\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"long_array\"", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"double_array\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING, MAPPER.readValue("\"string\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG, MAPPER.readValue("\"long\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("\"double\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"STRING_ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"LONG_ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"DOUBLE_ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"string_array\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"long_array\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"double_array\"", ExpressionType.class)); // ARRAY<*> and COMPLEX<*> patterns must match exactly ... - Assert.assertNotEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"array\"", ExpressionType.class)); - Assert.assertNotEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"array\"", ExpressionType.class)); - Assert.assertNotEquals(SOME_COMPLEX, MAPPER.readValue("\"COMPLEX\"", ExpressionType.class)); + Assertions.assertNotEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("\"array\"", ExpressionType.class)); + Assertions.assertNotEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("\"array\"", ExpressionType.class)); + Assertions.assertNotEquals(SOME_COMPLEX, MAPPER.readValue("\"COMPLEX\"", ExpressionType.class)); // this works though because array recursively calls on element type... - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("\"ARRAY\"", ExpressionType.class)); } @Test public void testFutureProof() throws JsonProcessingException { // in case we ever want to switch from string serde to JSON objects for type info, be ready - Assert.assertEquals(ExpressionType.STRING, MAPPER.readValue("{\"type\":\"STRING\"}", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG, MAPPER.readValue("{\"type\":\"LONG\"}", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("{\"type\":\"DOUBLE\"}", ExpressionType.class)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"STRING\"}}", ExpressionType.class)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"LONG\"}}", ExpressionType.class)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"DOUBLE\"}}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING, MAPPER.readValue("{\"type\":\"STRING\"}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG, MAPPER.readValue("{\"type\":\"LONG\"}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE, MAPPER.readValue("{\"type\":\"DOUBLE\"}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"STRING\"}}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"LONG\"}}", ExpressionType.class)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"DOUBLE\"}}", ExpressionType.class)); - Assert.assertEquals(SOME_COMPLEX, MAPPER.readValue("{\"type\":\"COMPLEX\", \"complexTypeName\":\"foo\"}", ExpressionType.class)); + Assertions.assertEquals(SOME_COMPLEX, MAPPER.readValue("{\"type\":\"COMPLEX\", \"complexTypeName\":\"foo\"}", ExpressionType.class)); ExpressionType whatHaveIdone = new ExpressionType(ExprType.ARRAY, null, new ExpressionType(ExprType.ARRAY, null, SOME_COMPLEX)); - Assert.assertEquals(whatHaveIdone, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"COMPLEX\", \"complexTypeName\":\"foo\"}}}", ExpressionType.class)); + Assertions.assertEquals(whatHaveIdone, MAPPER.readValue("{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"ARRAY\", \"elementType\":{\"type\":\"COMPLEX\", \"complexTypeName\":\"foo\"}}}", ExpressionType.class)); } @Test public void testConvertFromColumnType() { - Assert.assertNull(ExpressionType.fromColumnType(null)); - Assert.assertEquals(ExpressionType.LONG, ExpressionType.fromColumnType(ColumnType.LONG)); - Assert.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnType(ColumnType.FLOAT)); - Assert.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnType(ColumnType.DOUBLE)); - Assert.assertEquals(ExpressionType.STRING, ExpressionType.fromColumnType(ColumnType.STRING)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, ExpressionType.fromColumnType(ColumnType.LONG_ARRAY)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, ExpressionType.fromColumnType(ColumnType.DOUBLE_ARRAY)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, ExpressionType.fromColumnType(ColumnType.STRING_ARRAY)); - Assert.assertEquals( + Assertions.assertNull(ExpressionType.fromColumnType(null)); + Assertions.assertEquals(ExpressionType.LONG, ExpressionType.fromColumnType(ColumnType.LONG)); + Assertions.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnType(ColumnType.FLOAT)); + Assertions.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnType(ColumnType.DOUBLE)); + Assertions.assertEquals(ExpressionType.STRING, ExpressionType.fromColumnType(ColumnType.STRING)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, ExpressionType.fromColumnType(ColumnType.LONG_ARRAY)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, ExpressionType.fromColumnType(ColumnType.DOUBLE_ARRAY)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, ExpressionType.fromColumnType(ColumnType.STRING_ARRAY)); + Assertions.assertEquals( SOME_COMPLEX, ExpressionType.fromColumnType(ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName())) ); @@ -125,20 +120,20 @@ public void testConvertFromColumnType() ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName()) ) ); - Assert.assertEquals(complexArray, ExpressionType.fromColumnType(complexArrayColumn)); + Assertions.assertEquals(complexArray, ExpressionType.fromColumnType(complexArrayColumn)); } @Test public void testConvertFromColumnTypeStrict() { - Assert.assertEquals(ExpressionType.LONG, ExpressionType.fromColumnTypeStrict(ColumnType.LONG)); - Assert.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnTypeStrict(ColumnType.FLOAT)); - Assert.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnTypeStrict(ColumnType.DOUBLE)); - Assert.assertEquals(ExpressionType.STRING, ExpressionType.fromColumnTypeStrict(ColumnType.STRING)); - Assert.assertEquals(ExpressionType.LONG_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.LONG_ARRAY)); - Assert.assertEquals(ExpressionType.DOUBLE_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.DOUBLE_ARRAY)); - Assert.assertEquals(ExpressionType.STRING_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.STRING_ARRAY)); - Assert.assertEquals( + Assertions.assertEquals(ExpressionType.LONG, ExpressionType.fromColumnTypeStrict(ColumnType.LONG)); + Assertions.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnTypeStrict(ColumnType.FLOAT)); + Assertions.assertEquals(ExpressionType.DOUBLE, ExpressionType.fromColumnTypeStrict(ColumnType.DOUBLE)); + Assertions.assertEquals(ExpressionType.STRING, ExpressionType.fromColumnTypeStrict(ColumnType.STRING)); + Assertions.assertEquals(ExpressionType.LONG_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.LONG_ARRAY)); + Assertions.assertEquals(ExpressionType.DOUBLE_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.DOUBLE_ARRAY)); + Assertions.assertEquals(ExpressionType.STRING_ARRAY, ExpressionType.fromColumnTypeStrict(ColumnType.STRING_ARRAY)); + Assertions.assertEquals( SOME_COMPLEX, ExpressionType.fromColumnTypeStrict(ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName())) ); @@ -155,27 +150,29 @@ public void testConvertFromColumnTypeStrict() ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName()) ) ); - Assert.assertEquals(complexArray, ExpressionType.fromColumnTypeStrict(complexArrayColumn)); + Assertions.assertEquals(complexArray, ExpressionType.fromColumnTypeStrict(complexArrayColumn)); } @Test public void testConvertFromColumnTypeStrictNull() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Unsupported unknown value type"); - ExpressionType.fromColumnTypeStrict(null); + IllegalStateException e = Assertions.assertThrows( + IllegalStateException.class, + () -> ExpressionType.fromColumnTypeStrict(null) + ); + Assertions.assertTrue(e.getMessage().contains("Unsupported unknown value type")); } @Test public void testConvertToColumnType() { - Assert.assertEquals(ColumnType.LONG, ExpressionType.toColumnType(ExpressionType.LONG)); - Assert.assertEquals(ColumnType.DOUBLE, ExpressionType.toColumnType(ExpressionType.DOUBLE)); - Assert.assertEquals(ColumnType.STRING, ExpressionType.toColumnType(ExpressionType.STRING)); - Assert.assertEquals(ColumnType.LONG_ARRAY, ExpressionType.toColumnType(ExpressionType.LONG_ARRAY)); - Assert.assertEquals(ColumnType.DOUBLE_ARRAY, ExpressionType.toColumnType(ExpressionType.DOUBLE_ARRAY)); - Assert.assertEquals(ColumnType.STRING_ARRAY, ExpressionType.toColumnType(ExpressionType.STRING_ARRAY)); - Assert.assertEquals( + Assertions.assertEquals(ColumnType.LONG, ExpressionType.toColumnType(ExpressionType.LONG)); + Assertions.assertEquals(ColumnType.DOUBLE, ExpressionType.toColumnType(ExpressionType.DOUBLE)); + Assertions.assertEquals(ColumnType.STRING, ExpressionType.toColumnType(ExpressionType.STRING)); + Assertions.assertEquals(ColumnType.LONG_ARRAY, ExpressionType.toColumnType(ExpressionType.LONG_ARRAY)); + Assertions.assertEquals(ColumnType.DOUBLE_ARRAY, ExpressionType.toColumnType(ExpressionType.DOUBLE_ARRAY)); + Assertions.assertEquals(ColumnType.STRING_ARRAY, ExpressionType.toColumnType(ExpressionType.STRING_ARRAY)); + Assertions.assertEquals( ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName()), ExpressionType.toColumnType(SOME_COMPLEX) ); @@ -192,6 +189,6 @@ public void testConvertToColumnType() ColumnType.ofComplex(SOME_COMPLEX.getComplexTypeName()) ) ); - Assert.assertEquals(complexArrayColumn, ExpressionType.toColumnType(complexArray)); + Assertions.assertEquals(complexArrayColumn, ExpressionType.toColumnType(complexArray)); } } diff --git a/processing/src/test/java/org/apache/druid/math/expr/vector/FilteredVectorInputBindingTest.java b/processing/src/test/java/org/apache/druid/math/expr/vector/FilteredVectorInputBindingTest.java index 9379ffacb203..3ae3c6892b33 100644 --- a/processing/src/test/java/org/apache/druid/math/expr/vector/FilteredVectorInputBindingTest.java +++ b/processing/src/test/java/org/apache/druid/math/expr/vector/FilteredVectorInputBindingTest.java @@ -22,9 +22,9 @@ import org.apache.druid.math.expr.SettableVectorInputBinding; import org.apache.druid.query.filter.vector.VectorMatch; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class FilteredVectorInputBindingTest extends InitializedNullHandlingTest { @@ -74,7 +74,7 @@ public class FilteredVectorInputBindingTest extends InitializedNullHandlingTest private SettableVectorInputBinding baseBinding; - @Before + @BeforeEach public void setup() { baseBinding = new SettableVectorInputBinding(VECTOR_SIZE); @@ -95,10 +95,10 @@ public void testFilterString() matchMaker.setSelectionSize(3); final Object[] strings = filteredVectorInputBinding.getObjectVector("string"); - Assert.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertEquals("1", strings[0]); - Assert.assertEquals("3", strings[1]); - Assert.assertEquals("4", strings[2]); + Assertions.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertEquals("1", strings[0]); + Assertions.assertEquals("3", strings[1]); + Assertions.assertEquals("4", strings[2]); } @Test @@ -115,14 +115,14 @@ public void testFilterLongWithNull() long[] longs = filteredVectorInputBinding.getLongVector("long"); boolean[] nulls = filteredVectorInputBinding.getNullVector("long"); - Assert.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertNotNull(nulls); - Assert.assertEquals(1L, longs[0]); - Assert.assertEquals(3L, longs[1]); - Assert.assertEquals(4L, longs[2]); - Assert.assertFalse(nulls[0]); - Assert.assertTrue(nulls[1]); - Assert.assertFalse(nulls[2]); + Assertions.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertNotNull(nulls); + Assertions.assertEquals(1L, longs[0]); + Assertions.assertEquals(3L, longs[1]); + Assertions.assertEquals(4L, longs[2]); + Assertions.assertFalse(nulls[0]); + Assertions.assertTrue(nulls[1]); + Assertions.assertFalse(nulls[2]); selection[0] = 0; selection[1] = 2; @@ -133,18 +133,18 @@ public void testFilterLongWithNull() longs = filteredVectorInputBinding.getLongVector("long"); nulls = filteredVectorInputBinding.getNullVector("long"); - Assert.assertEquals(5, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertNotNull(nulls); - Assert.assertEquals(0L, longs[0]); - Assert.assertEquals(2L, longs[1]); - Assert.assertEquals(5L, longs[2]); - Assert.assertEquals(6L, longs[3]); - Assert.assertEquals(7L, longs[4]); - Assert.assertFalse(nulls[0]); - Assert.assertFalse(nulls[1]); - Assert.assertFalse(nulls[2]); - Assert.assertTrue(nulls[3]); - Assert.assertFalse(nulls[4]); + Assertions.assertEquals(5, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertNotNull(nulls); + Assertions.assertEquals(0L, longs[0]); + Assertions.assertEquals(2L, longs[1]); + Assertions.assertEquals(5L, longs[2]); + Assertions.assertEquals(6L, longs[3]); + Assertions.assertEquals(7L, longs[4]); + Assertions.assertFalse(nulls[0]); + Assertions.assertFalse(nulls[1]); + Assertions.assertFalse(nulls[2]); + Assertions.assertTrue(nulls[3]); + Assertions.assertFalse(nulls[4]); selection[0] = 1; @@ -154,14 +154,14 @@ public void testFilterLongWithNull() longs = filteredVectorInputBinding.getLongVector("long"); nulls = filteredVectorInputBinding.getNullVector("long"); - Assert.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertNotNull(nulls); - Assert.assertEquals(1L, longs[0]); - Assert.assertEquals(3L, longs[1]); - Assert.assertEquals(4L, longs[2]); - Assert.assertFalse(nulls[0]); - Assert.assertTrue(nulls[1]); - Assert.assertFalse(nulls[2]); + Assertions.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertNotNull(nulls); + Assertions.assertEquals(1L, longs[0]); + Assertions.assertEquals(3L, longs[1]); + Assertions.assertEquals(4L, longs[2]); + Assertions.assertFalse(nulls[0]); + Assertions.assertTrue(nulls[1]); + Assertions.assertFalse(nulls[2]); } @Test @@ -178,10 +178,10 @@ public void testDoubles() double[] doubles = filteredVectorInputBinding.getDoubleVector("double"); boolean[] nulls = filteredVectorInputBinding.getNullVector("double"); - Assert.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertEquals(1.1, doubles[0], 0.0); - Assert.assertEquals(3.3, doubles[1], 0.0); - Assert.assertEquals(4.4, doubles[2], 0.0); + Assertions.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertEquals(1.1, doubles[0], 0.0); + Assertions.assertEquals(3.3, doubles[1], 0.0); + Assertions.assertEquals(4.4, doubles[2], 0.0); selection[0] = 0; selection[1] = 2; @@ -192,13 +192,13 @@ public void testDoubles() doubles = filteredVectorInputBinding.getDoubleVector("double"); nulls = filteredVectorInputBinding.getNullVector("double"); - Assert.assertEquals(5, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertEquals(5, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertEquals(0.0, doubles[0], 0.0); - Assert.assertEquals(2.2, doubles[1], 0.0); - Assert.assertEquals(5.5, doubles[2], 0.0); - Assert.assertEquals(6.6, doubles[3], 0.0); - Assert.assertEquals(7.7, doubles[4], 0.0); + Assertions.assertEquals(0.0, doubles[0], 0.0); + Assertions.assertEquals(2.2, doubles[1], 0.0); + Assertions.assertEquals(5.5, doubles[2], 0.0); + Assertions.assertEquals(6.6, doubles[3], 0.0); + Assertions.assertEquals(7.7, doubles[4], 0.0); selection[0] = 1; selection[1] = 3; @@ -207,10 +207,10 @@ public void testDoubles() doubles = filteredVectorInputBinding.getDoubleVector("double"); nulls = filteredVectorInputBinding.getNullVector("double"); - Assert.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); + Assertions.assertEquals(3, filteredVectorInputBinding.getCurrentVectorSize()); - Assert.assertEquals(1.1, doubles[0], 0.0); - Assert.assertEquals(3.3, doubles[1], 0.0); - Assert.assertEquals(4.4, doubles[2], 0.0); + Assertions.assertEquals(1.1, doubles[0], 0.0); + Assertions.assertEquals(3.3, doubles[1], 0.0); + Assertions.assertEquals(4.4, doubles[2], 0.0); } } diff --git a/processing/src/test/java/org/apache/druid/metadata/MetadataStorageConnectorConfigTest.java b/processing/src/test/java/org/apache/druid/metadata/MetadataStorageConnectorConfigTest.java index 31c3ad33bcc5..3234d18acc9f 100644 --- a/processing/src/test/java/org/apache/druid/metadata/MetadataStorageConnectorConfigTest.java +++ b/processing/src/test/java/org/apache/druid/metadata/MetadataStorageConnectorConfigTest.java @@ -21,8 +21,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Map; @@ -77,8 +77,8 @@ public void testEquals() throws IOException "user", "\"nothing\"" ); - Assert.assertEquals(metadataStorageConnectorConfig, metadataStorageConnectorConfig2); - Assert.assertEquals(metadataStorageConnectorConfig.hashCode(), metadataStorageConnectorConfig2.hashCode()); + Assertions.assertEquals(metadataStorageConnectorConfig, metadataStorageConnectorConfig2); + Assertions.assertEquals(metadataStorageConnectorConfig.hashCode(), metadataStorageConnectorConfig2.hashCode()); } private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -133,12 +133,12 @@ private void testMetadataStorageConnectionConfig( MetadataStorageConnectorConfig.class ); - Assert.assertEquals(host, config.getHost()); - Assert.assertEquals(port, config.getPort()); - Assert.assertEquals(connectURI, config.getConnectURI()); - Assert.assertEquals(user, config.getUser()); - Assert.assertEquals(pwd, config.getPassword()); - Assert.assertNull(config.getDbcpProperties()); + Assertions.assertEquals(host, config.getHost()); + Assertions.assertEquals(port, config.getPort()); + Assertions.assertEquals(connectURI, config.getConnectURI()); + Assertions.assertEquals(user, config.getUser()); + Assertions.assertEquals(pwd, config.getPassword()); + Assertions.assertNull(config.getDbcpProperties()); } @Test @@ -180,14 +180,14 @@ private void testDbcpPropertiesFile( MetadataStorageConnectorConfig.class ); - Assert.assertEquals(host, config.getHost()); - Assert.assertEquals(port, config.getPort()); - Assert.assertEquals(connectURI, config.getConnectURI()); - Assert.assertEquals(user, config.getUser()); - Assert.assertEquals(pwd, config.getPassword()); + Assertions.assertEquals(host, config.getHost()); + Assertions.assertEquals(port, config.getPort()); + Assertions.assertEquals(connectURI, config.getConnectURI()); + Assertions.assertEquals(user, config.getUser()); + Assertions.assertEquals(pwd, config.getPassword()); Properties dbcpProperties = config.getDbcpProperties(); - Assert.assertEquals(dbcpProperties.getProperty("maxConnLifetimeMillis"), "1200000"); - Assert.assertEquals(dbcpProperties.getProperty("defaultQueryTimeout"), "30000"); + Assertions.assertEquals(dbcpProperties.getProperty("maxConnLifetimeMillis"), "1200000"); + Assertions.assertEquals(dbcpProperties.getProperty("defaultQueryTimeout"), "30000"); } @Test @@ -196,9 +196,9 @@ public void testCreate() Map props = ImmutableMap.of("key", "value"); MetadataStorageConnectorConfig config = MetadataStorageConnectorConfig.create("connectURI", "user", "pwd", props); - Assert.assertEquals("connectURI", config.getConnectURI()); - Assert.assertEquals("user", config.getUser()); - Assert.assertEquals("pwd", config.getPassword()); - Assert.assertEquals(1, config.getDbcpProperties().size()); + Assertions.assertEquals("connectURI", config.getConnectURI()); + Assertions.assertEquals("user", config.getUser()); + Assertions.assertEquals("pwd", config.getPassword()); + Assertions.assertEquals(1, config.getDbcpProperties().size()); } } diff --git a/processing/src/test/java/org/apache/druid/query/QueryInterruptedExceptionTest.java b/processing/src/test/java/org/apache/druid/query/QueryInterruptedExceptionTest.java index 70e688e46214..1e60031e6ef7 100644 --- a/processing/src/test/java/org/apache/druid/query/QueryInterruptedExceptionTest.java +++ b/processing/src/test/java/org/apache/druid/query/QueryInterruptedExceptionTest.java @@ -23,8 +23,8 @@ import org.apache.druid.java.util.common.ISE; import org.apache.druid.java.util.common.UOE; import org.apache.druid.segment.TestHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.concurrent.CancellationException; @@ -35,16 +35,16 @@ public class QueryInterruptedExceptionTest @Test public void testErrorCode() { - Assert.assertEquals( + Assertions.assertEquals( "Query cancelled", new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorCode() ); - Assert.assertEquals("Query cancelled", new QueryInterruptedException(new CancellationException()).getErrorCode()); - Assert.assertEquals("Query interrupted", new QueryInterruptedException(new InterruptedException()).getErrorCode()); - Assert.assertEquals("Unsupported operation", new QueryInterruptedException(new UOE("Unsupported")).getErrorCode()); - Assert.assertEquals("Unknown exception", new QueryInterruptedException(null).getErrorCode()); - Assert.assertEquals("Unknown exception", new QueryInterruptedException(new ISE("Something bad!")).getErrorCode()); - Assert.assertEquals( + Assertions.assertEquals("Query cancelled", new QueryInterruptedException(new CancellationException()).getErrorCode()); + Assertions.assertEquals("Query interrupted", new QueryInterruptedException(new InterruptedException()).getErrorCode()); + Assertions.assertEquals("Unsupported operation", new QueryInterruptedException(new UOE("Unsupported")).getErrorCode()); + Assertions.assertEquals("Unknown exception", new QueryInterruptedException(null).getErrorCode()); + Assertions.assertEquals("Unknown exception", new QueryInterruptedException(new ISE("Something bad!")).getErrorCode()); + Assertions.assertEquals( "Unknown exception", new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorCode() ); @@ -53,27 +53,27 @@ public void testErrorCode() @Test public void testErrorMessage() { - Assert.assertEquals( + Assertions.assertEquals( null, new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( null, new QueryInterruptedException(new CancellationException()).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( null, new QueryInterruptedException(new InterruptedException()).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( null, new QueryInterruptedException(null).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( "Something bad!", new QueryInterruptedException(new ISE("Something bad!")).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( "Something bad!", new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getMessage() ); @@ -82,27 +82,27 @@ public void testErrorMessage() @Test public void testErrorClass() { - Assert.assertEquals( + Assertions.assertEquals( "java.util.concurrent.CancellationException", new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "java.util.concurrent.CancellationException", new QueryInterruptedException(new CancellationException()).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "java.lang.InterruptedException", new QueryInterruptedException(new InterruptedException()).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( null, new QueryInterruptedException(null).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "org.apache.druid.java.util.common.ISE", new QueryInterruptedException(new ISE("Something bad!")).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "org.apache.druid.java.util.common.ISE", new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorClass() ); @@ -111,7 +111,7 @@ public void testErrorClass() @Test public void testHost() { - Assert.assertEquals( + Assertions.assertEquals( "myhost", new QueryInterruptedException(new QueryInterruptedException(new CancellationException(), "myhost")).getHost() ); @@ -120,51 +120,51 @@ public void testHost() @Test public void testSerde() { - Assert.assertEquals( + Assertions.assertEquals( "Query cancelled", roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getErrorCode() ); - Assert.assertEquals( + Assertions.assertEquals( "java.util.concurrent.CancellationException", roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( null, roundTrip(new QueryInterruptedException(new QueryInterruptedException(new CancellationException()))).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( "java.util.concurrent.CancellationException", roundTrip(new QueryInterruptedException(new CancellationException())).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "java.lang.InterruptedException", roundTrip(new QueryInterruptedException(new InterruptedException())).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( null, roundTrip(new QueryInterruptedException(null)).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "org.apache.druid.java.util.common.ISE", roundTrip(new QueryInterruptedException(new ISE("Something bad!"))).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "org.apache.druid.java.util.common.ISE", roundTrip(new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!")))).getErrorClass() ); - Assert.assertEquals( + Assertions.assertEquals( "Something bad!", roundTrip(new QueryInterruptedException(new ISE("Something bad!"))).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( "Something bad!", roundTrip(new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!")))).getMessage() ); - Assert.assertEquals( + Assertions.assertEquals( "Unknown exception", roundTrip(new QueryInterruptedException(new ISE("Something bad!"))).getErrorCode() ); - Assert.assertEquals( + Assertions.assertEquals( "Unknown exception", roundTrip(new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!")))).getErrorCode() ); @@ -180,11 +180,11 @@ public void testToStringShouldReturnUsefulInformation() "host" ); String exceptionString = exception.toString(); - Assert.assertTrue(exceptionString.startsWith(QueryInterruptedException.class.getSimpleName())); - Assert.assertTrue(exceptionString.contains("code=" + "error")); - Assert.assertTrue(exceptionString.contains("msg=" + "error messagez")); - Assert.assertTrue(exceptionString.contains("class=" + "error class")); - Assert.assertTrue(exceptionString.contains("host=" + "host")); + Assertions.assertTrue(exceptionString.startsWith(QueryInterruptedException.class.getSimpleName())); + Assertions.assertTrue(exceptionString.contains("code=" + "error")); + Assertions.assertTrue(exceptionString.contains("msg=" + "error messagez")); + Assertions.assertTrue(exceptionString.contains("class=" + "error class")); + Assertions.assertTrue(exceptionString.contains("host=" + "host")); } diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/BackwardCompatibleSerializablePairLongStringSimpleStagedSerdeTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/BackwardCompatibleSerializablePairLongStringSimpleStagedSerdeTest.java index effa47b471f6..1f35b38aa548 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/BackwardCompatibleSerializablePairLongStringSimpleStagedSerdeTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/BackwardCompatibleSerializablePairLongStringSimpleStagedSerdeTest.java @@ -24,8 +24,8 @@ import org.apache.druid.segment.serde.cell.RandomStringUtils; import org.apache.druid.segment.serde.cell.StagedSerde; import org.apache.druid.segment.serde.cell.StorableBuffer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.Nullable; import java.nio.ByteBuffer; @@ -58,17 +58,17 @@ public void testNullString() { SerializablePairLongString value = new SerializablePairLongString(Long.MAX_VALUE, null); // Write using the older serde, read using the newer serde - Assert.assertEquals( + Assertions.assertEquals( new SerializablePairLongString(Long.MAX_VALUE, null), readUsingSerde(writeUsingSerde(value, OLDER_SERDE), SERDE) ); // Write using the newer serde, read using the older serde - Assert.assertEquals( + Assertions.assertEquals( new SerializablePairLongString(Long.MAX_VALUE, null), readUsingSerde(writeUsingSerde(value, SERDE), OLDER_SERDE) ); // Compare the length of the serialized bytes for the value - Assert.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); + Assertions.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); } @Test @@ -76,17 +76,17 @@ public void testEmptyString() { SerializablePairLongString value = new SerializablePairLongString(Long.MAX_VALUE, ""); // Write using the older serde, read using the newer serde - Assert.assertEquals( + Assertions.assertEquals( new SerializablePairLongString(Long.MAX_VALUE, null), readUsingSerde(writeUsingSerde(value, OLDER_SERDE), SERDE) ); // Write using the newer serde, read using the older serde - Assert.assertEquals( + Assertions.assertEquals( new SerializablePairLongString(Long.MAX_VALUE, null), readUsingSerde(writeUsingSerde(value, SERDE), OLDER_SERDE) ); // Compare the length of the serialized bytes for the value - Assert.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); + Assertions.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); } @@ -99,17 +99,17 @@ public void testLargeString() private void testValue(@Nullable SerializablePairLongString value) { // Write using the older serde, read using the newer serde - Assert.assertEquals( + Assertions.assertEquals( value, readUsingSerde(writeUsingSerde(value, OLDER_SERDE), SERDE) ); // Write using the newer serde, read using the older serde - Assert.assertEquals( + Assertions.assertEquals( value, readUsingSerde(writeUsingSerde(value, SERDE), OLDER_SERDE) ); // Compare the length of the serialized bytes for the value - Assert.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); + Assertions.assertEquals(writeUsingSerde(value, OLDER_SERDE).length, writeUsingSerde(value, SERDE).length); } private static byte[] writeUsingSerde( diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/DoubleAnyAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/DoubleAnyAggregationTest.java index 103d5c1d4b97..5534c1bb0d5c 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/DoubleAnyAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/DoubleAnyAggregationTest.java @@ -28,9 +28,9 @@ import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.testing.InitializedNullHandlingTest; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.Comparator; @@ -46,7 +46,7 @@ public class DoubleAnyAggregationTest extends InitializedNullHandlingTest private double[] doubles = {1.1897d, 0.001d, 86.23d, 166.228d}; private Double[] objects = {2.1897d, 1.001d, 87.23d, 167.228d}; - @Before + @BeforeEach public void setup() { doubleAnyAggFactory = new DoubleAnyAggregatorFactory("billy", "nilly"); @@ -71,9 +71,9 @@ public void testDoubleAnyAggregator() Double result = (Double) agg.get(); - Assert.assertEquals((Double) doubles[0], result); - Assert.assertEquals((long) doubles[0], agg.getLong()); - Assert.assertEquals(doubles[0], agg.getDouble(), 0.0001); + Assertions.assertEquals((Double) doubles[0], result); + Assertions.assertEquals((long) doubles[0], agg.getLong()); + Assertions.assertEquals(doubles[0], agg.getDouble(), 0.0001); } @Test @@ -92,9 +92,9 @@ public void testDoubleAnyBufferAggregator() Double result = (Double) agg.get(buffer, 0); - Assert.assertEquals(doubles[0], result, 0.0001); - Assert.assertEquals((long) doubles[0], agg.getLong(buffer, 0)); - Assert.assertEquals(doubles[0], agg.getDouble(buffer, 0), 0.0001); + Assertions.assertEquals(doubles[0], result, 0.0001); + Assertions.assertEquals((long) doubles[0], agg.getLong(buffer, 0)); + Assertions.assertEquals(doubles[0], agg.getDouble(buffer, 0), 0.0001); } @Test @@ -102,7 +102,7 @@ public void testCombine() { Double d1 = 3.0; Double d2 = 4.0; - Assert.assertEquals(d1, doubleAnyAggFactory.combine(d1, d2)); + Assertions.assertEquals(d1, doubleAnyAggFactory.combine(d1, d2)); } @Test @@ -111,10 +111,10 @@ public void testComparatorWithNulls() Double d1 = 3.0; Double d2 = null; Comparator comparator = doubleAnyAggFactory.getComparator(); - Assert.assertEquals(1, comparator.compare(d1, d2)); - Assert.assertEquals(0, comparator.compare(d1, d1)); - Assert.assertEquals(0, comparator.compare(d2, d2)); - Assert.assertEquals(-1, comparator.compare(d2, d1)); + Assertions.assertEquals(1, comparator.compare(d1, d2)); + Assertions.assertEquals(0, comparator.compare(d1, d1)); + Assertions.assertEquals(0, comparator.compare(d2, d2)); + Assertions.assertEquals(-1, comparator.compare(d2, d1)); } @Test @@ -123,9 +123,9 @@ public void testComparatorWithTypeMismatch() Long n1 = 3L; Double n2 = 4.0; Comparator comparator = doubleAnyAggFactory.getComparator(); - Assert.assertEquals(0, comparator.compare(n1, n1)); - Assert.assertEquals(-1, comparator.compare(n1, n2)); - Assert.assertEquals(1, comparator.compare(n2, n1)); + Assertions.assertEquals(0, comparator.compare(n1, n1)); + Assertions.assertEquals(-1, comparator.compare(n1, n2)); + Assertions.assertEquals(1, comparator.compare(n2, n1)); } @Test @@ -140,9 +140,9 @@ public void testDoubleAnyCombiningAggregator() Double result = (Double) agg.get(); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong()); - Assert.assertEquals(objects[0], agg.getDouble(), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong()); + Assertions.assertEquals(objects[0], agg.getDouble(), 0.0001); } @Test @@ -161,9 +161,9 @@ public void testDoubleAnyCombiningBufferAggregator() Double result = (Double) agg.get(buffer, 0); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); - Assert.assertEquals(objects[0], agg.getDouble(buffer, 0), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); + Assertions.assertEquals(objects[0], agg.getDouble(buffer, 0), 0.0001); } @Test @@ -171,7 +171,7 @@ public void testSerde() throws Exception { DefaultObjectMapper mapper = new DefaultObjectMapper(); String doubleSpecJson = "{\"type\":\"doubleAny\",\"name\":\"billy\",\"fieldName\":\"nilly\"}"; - Assert.assertEquals(doubleAnyAggFactory, mapper.readValue(doubleSpecJson, AggregatorFactory.class)); + Assertions.assertEquals(doubleAnyAggFactory, mapper.readValue(doubleSpecJson, AggregatorFactory.class)); } private void aggregate( diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/FloatAnyAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/FloatAnyAggregationTest.java index f31e8bbec56c..5286dd208068 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/FloatAnyAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/FloatAnyAggregationTest.java @@ -28,9 +28,9 @@ import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.testing.InitializedNullHandlingTest; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.Comparator; @@ -46,7 +46,7 @@ public class FloatAnyAggregationTest extends InitializedNullHandlingTest private float[] floats = {1.1897f, 0.001f, 86.23f, 166.228f}; private Float[] objects = {2.1897f, 1.001f, 87.23f, 167.228f}; - @Before + @BeforeEach public void setup() { floatAnyAggFactory = new FloatAnyAggregatorFactory("billy", "nilly"); @@ -71,9 +71,9 @@ public void testFloatAnyAggregator() Float result = (Float) agg.get(); - Assert.assertEquals((Float) floats[0], result); - Assert.assertEquals((long) floats[0], agg.getLong()); - Assert.assertEquals(floats[0], agg.getFloat(), 0.0001); + Assertions.assertEquals((Float) floats[0], result); + Assertions.assertEquals((long) floats[0], agg.getLong()); + Assertions.assertEquals(floats[0], agg.getFloat(), 0.0001); } @Test @@ -92,9 +92,9 @@ public void testFloatAnyBufferAggregator() Float result = (Float) agg.get(buffer, 0); - Assert.assertEquals(floats[0], result, 0.0001); - Assert.assertEquals((long) floats[0], agg.getLong(buffer, 0)); - Assert.assertEquals(floats[0], agg.getFloat(buffer, 0), 0.0001); + Assertions.assertEquals(floats[0], result, 0.0001); + Assertions.assertEquals((long) floats[0], agg.getLong(buffer, 0)); + Assertions.assertEquals(floats[0], agg.getFloat(buffer, 0), 0.0001); } @Test @@ -102,7 +102,7 @@ public void testCombine() { Float f1 = 3.0f; Float f2 = 4.0f; - Assert.assertEquals(f1, floatAnyAggFactory.combine(f1, f2)); + Assertions.assertEquals(f1, floatAnyAggFactory.combine(f1, f2)); } @Test @@ -111,10 +111,10 @@ public void testComparatorWithNulls() Float f1 = 3.0f; Float f2 = null; Comparator comparator = floatAnyAggFactory.getComparator(); - Assert.assertEquals(1, comparator.compare(f1, f2)); - Assert.assertEquals(0, comparator.compare(f1, f1)); - Assert.assertEquals(0, comparator.compare(f2, f2)); - Assert.assertEquals(-1, comparator.compare(f2, f1)); + Assertions.assertEquals(1, comparator.compare(f1, f2)); + Assertions.assertEquals(0, comparator.compare(f1, f1)); + Assertions.assertEquals(0, comparator.compare(f2, f2)); + Assertions.assertEquals(-1, comparator.compare(f2, f1)); } @Test @@ -123,9 +123,9 @@ public void testComparatorWithTypeMismatch() Long n1 = 3L; Float n2 = 4.0f; Comparator comparator = floatAnyAggFactory.getComparator(); - Assert.assertEquals(0, comparator.compare(n1, n1)); - Assert.assertEquals(-1, comparator.compare(n1, n2)); - Assert.assertEquals(1, comparator.compare(n2, n1)); + Assertions.assertEquals(0, comparator.compare(n1, n1)); + Assertions.assertEquals(-1, comparator.compare(n1, n2)); + Assertions.assertEquals(1, comparator.compare(n2, n1)); } @Test @@ -140,9 +140,9 @@ public void testFloatAnyCombiningAggregator() Float result = (Float) agg.get(); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong()); - Assert.assertEquals(objects[0], agg.getFloat(), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong()); + Assertions.assertEquals(objects[0], agg.getFloat(), 0.0001); } @Test @@ -161,9 +161,9 @@ public void testFloatAnyCombiningBufferAggregator() Float result = (Float) agg.get(buffer, 0); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); - Assert.assertEquals(objects[0], agg.getFloat(buffer, 0), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); + Assertions.assertEquals(objects[0], agg.getFloat(buffer, 0), 0.0001); } @Test @@ -171,7 +171,7 @@ public void testSerde() throws Exception { DefaultObjectMapper mapper = new DefaultObjectMapper(); String floatSpecJson = "{\"type\":\"floatAny\",\"name\":\"billy\",\"fieldName\":\"nilly\"}"; - Assert.assertEquals(floatAnyAggFactory, mapper.readValue(floatSpecJson, AggregatorFactory.class)); + Assertions.assertEquals(floatAnyAggFactory, mapper.readValue(floatSpecJson, AggregatorFactory.class)); } private void aggregate( diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/LongAnyAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/LongAnyAggregationTest.java index 9525cdfb3f35..2d5cbff5f983 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/LongAnyAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/LongAnyAggregationTest.java @@ -28,9 +28,9 @@ import org.apache.druid.segment.ColumnSelectorFactory; import org.apache.druid.testing.InitializedNullHandlingTest; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.Comparator; @@ -47,7 +47,7 @@ public class LongAnyAggregationTest extends InitializedNullHandlingTest private long[] longs = {185, -216, -128751132, Long.MIN_VALUE}; private Long[] objects = {1123126751L, 1784247991L, 1854329816L, 1000000000L}; - @Before + @BeforeEach public void setup() { longAnyAggFactory = new LongAnyAggregatorFactory("billy", "nilly"); @@ -72,9 +72,9 @@ public void testLongAnyAggregator() Long result = (Long) agg.get(); - Assert.assertEquals((Long) longs[0], result); - Assert.assertEquals((long) longs[0], agg.getLong()); - Assert.assertEquals(longs[0], agg.getLong(), 0.0001); + Assertions.assertEquals((Long) longs[0], result); + Assertions.assertEquals((long) longs[0], agg.getLong()); + Assertions.assertEquals(longs[0], agg.getLong(), 0.0001); } @Test @@ -93,9 +93,9 @@ public void testLongAnyBufferAggregator() Long result = (Long) agg.get(buffer, 0); - Assert.assertEquals(longs[0], result, 0.0001); - Assert.assertEquals((long) longs[0], agg.getLong(buffer, 0)); - Assert.assertEquals(longs[0], agg.getLong(buffer, 0), 0.0001); + Assertions.assertEquals(longs[0], result, 0.0001); + Assertions.assertEquals((long) longs[0], agg.getLong(buffer, 0)); + Assertions.assertEquals(longs[0], agg.getLong(buffer, 0), 0.0001); } @Test @@ -103,7 +103,7 @@ public void testCombine() { Long l1 = 3L; Long l2 = 4L; - Assert.assertEquals(l1, longAnyAggFactory.combine(l1, l2)); + Assertions.assertEquals(l1, longAnyAggFactory.combine(l1, l2)); } @Test @@ -112,10 +112,10 @@ public void testComparatorWithNulls() Long l1 = 3L; Long l2 = null; Comparator comparator = longAnyAggFactory.getComparator(); - Assert.assertEquals(1, comparator.compare(l1, l2)); - Assert.assertEquals(0, comparator.compare(l1, l1)); - Assert.assertEquals(0, comparator.compare(l2, l2)); - Assert.assertEquals(-1, comparator.compare(l2, l1)); + Assertions.assertEquals(1, comparator.compare(l1, l2)); + Assertions.assertEquals(0, comparator.compare(l1, l1)); + Assertions.assertEquals(0, comparator.compare(l2, l2)); + Assertions.assertEquals(-1, comparator.compare(l2, l1)); } @Test @@ -124,9 +124,9 @@ public void testComparatorWithTypeMismatch() Integer n1 = 3; Long n2 = 4L; Comparator comparator = longAnyAggFactory.getComparator(); - Assert.assertEquals(0, comparator.compare(n1, n1)); - Assert.assertEquals(-1, comparator.compare(n1, n2)); - Assert.assertEquals(1, comparator.compare(n2, n1)); + Assertions.assertEquals(0, comparator.compare(n1, n1)); + Assertions.assertEquals(-1, comparator.compare(n1, n2)); + Assertions.assertEquals(1, comparator.compare(n2, n1)); } @Test @@ -141,9 +141,9 @@ public void testLongAnyCombiningAggregator() Long result = (Long) agg.get(); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong()); - Assert.assertEquals(objects[0], agg.getLong(), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong()); + Assertions.assertEquals(objects[0], agg.getLong(), 0.0001); } @Test @@ -162,9 +162,9 @@ public void testLongAnyCombiningBufferAggregator() Long result = (Long) agg.get(buffer, 0); - Assert.assertEquals(objects[0], result, 0.0001); - Assert.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); - Assert.assertEquals(objects[0], agg.getLong(buffer, 0), 0.0001); + Assertions.assertEquals(objects[0], result, 0.0001); + Assertions.assertEquals(objects[0].longValue(), agg.getLong(buffer, 0)); + Assertions.assertEquals(objects[0], agg.getLong(buffer, 0), 0.0001); } @Test @@ -172,7 +172,7 @@ public void testSerde() throws Exception { DefaultObjectMapper mapper = new DefaultObjectMapper(); String longSpecJson = "{\"type\":\"longAny\",\"name\":\"billy\",\"fieldName\":\"nilly\"}"; - Assert.assertEquals(longAnyAggFactory, mapper.readValue(longSpecJson, AggregatorFactory.class)); + Assertions.assertEquals(longAnyAggFactory, mapper.readValue(longSpecJson, AggregatorFactory.class)); } private void aggregate( diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/NumericAnyVectorAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/NumericAnyVectorAggregatorTest.java index e9c60d35a51c..9c740b58d11c 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/NumericAnyVectorAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/NumericAnyVectorAggregatorTest.java @@ -22,20 +22,23 @@ import org.apache.druid.segment.column.TypeStrategies; import org.apache.druid.segment.vector.VectorValueSelector; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import java.nio.ByteBuffer; import java.util.concurrent.ThreadLocalRandom; import static org.apache.druid.query.aggregation.any.NumericAnyVectorAggregator.BYTE_FLAG_FOUND_MASK; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class NumericAnyVectorAggregatorTest extends InitializedNullHandlingTest { private static final int NULL_POSITION = 10; @@ -50,7 +53,7 @@ public class NumericAnyVectorAggregatorTest extends InitializedNullHandlingTest private NumericAnyVectorAggregator target; - @Before + @BeforeEach public void setUp() { Mockito.doReturn(NULLS).when(selector).getNullVector(); @@ -93,8 +96,8 @@ Object getNonNullObject(ByteBuffer buf, int position) public void initShouldSetDoubleAfterPositionToZero() { target.init(buf, POSITION); - Assert.assertEquals(0, buf.get(POSITION) & BYTE_FLAG_FOUND_MASK); - Assert.assertEquals( + Assertions.assertEquals(0, buf.get(POSITION) & BYTE_FLAG_FOUND_MASK); + Assertions.assertEquals( TypeStrategies.IS_NULL_BYTE, buf.get(POSITION) ); @@ -104,14 +107,14 @@ public void initShouldSetDoubleAfterPositionToZero() public void aggregateNotFoundAndHasNullsShouldPutNull() { target.aggregate(buf, POSITION, 0, 3); - Assert.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NULL_BYTE, buf.get(POSITION)); + Assertions.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NULL_BYTE, buf.get(POSITION)); } @Test public void aggregateNotFoundAndHasNullsOutsideRangeShouldPutValue() { target.aggregate(buf, POSITION, 0, 1); - Assert.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(POSITION)); + Assertions.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(POSITION)); } @Test @@ -119,7 +122,7 @@ public void aggregateNotFoundAndNoNullsShouldPutValue() { Mockito.doReturn(null).when(selector).getNullVector(); target.aggregate(buf, POSITION, 0, 3); - Assert.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(POSITION)); + Assertions.assertEquals(BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(POSITION)); } @Test @@ -127,7 +130,7 @@ public void aggregateNotFoundNoNullsAndValuesOutsideRangeShouldNotPutValue() { Mockito.doReturn(null).when(selector).getNullVector(); target.aggregate(buf, POSITION, NULLS.length, NULLS.length + 1); - Assert.assertNotEquals(BYTE_FLAG_FOUND_MASK, (buf.get(POSITION) & BYTE_FLAG_FOUND_MASK)); + Assertions.assertNotEquals(BYTE_FLAG_FOUND_MASK, (buf.get(POSITION) & BYTE_FLAG_FOUND_MASK)); } @Test @@ -140,11 +143,11 @@ public void aggregateBatchNoRowsShouldAggregateAllRows() target.aggregate(buf, 3, positions, null, positionOffset); for (int i = 0; i < positions.length; i++) { int position = positions[i] + positionOffset; - Assert.assertEquals( + Assertions.assertEquals( BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(position) & (byte) (BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE) ); - Assert.assertEquals(i, buf.getLong(position + 1)); + Assertions.assertEquals(i, buf.getLong(position + 1)); } } @@ -159,11 +162,11 @@ public void aggregateBatchWithRowsShouldAggregateAllRows() target.aggregate(buf, 3, positions, rows, positionOffset); for (int i = 0; i < positions.length; i++) { int position = positions[i] + positionOffset; - Assert.assertEquals( + Assertions.assertEquals( BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE, buf.get(position) & (byte) (BYTE_FLAG_FOUND_MASK | TypeStrategies.IS_NOT_NULL_BYTE) ); - Assert.assertEquals(rows[i], buf.getLong(position + 1)); + Assertions.assertEquals(rows[i], buf.getLong(position + 1)); } } @@ -173,28 +176,28 @@ public void aggregateFoundShouldDoNothing() long previous = buf.getLong(POSITION + 1); buf.put(POSITION, BYTE_FLAG_FOUND_MASK); target.aggregate(buf, POSITION, 0, 3); - Assert.assertEquals(previous, buf.getLong(POSITION + 1)); + Assertions.assertEquals(previous, buf.getLong(POSITION + 1)); } @Test public void getNullShouldReturnNull() { - Assert.assertNull(target.get(buf, NULL_POSITION)); + Assertions.assertNull(target.get(buf, NULL_POSITION)); } @Test public void getNotNullShouldReturnValue() { - Assert.assertEquals(FOUND_OBJECT, target.get(buf, POSITION)); + Assertions.assertEquals(FOUND_OBJECT, target.get(buf, POSITION)); } @Test public void isValueNull() { buf.put(POSITION, (byte) 4); - Assert.assertFalse(target.isValueNull(buf, POSITION)); + Assertions.assertFalse(target.isValueNull(buf, POSITION)); buf.put(POSITION, (byte) 3); - Assert.assertTrue(target.isValueNull(buf, POSITION)); + Assertions.assertTrue(target.isValueNull(buf, POSITION)); } private void clearBufferForPositions(int offset, int... positions) diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregationTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregationTest.java index b728049d6259..3681da091345 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregationTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregationTest.java @@ -27,9 +27,9 @@ import org.apache.druid.segment.column.ColumnCapabilitiesImpl; import org.apache.druid.segment.column.ColumnType; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; @@ -46,7 +46,7 @@ public class StringAnyAggregationTest private String[] stringsWithNullFirst = {null, "1111", "2222", "3333", null, "4444"}; - @Before + @BeforeEach public void setup() { stringAnyAggFactory = new StringAnyAggregatorFactory("billy", "nilly", MAX_STRING_SIZE, true); @@ -74,7 +74,7 @@ public void testStringAnyAggregator() String result = (String) agg.get(); - Assert.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); } @Test @@ -95,7 +95,7 @@ public void testStringAnyAggregatorWithNullFirst() aggregate(agg); String result = (String) agg.get(); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -114,7 +114,7 @@ public void testStringAnyBufferAggregator() String result = (String) agg.get(buffer, 0); - Assert.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); } @Test @@ -139,7 +139,7 @@ public void testStringAnyBufferAggregatorWithNullFirst() aggregate(agg, buffer, 0); String result = (String) agg.get(buffer, 0); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -147,7 +147,7 @@ public void testCombine() { String s1 = "aaaaaa"; String s2 = "aaaaaa"; - Assert.assertEquals(s1, stringAnyAggFactory.combine(s1, s2)); + Assertions.assertEquals(s1, stringAnyAggFactory.combine(s1, s2)); } @Test @@ -162,8 +162,8 @@ public void testStringAnyCombiningAggregator() String result = (String) agg.get(); - Assert.assertEquals(strings[0], result); - Assert.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); } @Test @@ -182,8 +182,8 @@ public void testStringAnyCombiningBufferAggregator() String result = (String) agg.get(buffer, 0); - Assert.assertEquals(strings[0], result); - Assert.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); + Assertions.assertEquals(strings[0], result); } private void aggregate( diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregatorFactoryTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregatorFactoryTest.java index daac6605998b..4a535d96561b 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregatorFactoryTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregatorFactoryTest.java @@ -32,9 +32,9 @@ import org.apache.druid.segment.vector.TestVectorColumnSelectorFactory; import org.apache.druid.segment.virtual.FallbackVirtualColumnTest; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -48,7 +48,7 @@ public class StringAnyAggregatorFactoryTest extends InitializedNullHandlingTest private TestVectorColumnSelectorFactory vectorSelectorFactory; private StringAnyAggregatorFactory target; - @Before + @BeforeEach public void setUp() { target = new StringAnyAggregatorFactory(NAME, FIELD_NAME, MAX_STRING_BYTES, true); @@ -64,19 +64,19 @@ public void setUp() @Test public void canVectorizeWithoutCapabilitiesShouldReturnTrue() { - Assert.assertTrue(target.canVectorize(new TestColumnSelectorFactory(null))); + Assertions.assertTrue(target.canVectorize(new TestColumnSelectorFactory(null))); } @Test public void canVectorizeWithDictionaryEncodedMvStringShouldReturnTrue() { - Assert.assertTrue(target.canVectorize(new TestColumnSelectorFactory(capabilitiesMvString))); + Assertions.assertTrue(target.canVectorize(new TestColumnSelectorFactory(capabilitiesMvString))); } @Test public void canVectorizeWithNonDictionaryEncodedStringShouldReturnFalse() { - Assert.assertFalse( + Assertions.assertFalse( target.canVectorize( new TestColumnSelectorFactory( ColumnCapabilitiesImpl.createDefault().setType(ColumnType.STRING) @@ -89,39 +89,39 @@ public void canVectorizeWithNonDictionaryEncodedStringShouldReturnFalse() public void factorizeVectorWithoutCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector() { StringAnyVectorAggregator aggregator = target.factorizeVector(vectorSelectorFactory); - Assert.assertNotNull(aggregator); + Assertions.assertNotNull(aggregator); } @Test public void factorizeVectorWithUnknownCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector() { StringAnyVectorAggregator aggregator = target.factorizeVector(vectorSelectorFactory); - Assert.assertNotNull(aggregator); + Assertions.assertNotNull(aggregator); } @Test public void factorizeVectorWithMultipleValuesCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector() { StringAnyVectorAggregator aggregator = target.factorizeVector(vectorSelectorFactory); - Assert.assertNotNull(aggregator); + Assertions.assertNotNull(aggregator); } @Test public void factorizeVectorWithoutMultipleValuesCapabilitiesShouldReturnAggregatorWithSingleDimensionSelector() { StringAnyVectorAggregator aggregator = target.factorizeVector(vectorSelectorFactory); - Assert.assertNotNull(aggregator); + Assertions.assertNotNull(aggregator); } @Test public void testFactorize() { Aggregator res = target.factorize(new TestColumnSelectorFactory(capabilitiesMvString)); - Assert.assertTrue(res instanceof StringAnyAggregator); + Assertions.assertInstanceOf(StringAnyAggregator.class, res); res.aggregate(); - Assert.assertEquals(null, res.get()); + Assertions.assertEquals(null, res.get()); StringAnyVectorAggregator vectorAggregator = target.factorizeVector(vectorSelectorFactory); - Assert.assertTrue(vectorAggregator.isAggregateMultipleValues()); + Assertions.assertTrue(vectorAggregator.isAggregateMultipleValues()); } @Test @@ -129,10 +129,10 @@ public void testSvdStringAnyAggregator() { TestColumnSelectorFactory columnSelectorFactory = new TestColumnSelectorFactory(capabilitiesMvString); Aggregator res = target.factorize(columnSelectorFactory); - Assert.assertTrue(res instanceof StringAnyAggregator); + Assertions.assertInstanceOf(StringAnyAggregator.class, res); columnSelectorFactory.moveSelectorCursorToNext(); res.aggregate(); - Assert.assertEquals("CCCC", res.get()); + Assertions.assertEquals("CCCC", res.get()); } @Test @@ -140,11 +140,11 @@ public void testMvdStringAnyAggregator() { TestColumnSelectorFactory columnSelectorFactory = new TestColumnSelectorFactory(capabilitiesMvString); Aggregator res = target.factorize(columnSelectorFactory); - Assert.assertTrue(res instanceof StringAnyAggregator); + Assertions.assertInstanceOf(StringAnyAggregator.class, res); columnSelectorFactory.moveSelectorCursorToNext(); columnSelectorFactory.moveSelectorCursorToNext(); res.aggregate(); - Assert.assertEquals("[AAAA, AAA", res.get()); + Assertions.assertEquals("[AAAA, AAA", res.get()); } @Test @@ -153,12 +153,12 @@ public void testMvdStringAnyAggregatorWithAggregateMultipleToFalse() StringAnyAggregatorFactory target = new StringAnyAggregatorFactory(NAME, FIELD_NAME, MAX_STRING_BYTES, false); TestColumnSelectorFactory columnSelectorFactory = new TestColumnSelectorFactory(capabilitiesMvString); Aggregator res = target.factorize(columnSelectorFactory); - Assert.assertTrue(res instanceof StringAnyAggregator); + Assertions.assertInstanceOf(StringAnyAggregator.class, res); columnSelectorFactory.moveSelectorCursorToNext(); columnSelectorFactory.moveSelectorCursorToNext(); res.aggregate(); // picks up first value in mvd list - Assert.assertEquals("AAAA", res.get()); + Assertions.assertEquals("AAAA", res.get()); } static class TestColumnSelectorFactory implements ColumnSelectorFactory diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyVectorAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyVectorAggregatorTest.java index b6555f6d2af4..ac092257c6a3 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyVectorAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyVectorAggregatorTest.java @@ -24,13 +24,15 @@ import org.apache.druid.segment.vector.MultiValueDimensionVectorSelector; import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -40,7 +42,8 @@ import static org.apache.druid.query.aggregation.any.StringAnyVectorAggregator.NOT_FOUND_FLAG_VALUE; import static org.mockito.ArgumentMatchers.anyInt; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class StringAnyVectorAggregatorTest extends InitializedNullHandlingTest { private static final int MAX_STRING_BYTES = 32; @@ -65,7 +68,7 @@ public class StringAnyVectorAggregatorTest extends InitializedNullHandlingTest private StringAnyVectorAggregator multiValueTarget; private StringAnyVectorAggregator customMultiValueTarget; - @Before + @BeforeEach public void setUp() { Mockito.doReturn(MULTI_VALUE_ROWS).when(multiValueSelector).getRowVector(); @@ -83,65 +86,71 @@ public void setUp() customMultiValueTarget = new StringAnyVectorAggregator(null, multiValueSelector, MAX_STRING_BYTES, false); } - @Test(expected = IllegalStateException.class) + @Test public void initWithBothSingleAndMultiValueSelectorShouldThrowException() { - new StringAnyVectorAggregator(singleValueSelector, multiValueSelector, MAX_STRING_BYTES, true); + Assertions.assertThrows( + IllegalStateException.class, + () -> new StringAnyVectorAggregator(singleValueSelector, multiValueSelector, MAX_STRING_BYTES, true) + ); } - @Test(expected = IllegalStateException.class) + @Test public void initWithNeitherSingleNorMultiValueSelectorShouldThrowException() { - new StringAnyVectorAggregator(null, null, MAX_STRING_BYTES, true); + Assertions.assertThrows( + IllegalStateException.class, + () -> new StringAnyVectorAggregator(null, null, MAX_STRING_BYTES, true) + ); } @Test public void initSingleValueTargetShouldMarkPositionAsNotFound() { singleValueTarget.init(buf, POSITION + 1); - Assert.assertEquals(NOT_FOUND_FLAG_VALUE, buf.getInt(POSITION + 1)); + Assertions.assertEquals(NOT_FOUND_FLAG_VALUE, buf.getInt(POSITION + 1)); } @Test public void initMultiValueTargetShouldMarkPositionAsNotFound() { multiValueTarget.init(buf, POSITION + 1); - Assert.assertEquals(NOT_FOUND_FLAG_VALUE, buf.getInt(POSITION + 1)); + Assertions.assertEquals(NOT_FOUND_FLAG_VALUE, buf.getInt(POSITION + 1)); } @Test public void aggregatePositionNotFoundShouldPutFirstValue() { singleValueTarget.aggregate(buf, POSITION, 0, 2); - Assert.assertEquals(DICTIONARY[1], singleValueTarget.get(buf, POSITION)); + Assertions.assertEquals(DICTIONARY[1], singleValueTarget.get(buf, POSITION)); } @Test public void aggregateEmptyShouldPutNull() { singleValueTarget.aggregate(buf, POSITION, 2, 3); - Assert.assertNull(singleValueTarget.get(buf, POSITION)); + Assertions.assertNull(singleValueTarget.get(buf, POSITION)); } @Test public void aggregateMultiValuePositionNotFoundShouldPutFirstValue() { multiValueTarget.aggregate(buf, POSITION, 0, 2); - Assert.assertEquals("[One, Zero]", multiValueTarget.get(buf, POSITION)); + Assertions.assertEquals("[One, Zero]", multiValueTarget.get(buf, POSITION)); } @Test public void aggregateMultiValueEmptyShouldPutNull() { multiValueTarget.aggregate(buf, POSITION, 2, 3); - Assert.assertNull(multiValueTarget.get(buf, POSITION)); + Assertions.assertNull(multiValueTarget.get(buf, POSITION)); } @Test public void aggregateValueLongerThanLimitShouldPutTruncatedValue() { singleValueTarget.aggregate(buf, POSITION, 3, 4); - Assert.assertEquals(DICTIONARY[2].substring(0, 32), singleValueTarget.get(buf, POSITION)); + Assertions.assertEquals(DICTIONARY[2].substring(0, 32), singleValueTarget.get(buf, POSITION)); } @Test @@ -153,7 +162,7 @@ public void aggregateBatchNoRowsShouldAggregateAllRows() singleValueTarget.aggregate(buf, 3, positions, null, positionOffset); for (int i = 0; i < positions.length; i++) { int position = positions[i] + positionOffset; - Assert.assertEquals(singleValueSelector.lookupName(SINGLE_VALUE_ROWS[i]), singleValueTarget.get(buf, position)); + Assertions.assertEquals(singleValueSelector.lookupName(SINGLE_VALUE_ROWS[i]), singleValueTarget.get(buf, position)); } } @@ -170,13 +179,13 @@ public void aggregateBatchWithRowsShouldAggregateAllRows() int row = rows[i]; IndexedInts rowIndex = MULTI_VALUE_ROWS[row]; if (rowIndex.size() == 0) { - Assert.assertNull(multiValueTarget.get(buf, position)); + Assertions.assertNull(multiValueTarget.get(buf, position)); } else if (rowIndex.size() == 1) { - Assert.assertEquals(multiValueSelector.lookupName(rowIndex.get(0)), multiValueTarget.get(buf, position)); + Assertions.assertEquals(multiValueSelector.lookupName(rowIndex.get(0)), multiValueTarget.get(buf, position)); } else { List res = new ArrayList<>(); rowIndex.forEach(index -> res.add(multiValueSelector.lookupName(index))); - Assert.assertEquals(res.toString(), multiValueTarget.get(buf, position)); + Assertions.assertEquals(res.toString(), multiValueTarget.get(buf, position)); } } } @@ -194,9 +203,9 @@ public void aggregateBatchWithRowsShouldAggregateAllRowsWithAggregateMVDFalse() int row = rows[i]; IndexedInts rowIndex = MULTI_VALUE_ROWS[row]; if (rowIndex.size() == 0) { - Assert.assertNull(customMultiValueTarget.get(buf, position)); + Assertions.assertNull(customMultiValueTarget.get(buf, position)); } else { - Assert.assertEquals(multiValueSelector.lookupName(rowIndex.get(0)), customMultiValueTarget.get(buf, position)); + Assertions.assertEquals(multiValueSelector.lookupName(rowIndex.get(0)), customMultiValueTarget.get(buf, position)); } } } diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregatorTest.java index 71e582c078a2..581707b4be00 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/first/StringFirstBufferAggregatorTest.java @@ -23,8 +23,8 @@ import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; @@ -76,8 +76,8 @@ public void testBufferAggregate() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", strings[0], sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(timestamps[0]), sp.lhs); + Assertions.assertEquals(strings[0], sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(timestamps[0]), sp.lhs, "last string timestamp is the biggest"); } @Test @@ -113,8 +113,8 @@ public void testBufferAggregateWithFoldCheck() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", strings[0], sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(timestamps[0]), sp.lhs); + Assertions.assertEquals(strings[0], sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(timestamps[0]), sp.lhs, "last string timestamp is the biggest"); } @Test @@ -151,8 +151,8 @@ public void testNullBufferAggregate() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", strings[1], sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(timestamps[1]), sp.lhs); + Assertions.assertEquals(strings[1], sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(timestamps[1]), sp.lhs, "last string timestamp is the biggest"); } @@ -189,7 +189,7 @@ public void testNoStringValue() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals(1526724000L, (long) sp.lhs); - Assert.assertEquals(null, sp.rhs); + Assertions.assertEquals(1526724000L, (long) sp.lhs); + Assertions.assertEquals(null, sp.rhs); } } diff --git a/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/last/StringLastBufferAggregatorTest.java b/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/last/StringLastBufferAggregatorTest.java index 9e8c9117a32a..3f1e66f802a5 100644 --- a/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/last/StringLastBufferAggregatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/aggregation/firstlast/last/StringLastBufferAggregatorTest.java @@ -23,8 +23,8 @@ import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.TestLongColumnSelector; import org.apache.druid.query.aggregation.TestObjectColumnSelector; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; @@ -77,8 +77,8 @@ public void testBufferAggregate() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", "DDDD", sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(1526725900L), sp.lhs); + Assertions.assertEquals("DDDD", sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(1526725900L), sp.lhs, "last string timestamp is the biggest"); } @@ -115,8 +115,8 @@ public void testBufferAggregateWithFoldCheck() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", "DDDD", sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(1526725900L), sp.lhs); + Assertions.assertEquals("DDDD", sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(1526725900L), sp.lhs, "last string timestamp is the biggest"); } @Test @@ -153,8 +153,8 @@ public void testNullBufferAggregate() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals("expected last string value", strings[2], sp.rhs); - Assert.assertEquals("last string timestamp is the biggest", Long.valueOf(timestamps[2]), sp.lhs); + Assertions.assertEquals(strings[2], sp.rhs, "expected last string value"); + Assertions.assertEquals(Long.valueOf(timestamps[2]), sp.lhs, "last string timestamp is the biggest"); } @@ -191,7 +191,7 @@ public void testNonStringValue() SerializablePairLongString sp = ((SerializablePairLongString) agg.get(buf, position)); - Assert.assertEquals(1526724600L, (long) sp.lhs); - Assert.assertEquals("2.0", sp.rhs); + Assertions.assertEquals(1526724600L, (long) sp.lhs); + Assertions.assertEquals("2.0", sp.rhs); } } diff --git a/processing/src/test/java/org/apache/druid/query/explain/ExplainAttributesTest.java b/processing/src/test/java/org/apache/druid/query/explain/ExplainAttributesTest.java index affaf6e3ddfb..2a7a4a82ab6d 100644 --- a/processing/src/test/java/org/apache/druid/query/explain/ExplainAttributesTest.java +++ b/processing/src/test/java/org/apache/druid/query/explain/ExplainAttributesTest.java @@ -23,13 +23,11 @@ import org.apache.druid.error.DruidException; import org.apache.druid.jackson.DefaultObjectMapper; import org.apache.druid.java.util.common.granularity.Granularities; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; -import static org.junit.Assert.assertEquals; - public class ExplainAttributesTest { private static final ObjectMapper MAPPER = new DefaultObjectMapper(); @@ -38,11 +36,11 @@ public class ExplainAttributesTest public void testGetters() { final ExplainAttributes selectAttributes = new ExplainAttributes("SELECT", null, null, null, null); - assertEquals("SELECT", selectAttributes.getStatementType()); - Assert.assertNull(selectAttributes.getTargetDataSource()); - Assert.assertNull(selectAttributes.getPartitionedBy()); - Assert.assertNull(selectAttributes.getClusteredBy()); - Assert.assertNull(selectAttributes.getReplaceTimeChunks()); + Assertions.assertEquals("SELECT", selectAttributes.getStatementType()); + Assertions.assertNull(selectAttributes.getTargetDataSource()); + Assertions.assertNull(selectAttributes.getPartitionedBy()); + Assertions.assertNull(selectAttributes.getClusteredBy()); + Assertions.assertNull(selectAttributes.getReplaceTimeChunks()); } @Test @@ -182,13 +180,13 @@ private void testSerde(final ExplainAttributes explainAttributes, final String e final ExplainAttributes observedAttributes; try { final String observedSerializedAttributes = MAPPER.writeValueAsString(explainAttributes); - assertEquals(expectedSerializedAttributes, observedSerializedAttributes); + Assertions.assertEquals(expectedSerializedAttributes, observedSerializedAttributes); observedAttributes = MAPPER.readValue(observedSerializedAttributes, ExplainAttributes.class); } catch (Exception e) { throw DruidException.defensive(e, "Error serializing/deserializing explain plan[%s].", explainAttributes); } - assertEquals(explainAttributes, observedAttributes); + Assertions.assertEquals(explainAttributes, observedAttributes); } } diff --git a/processing/src/test/java/org/apache/druid/query/expression/ArrayQuantileExprMacroTest.java b/processing/src/test/java/org/apache/druid/query/expression/ArrayQuantileExprMacroTest.java index 50a7a309cf89..c72a5083cd99 100644 --- a/processing/src/test/java/org/apache/druid/query/expression/ArrayQuantileExprMacroTest.java +++ b/processing/src/test/java/org/apache/druid/query/expression/ArrayQuantileExprMacroTest.java @@ -26,8 +26,8 @@ import org.apache.druid.math.expr.ExprEval; import org.apache.druid.math.expr.InputBindings; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class ArrayQuantileExprMacroTest extends InitializedNullHandlingTest { @@ -41,7 +41,7 @@ public void test_apply_longArray() ) ); - Assert.assertEquals( + Assertions.assertEquals( 2.0, result.eval(InputBindings.nilBindings()).asDouble(), 0.0 @@ -58,7 +58,7 @@ public void test_apply_longArrayWithNulls() ) ); - Assert.assertEquals( + Assertions.assertEquals( 2.0, result.eval(InputBindings.nilBindings()).asDouble(), 0.0 @@ -75,7 +75,7 @@ public void test_apply_doubleArray() ) ); - Assert.assertEquals( + Assertions.assertEquals( 2.0, result.eval(InputBindings.nilBindings()).asDouble(), 0.0 @@ -92,7 +92,7 @@ public void test_apply_doubleArrayWithNulls() ) ); - Assert.assertEquals( + Assertions.assertEquals( 2.0, result.eval(InputBindings.nilBindings()).asDouble(), 0.0 @@ -109,7 +109,7 @@ public void test_apply_stringArray() ) ); - Assert.assertTrue(result.eval(InputBindings.nilBindings()).isNumericNull()); + Assertions.assertTrue(result.eval(InputBindings.nilBindings()).isNumericNull()); } @Test @@ -122,7 +122,7 @@ public void test_apply_null() ) ); - Assert.assertTrue(result.eval(InputBindings.nilBindings()).isNumericNull()); + Assertions.assertTrue(result.eval(InputBindings.nilBindings()).isNumericNull()); } @Test @@ -157,21 +157,21 @@ public void test_quantileFromSortedArray() 96.84202159588680 ); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0.0000001); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0.0000001); - Assert.assertEquals(1.748963413, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0.0000001); - Assert.assertEquals(12.45021723, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0.0000001); - Assert.assertEquals(21.67577451, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0.0000001); - Assert.assertEquals(30.44964132, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0.0000001); - Assert.assertEquals(35.44337814, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0.0000001); - Assert.assertEquals(38.4706171, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0.0000001); - Assert.assertEquals(41.73995751, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0.0000001); - Assert.assertEquals(57.25176603, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0.0000001); - Assert.assertEquals(77.96955453, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0.0000001); - Assert.assertEquals(85.52305771, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0.0000001); - Assert.assertEquals(96.84185513, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0.0000001); - Assert.assertEquals(96.8420216, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0.0000001); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0.0000001); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0.0000001); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0.0000001); + Assertions.assertEquals(1.748963413, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0.0000001); + Assertions.assertEquals(12.45021723, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0.0000001); + Assertions.assertEquals(21.67577451, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0.0000001); + Assertions.assertEquals(30.44964132, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0.0000001); + Assertions.assertEquals(35.44337814, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0.0000001); + Assertions.assertEquals(38.4706171, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0.0000001); + Assertions.assertEquals(41.73995751, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0.0000001); + Assertions.assertEquals(57.25176603, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0.0000001); + Assertions.assertEquals(77.96955453, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0.0000001); + Assertions.assertEquals(85.52305771, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0.0000001); + Assertions.assertEquals(96.84185513, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0.0000001); + Assertions.assertEquals(96.8420216, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0.0000001); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0.0000001); } @Test @@ -179,21 +179,21 @@ public void test_quantileFromSortedArray_singleElement() { final DoubleList doubles = DoubleList.of(1.748945667); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0); - Assert.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0); + Assertions.assertEquals(1.748945667, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0); } @Test @@ -201,20 +201,20 @@ public void test_quantileFromSortedArray_noElements() { final DoubleList doubles = DoubleLists.emptyList(); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0); - Assert.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, -0.1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.000001), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.2), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.3), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.4), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.5), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.6), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.7), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.8), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.9), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 0.999999), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1), 0); + Assertions.assertEquals(Double.NaN, ArrayQuantileExprMacro.quantileFromSortedArray(doubles, 1.1), 0); } } diff --git a/processing/src/test/java/org/apache/druid/query/extraction/MapBasedLookupExtractorTest.java b/processing/src/test/java/org/apache/druid/query/extraction/MapBasedLookupExtractorTest.java index 0726e733b343..0a7c5acff5b3 100644 --- a/processing/src/test/java/org/apache/druid/query/extraction/MapBasedLookupExtractorTest.java +++ b/processing/src/test/java/org/apache/druid/query/extraction/MapBasedLookupExtractorTest.java @@ -24,8 +24,8 @@ import org.apache.commons.compress.utils.Lists; import org.apache.druid.query.lookup.ImmutableLookupMap; import org.apache.druid.query.lookup.LookupExtractor; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.Nullable; import java.util.Collections; @@ -55,30 +55,30 @@ public abstract class MapBasedLookupExtractorTest public void test_unapplyAll_simple() { final LookupExtractor lookup = makeLookupExtractor(simpleLookupMap); - Assert.assertEquals(Collections.singletonList("foo"), unapply(lookup, "bar")); - Assert.assertEquals(Collections.emptySet(), Sets.newHashSet(unapply(lookup, null))); - Assert.assertEquals(Sets.newHashSet("null", "empty String"), Sets.newHashSet(unapply(lookup, ""))); - Assert.assertEquals(Sets.newHashSet(""), Sets.newHashSet(unapply(lookup, "empty_string"))); - Assert.assertEquals("not existing value returns empty list", Collections.emptyList(), unapply(lookup, "not There")); + Assertions.assertEquals(Collections.singletonList("foo"), unapply(lookup, "bar")); + Assertions.assertEquals(Collections.emptySet(), Sets.newHashSet(unapply(lookup, null))); + Assertions.assertEquals(Sets.newHashSet("null", "empty String"), Sets.newHashSet(unapply(lookup, ""))); + Assertions.assertEquals(Sets.newHashSet(""), Sets.newHashSet(unapply(lookup, "empty_string"))); + Assertions.assertEquals(Collections.emptyList(), unapply(lookup, "not There"), "not existing value returns empty list"); } @Test public void test_asMap_simple() { final LookupExtractor lookup = makeLookupExtractor(simpleLookupMap); - Assert.assertTrue(lookup.supportsAsMap()); - Assert.assertEquals(simpleLookupMap, lookup.asMap()); + Assertions.assertTrue(lookup.supportsAsMap()); + Assertions.assertEquals(simpleLookupMap, lookup.asMap()); } @Test public void test_apply_simple() { final LookupExtractor lookup = makeLookupExtractor(simpleLookupMap); - Assert.assertEquals("bar", lookup.apply("foo")); - Assert.assertEquals("", lookup.apply("null")); - Assert.assertEquals("", lookup.apply("empty String")); - Assert.assertEquals("empty_string", lookup.apply("")); - Assert.assertNull(lookup.apply(null)); + Assertions.assertEquals("bar", lookup.apply("foo")); + Assertions.assertEquals("", lookup.apply("null")); + Assertions.assertEquals("", lookup.apply("empty String")); + Assertions.assertEquals("empty_string", lookup.apply("")); + Assertions.assertNull(lookup.apply(null)); } @Test @@ -88,9 +88,9 @@ public void test_apply_nullKey() mapWithNullKey.put(null, "nv"); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertNull(lookup.apply("missing")); - Assert.assertNull(lookup.apply("")); - Assert.assertNull(lookup.apply(null)); + Assertions.assertNull(lookup.apply("missing")); + Assertions.assertNull(lookup.apply("")); + Assertions.assertNull(lookup.apply(null)); } @Test @@ -100,12 +100,12 @@ public void test_unapply_nullKey() mapWithNullKey.put(null, "nv"); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertEquals( + Assertions.assertEquals( Collections.emptyList(), unapply(lookup, "nv") ); - Assert.assertEquals( + Assertions.assertEquals( Collections.emptyList(), unapply(lookup, null) ); @@ -118,7 +118,7 @@ public void test_apply_nullValue() mapWithNullKey.put("nk", null); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertNull(lookup.apply("nk")); + Assertions.assertNull(lookup.apply("nk")); } @Test @@ -128,7 +128,7 @@ public void test_unapply_nullValue() mapWithNullKey.put("nk", null); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertEquals( + Assertions.assertEquals( Collections.singletonList("nk"), unapply(lookup, null) ); @@ -141,7 +141,7 @@ public void test_apply_emptyStringValue() mapWithNullKey.put("nk", ""); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertEquals( + Assertions.assertEquals( "", lookup.apply("nk") ); @@ -154,12 +154,12 @@ public void test_unapply_emptyStringValue() mapWithNullKey.put("nk", ""); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertEquals( + Assertions.assertEquals( Collections.emptyList(), unapply(lookup, null) ); - Assert.assertEquals( + Assertions.assertEquals( Collections.singletonList("nk"), unapply(lookup, "") ); @@ -173,9 +173,9 @@ public void test_apply_nullAndEmptyStringKey() mapWithNullKey.put("", "empty"); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertNull(lookup.apply("missing")); - Assert.assertEquals("empty", lookup.apply("")); - Assert.assertNull(lookup.apply(null)); + Assertions.assertNull(lookup.apply("missing")); + Assertions.assertEquals("empty", lookup.apply("")); + Assertions.assertNull(lookup.apply(null)); } @Test @@ -186,12 +186,12 @@ public void test_unapply_nullAndEmptyStringKey() mapWithNullKey.put("", "empty"); final LookupExtractor lookup = makeLookupExtractor(mapWithNullKey); - Assert.assertEquals( + Assertions.assertEquals( Collections.singletonList(""), unapply(lookup, "empty") ); - Assert.assertEquals( + Assertions.assertEquals( Collections.emptyList(), unapply(lookup, "nv") ); @@ -200,8 +200,8 @@ public void test_unapply_nullAndEmptyStringKey() @Test public void test_estimateHeapFootprint() { - Assert.assertEquals(0L, makeLookupExtractor(Collections.emptyMap()).estimateHeapFootprint()); - Assert.assertEquals(388L, makeLookupExtractor(simpleLookupMap).estimateHeapFootprint()); + Assertions.assertEquals(0L, makeLookupExtractor(Collections.emptyMap()).estimateHeapFootprint()); + Assertions.assertEquals(388L, makeLookupExtractor(simpleLookupMap).estimateHeapFootprint()); } protected List unapply(final LookupExtractor lookup, @Nullable final String s) diff --git a/processing/src/test/java/org/apache/druid/query/lookup/LookupSegmentTest.java b/processing/src/test/java/org/apache/druid/query/lookup/LookupSegmentTest.java index 68fc3210b4ed..afeaf78e710f 100644 --- a/processing/src/test/java/org/apache/druid/query/lookup/LookupSegmentTest.java +++ b/processing/src/test/java/org/apache/druid/query/lookup/LookupSegmentTest.java @@ -35,10 +35,8 @@ import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; import org.apache.druid.segment.column.ValueType; -import org.hamcrest.CoreMatchers; -import org.hamcrest.MatcherAssert; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.Nullable; import java.util.ArrayList; @@ -106,31 +104,31 @@ public LookupExtractor get() @Test public void test_getId() { - Assert.assertNull(LOOKUP_SEGMENT.getId()); + Assertions.assertNull(LOOKUP_SEGMENT.getId()); } @Test public void test_getDebugString() { - Assert.assertEquals("LookupSegment:mylookup", LOOKUP_SEGMENT.getDebugString()); + Assertions.assertEquals("LookupSegment:mylookup", LOOKUP_SEGMENT.getDebugString()); } @Test public void test_getDataInterval() { - Assert.assertEquals(Intervals.ETERNITY, LOOKUP_SEGMENT.getDataInterval()); + Assertions.assertEquals(Intervals.ETERNITY, LOOKUP_SEGMENT.getDataInterval()); } @Test public void test_asQueryableIndex() { - Assert.assertNull(LOOKUP_SEGMENT.as(QueryableIndex.class)); + Assertions.assertNull(LOOKUP_SEGMENT.as(QueryableIndex.class)); } @Test public void test_asCursorFactory_getRowSignature() { - Assert.assertEquals( + Assertions.assertEquals( RowSignature.builder() .add("k", ColumnType.STRING) .add("v", ColumnType.STRING) @@ -144,13 +142,13 @@ public void test_asCursorFactory_getColumnCapabilitiesK() { final ColumnCapabilities capabilities = LOOKUP_SEGMENT.as(CursorFactory.class).getColumnCapabilities("k"); - Assert.assertEquals(ValueType.STRING, capabilities.getType()); + Assertions.assertEquals(ValueType.STRING, capabilities.getType()); // Note: the "k" column does not actually have multiple values, but the RowBasedStorageAdapter doesn't allow // reporting complete single-valued capabilities. It would be good to change this in the future, so query engines // running on top of lookups can take advantage of singly-valued optimizations. - Assert.assertTrue(capabilities.hasMultipleValues().isUnknown()); - Assert.assertFalse(capabilities.isDictionaryEncoded().isTrue()); + Assertions.assertTrue(capabilities.hasMultipleValues().isUnknown()); + Assertions.assertFalse(capabilities.isDictionaryEncoded().isTrue()); } @Test @@ -161,9 +159,9 @@ public void test_asCursorFactory_getColumnCapabilitiesV() // Note: the "v" column does not actually have multiple values, but the RowBasedStorageAdapter doesn't allow // reporting complete single-valued capabilities. It would be good to change this in the future, so query engines // running on top of lookups can take advantage of singly-valued optimizations. - Assert.assertEquals(ValueType.STRING, capabilities.getType()); - Assert.assertTrue(capabilities.hasMultipleValues().isUnknown()); - Assert.assertFalse(capabilities.isDictionaryEncoded().isTrue()); + Assertions.assertEquals(ValueType.STRING, capabilities.getType()); + Assertions.assertTrue(capabilities.hasMultipleValues().isUnknown()); + Assertions.assertFalse(capabilities.isDictionaryEncoded().isTrue()); } @Test @@ -185,7 +183,7 @@ public void test_asCursorFactory_makeCursor() cursor.advanceUninterruptibly(); } - Assert.assertEquals( + Assertions.assertEquals( ImmutableList.of( Pair.of("a", "b"), Pair.of("x", "y") @@ -200,6 +198,6 @@ public void test_asCursorFactory_isRowBasedAdapter() { // This allows us to assume that LookupSegmentTest is further exercising makeCursor and verifying misc. // methods like getMinTime, getMaxTime, getMetadata, etc, without checking them explicitly in _this_ test class. - MatcherAssert.assertThat(LOOKUP_SEGMENT.as(CursorFactory.class), CoreMatchers.instanceOf(RowBasedCursorFactory.class)); + Assertions.assertInstanceOf(RowBasedCursorFactory.class, LOOKUP_SEGMENT.as(CursorFactory.class)); } } diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryLimitRowIteratorTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryLimitRowIteratorTest.java index c4dccff2b3c8..708cc0c0ccb6 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryLimitRowIteratorTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryLimitRowIteratorTest.java @@ -28,18 +28,19 @@ import org.apache.druid.query.QueryRunnerTestHelper; import org.apache.druid.query.context.ResponseContext; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; -@RunWith(Parameterized.class) +@ParameterizedClass +@MethodSource("constructorFeeder") public class ScanQueryLimitRowIteratorTest extends InitializedNullHandlingTest { private static final int NUM_ELEMENTS = 1000; @@ -58,7 +59,6 @@ public ScanQueryLimitRowIteratorTest( this.limit = limit; } - @Parameterized.Parameters(name = "{0} {1}") public static Iterable constructorFeeder() { List batchSizes = ImmutableList.of(1, 33); @@ -69,7 +69,7 @@ public static Iterable constructorFeeder() ); } - @Before + @BeforeEach public void setup() { singleEventScanResultValues = new ArrayList<>(); @@ -128,14 +128,14 @@ public void testNonOrderedScan() List> events = ScanQueryTestHelper.getEventsListResultFormat(curr); if (events.size() != batchSize) { if (expectedNumRows - count > batchSize) { - Assert.fail("Batch size is incorrect"); + Assertions.fail("Batch size is incorrect"); } else { - Assert.assertEquals(expectedNumRows - count, events.size()); + Assertions.assertEquals(expectedNumRows - count, events.size()); } } count += events.size(); } - Assert.assertEquals(expectedNumRows, count); + Assertions.assertEquals(expectedNumRows, count); } /** @@ -167,14 +167,14 @@ public void testBrokerOrderedScan() List> events = ScanQueryTestHelper.getEventsListResultFormat(curr); if (events.size() != batchSize) { if (expectedNumRows - count >= batchSize) { - Assert.fail("Batch size is incorrect"); + Assertions.fail("Batch size is incorrect"); } else { - Assert.assertEquals(expectedNumRows - count, events.size()); + Assertions.assertEquals(expectedNumRows - count, events.size()); } } count += events.size(); } - Assert.assertEquals(expectedNumRows, count); + Assertions.assertEquals(expectedNumRows, count); } /** @@ -206,9 +206,9 @@ public void testHistoricalOrderedScan() while (itr.hasNext()) { ScanResultValue curr = itr.next(); List> events = ScanQueryTestHelper.getEventsListResultFormat(curr); - Assert.assertEquals(1, events.size()); + Assertions.assertEquals(1, events.size()); count += events.size(); } - Assert.assertEquals(expectedNumRows, count); + Assertions.assertEquals(expectedNumRows, count); } } diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java index 36e57a927f7b..319036e295ef 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java @@ -26,9 +26,9 @@ import org.apache.druid.query.spec.QuerySegmentSpec; import org.apache.druid.segment.column.ColumnHolder; import org.joda.time.Interval; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collections; @@ -39,7 +39,7 @@ public class ScanResultValueTimestampComparatorTest { private static QuerySegmentSpec intervalSpec; - @BeforeClass + @BeforeAll public static void setup() { intervalSpec = new MultipleIntervalSegmentSpec( @@ -83,7 +83,7 @@ public void testComparisonDescendingList() events2 ); - Assert.assertEquals(1, comparator.compare(s1, s2)); + Assertions.assertEquals(1, comparator.compare(s1, s2)); } @Test @@ -120,7 +120,7 @@ public void testComparisonAscendingList() events2 ); - Assert.assertEquals(-1, comparator.compare(s1, s2)); + Assertions.assertEquals(-1, comparator.compare(s1, s2)); } @Test @@ -155,7 +155,7 @@ public void testComparisonDescendingCompactedList() events2 ); - Assert.assertEquals(1, comparator.compare(s1, s2)); + Assertions.assertEquals(1, comparator.compare(s1, s2)); } @Test @@ -190,6 +190,6 @@ public void testAscendingCompactedList() events2 ); - Assert.assertEquals(-1, comparator.compare(s1, s2)); + Assertions.assertEquals(-1, comparator.compare(s1, s2)); } } diff --git a/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java index 40e2ac296ecb..5ab3783869ed 100644 --- a/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/spec/SpecificSegmentQueryRunnerTest.java @@ -44,8 +44,8 @@ import org.apache.druid.query.timeseries.TimeseriesResultBuilder; import org.apache.druid.query.timeseries.TimeseriesResultValue; import org.apache.druid.segment.SegmentMissingException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; @@ -188,11 +188,11 @@ public void run() Sequence results = queryRunner.run(QueryPlus.wrap(query), responseContext); List> res = results.toList(); - Assert.assertEquals(1, res.size()); + Assertions.assertEquals(1, res.size()); Result theVal = res.get(0); - Assert.assertTrue(1L == theVal.getValue().getLongMetric("rows")); + Assertions.assertTrue(1L == theVal.getValue().getLongMetric("rows")); validate(mapper, descriptor, responseContext); } @@ -201,10 +201,10 @@ private void validate(ObjectMapper mapper, SegmentDescriptor descriptor, Respons throws IOException { List missingSegments = responseContext.getMissingSegments(); - Assert.assertTrue(missingSegments != null); + Assertions.assertTrue(missingSegments != null); SegmentDescriptor segmentDesc = missingSegments.get(0); SegmentDescriptor newDesc = mapper.readValue(mapper.writeValueAsString(segmentDesc), SegmentDescriptor.class); - Assert.assertEquals(descriptor, newDesc); + Assertions.assertEquals(descriptor, newDesc); } } diff --git a/processing/src/test/java/org/apache/druid/query/timeseries/TimeseriesBinaryFnTest.java b/processing/src/test/java/org/apache/druid/query/timeseries/TimeseriesBinaryFnTest.java index 0cd3df176bbb..842b55696eda 100644 --- a/processing/src/test/java/org/apache/druid/query/timeseries/TimeseriesBinaryFnTest.java +++ b/processing/src/test/java/org/apache/druid/query/timeseries/TimeseriesBinaryFnTest.java @@ -27,8 +27,8 @@ import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.joda.time.DateTime; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -84,7 +84,7 @@ public void testMerge() result1, result2 ); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -126,7 +126,7 @@ public void testMergeDay() result1, result2 ); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -152,7 +152,7 @@ public void testMergeOneNullResult() result1, result2 ); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -194,6 +194,6 @@ public void testMergeShiftedTimestamp() result1, result2 ); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/processing/src/test/java/org/apache/druid/query/union/UnionQueryQueryToolChestTest.java b/processing/src/test/java/org/apache/druid/query/union/UnionQueryQueryToolChestTest.java index c4669b5075ad..8b2b465fd171 100644 --- a/processing/src/test/java/org/apache/druid/query/union/UnionQueryQueryToolChestTest.java +++ b/processing/src/test/java/org/apache/druid/query/union/UnionQueryQueryToolChestTest.java @@ -41,7 +41,7 @@ import org.apache.druid.query.spec.MultipleIntervalSegmentSpec; import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -95,7 +95,7 @@ public void testResultArraySignatureWithTimestampResultField() UnionQuery query = new UnionQuery(queries); - Assert.assertEquals( + Assertions.assertEquals( sig, query.getResultRowSignature() ); diff --git a/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java b/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java index da3361c155b8..77b386fc5896 100644 --- a/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java +++ b/processing/src/test/java/org/apache/druid/segment/StringDimensionIndexerTest.java @@ -22,8 +22,8 @@ import org.apache.druid.data.input.impl.DimensionSchema; import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -83,7 +83,7 @@ public void testProcessRowValsToEncodedKeyComponent_usingAvgEstimates() 94L ); - Assert.assertEquals(306L, totalEstimatedSize); + Assertions.assertEquals(306L, totalEstimatedSize); } @Test @@ -108,7 +108,7 @@ public void testProcessRowValsToEncodedKeyComponent_comparison() } // If all dimension values are unique (or cardinality is high), - Assert.assertEquals(940L, totalSizeWithAvgEstimates); + Assertions.assertEquals(940L, totalSizeWithAvgEstimates); // Verify sizes with repeated dimension values for (int i = 0; i < 100; ++i) { @@ -122,7 +122,7 @@ public void testProcessRowValsToEncodedKeyComponent_comparison() ); } - Assert.assertEquals(2940L, totalSizeWithAvgEstimates); + Assertions.assertEquals(2940L, totalSizeWithAvgEstimates); } @Test @@ -135,7 +135,7 @@ public void testBinaryInputs() ); final byte[] byteVal = new byte[]{0x01, 0x02, 0x03, 0x04}; EncodedKeyComponent keyComponent = indexer.processRowValsToUnsortedEncodedKeyComponent(byteVal, false); - Assert.assertEquals( + Assertions.assertEquals( StringUtils.encodeBase64String(byteVal), indexer.convertUnsortedEncodedKeyComponentToActualList(keyComponent.getComponent()) ); @@ -152,7 +152,7 @@ public void testTruncation() ); EncodedKeyComponent keyComponent = indexer.processRowValsToUnsortedEncodedKeyComponent("abcdefghij", false); - Assert.assertEquals( + Assertions.assertEquals( "abcde", indexer.convertUnsortedEncodedKeyComponentToActualList(keyComponent.getComponent()) ); @@ -172,7 +172,7 @@ public void testSingleValueMvdTruncated() Collections.singletonList("abcdefghij"), false ); - Assert.assertEquals( + Assertions.assertEquals( "abcde", indexer.convertUnsortedEncodedKeyComponentToActualList(keyComponent.getComponent()) ); @@ -192,7 +192,7 @@ public void testMultiValueNotTruncated() Arrays.asList("abcdefghij", "klmnopqrst"), false ); - Assert.assertEquals( + Assertions.assertEquals( Arrays.asList("abcdefghij", "klmnopqrst"), indexer.convertUnsortedEncodedKeyComponentToActualList(keyComponent.getComponent()) ); @@ -207,8 +207,8 @@ private long verifyEncodedValues( { EncodedKeyComponent encodedKeyComponent = indexer .processRowValsToUnsortedEncodedKeyComponent(dimensionValues, false); - Assert.assertArrayEquals(expectedEncodedValues, encodedKeyComponent.getComponent()); - Assert.assertEquals(expectedSizeDelta, encodedKeyComponent.getEffectiveSizeBytes()); + Assertions.assertArrayEquals(expectedEncodedValues, encodedKeyComponent.getComponent()); + Assertions.assertEquals(expectedSizeDelta, encodedKeyComponent.getEffectiveSizeBytes()); return encodedKeyComponent.getEffectiveSizeBytes(); } diff --git a/processing/src/test/java/org/apache/druid/segment/join/table/LookupJoinMatcherTest.java b/processing/src/test/java/org/apache/druid/segment/join/table/LookupJoinMatcherTest.java index 6b43b2bc009c..5eea9cdb7190 100644 --- a/processing/src/test/java/org/apache/druid/segment/join/table/LookupJoinMatcherTest.java +++ b/processing/src/test/java/org/apache/druid/segment/join/table/LookupJoinMatcherTest.java @@ -32,18 +32,21 @@ import org.apache.druid.segment.data.SingleIndexedInt; import org.apache.druid.segment.join.JoinConditionAnalysis; import org.apache.druid.segment.join.lookup.LookupJoinMatcher; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import java.util.Map; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class LookupJoinMatcherTest { private final Map lookupMap = @@ -61,7 +64,7 @@ public class LookupJoinMatcherTest private LookupJoinMatcher target; - @Before + @BeforeEach public void setUp() { Mockito.doReturn(true).when(extractor).supportsAsMap(); @@ -73,9 +76,9 @@ public void testCreateConditionAlwaysFalseShouldReturnSuccessfullyAndNotThrowExc { JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression("0", PREFIX, ExprMacroTable.nil()); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, false); - Assert.assertNotNull(target); + Assertions.assertNotNull(target); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); - Assert.assertNotNull(target); + Assertions.assertNotNull(target); } @Test @@ -84,9 +87,9 @@ public void testCreateConditionAlwaysTrueShouldReturnSuccessfullyAndNotThrowExce JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression("1", PREFIX, ExprMacroTable.nil()); Mockito.doReturn(true).when(extractor).supportsAsMap(); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, false); - Assert.assertNotNull(target); + Assertions.assertNotNull(target); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); - Assert.assertNotNull(target); + Assertions.assertNotNull(target); } @Test @@ -96,23 +99,23 @@ public void testMatchConditionAlwaysTrue() target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); // Test match first target.matchCondition(); - Assert.assertTrue(target.hasMatch()); + Assertions.assertTrue(target.hasMatch()); verifyMatch("foo", "bar"); // Test match second target.nextMatch(); - Assert.assertTrue(target.hasMatch()); + Assertions.assertTrue(target.hasMatch()); verifyMatch("null", ""); // Test match third target.nextMatch(); - Assert.assertTrue(target.hasMatch()); + Assertions.assertTrue(target.hasMatch()); verifyMatch("empty String", ""); // Test match forth target.nextMatch(); - Assert.assertTrue(target.hasMatch()); + Assertions.assertTrue(target.hasMatch()); verifyMatch("", "empty_string"); // Test no more target.nextMatch(); - Assert.assertFalse(target.hasMatch()); + Assertions.assertFalse(target.hasMatch()); } @Test @@ -122,7 +125,7 @@ public void testMatchConditionAlwaysFalse() target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); // Test match first target.matchCondition(); - Assert.assertFalse(target.hasMatch()); + Assertions.assertFalse(target.hasMatch()); verifyMatch(null, null); } @@ -145,14 +148,14 @@ public void testMatchConditionSometimesTrueSometimesFalse() target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); // Test match target.matchCondition(); - Assert.assertTrue(target.hasMatch()); + Assertions.assertTrue(target.hasMatch()); verifyMatch("foo", "bar"); // Test no more target.nextMatch(); - Assert.assertFalse(target.hasMatch()); + Assertions.assertFalse(target.hasMatch()); } - @Test(expected = QueryUnsupportedException.class) + @Test public void testMatchMultiValuedRowShouldThrowException() { ArrayBasedIndexedInts row = new ArrayBasedIndexedInts(new int[]{2, 4, 6}); @@ -166,7 +169,7 @@ public void testMatchMultiValuedRowShouldThrowException() ); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); // Test match should throw exception - target.matchCondition(); + Assertions.assertThrows(QueryUnsupportedException.class, () -> target.matchCondition()); } @Test @@ -183,23 +186,23 @@ public void testMatchEmptyRow() ); target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true); target.matchCondition(); - Assert.assertFalse(target.hasMatch()); + Assertions.assertFalse(target.hasMatch()); } private void verifyMatch(String expectedKey, String expectedValue) { DimensionSelector selector = target.getColumnSelectorFactory() .makeDimensionSelector(DefaultDimensionSpec.of("k")); - Assert.assertEquals(-1, selector.getValueCardinality()); - Assert.assertEquals(expectedKey, selector.lookupName(0)); - Assert.assertEquals(expectedKey, selector.lookupName(0)); - Assert.assertNull(selector.idLookup()); + Assertions.assertEquals(-1, selector.getValueCardinality()); + Assertions.assertEquals(expectedKey, selector.lookupName(0)); + Assertions.assertEquals(expectedKey, selector.lookupName(0)); + Assertions.assertNull(selector.idLookup()); selector = target.getColumnSelectorFactory() .makeDimensionSelector(DefaultDimensionSpec.of("v")); - Assert.assertEquals(-1, selector.getValueCardinality()); - Assert.assertEquals(expectedValue, selector.lookupName(0)); - Assert.assertEquals(expectedValue, selector.lookupName(0)); - Assert.assertNull(selector.idLookup()); + Assertions.assertEquals(-1, selector.getValueCardinality()); + Assertions.assertEquals(expectedValue, selector.lookupName(0)); + Assertions.assertEquals(expectedValue, selector.lookupName(0)); + Assertions.assertNull(selector.idLookup()); } } diff --git a/processing/src/test/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpecTest.java b/processing/src/test/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpecTest.java index 2b6b2eb15651..962410e10d8d 100644 --- a/processing/src/test/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpecTest.java +++ b/processing/src/test/java/org/apache/druid/segment/nested/NestedCommonFormatColumnFormatSpecTest.java @@ -31,7 +31,7 @@ import org.apache.druid.segment.data.FrontCodedIndexed; import org.apache.druid.segment.data.RoaringBitmapSerdeFactory; import org.apache.druid.segment.serde.NestedCommonFormatColumnPartSerde; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class NestedCommonFormatColumnFormatSpecTest @@ -50,7 +50,7 @@ public void testSerde() throws JsonProcessingException .setDoubleFieldBitmapIndexType(BitmapIndexType.NullValueIndex.INSTANCE) .build(); // NestedCommonFormatColumnFormatSpec does not support serde for BitmapEncoding, value would be ignored - Assert.assertEquals( + Assertions.assertEquals( NestedCommonFormatColumnFormatSpec.builder(spec).setBitmapEncoding(null).build(), TestHelper.JSON_MAPPER.readValue( TestHelper.JSON_MAPPER.writeValueAsString(spec), @@ -75,7 +75,7 @@ public void testSerdeFormatSpec() throws JsonProcessingException TestHelper.JSON_MAPPER.writeValueAsString(spec), NestedCommonFormatColumnPartSerde.FormatSpec.class ); - Assert.assertEquals(spec.toString(), formatSpec.toString()); + Assertions.assertEquals(spec.toString(), formatSpec.toString()); } @Test @@ -86,27 +86,27 @@ public void testGetEffectiveSpecDefaults() IndexSpec.getDefault().getEffectiveSpec() ); - Assert.assertEquals(StringEncodingStrategy.UTF8_STRATEGY, defaults.getObjectFieldsDictionaryEncoding()); - Assert.assertEquals(ObjectStorageEncoding.SMILE, defaults.getObjectStorageEncoding()); - Assert.assertEquals(CompressionStrategy.LZ4, defaults.getObjectStorageCompression()); - Assert.assertEquals( + Assertions.assertEquals(StringEncodingStrategy.UTF8_STRATEGY, defaults.getObjectFieldsDictionaryEncoding()); + Assertions.assertEquals(ObjectStorageEncoding.SMILE, defaults.getObjectStorageEncoding()); + Assertions.assertEquals(CompressionStrategy.LZ4, defaults.getObjectStorageCompression()); + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getDimensionCompression(), defaults.getDictionaryEncodedColumnCompression() ); - Assert.assertEquals( + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getStringDictionaryEncoding(), defaults.getStringDictionaryEncoding() ); - Assert.assertEquals( + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getMetricCompression(), defaults.getLongColumnCompression() ); - Assert.assertEquals( + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getMetricCompression(), defaults.getDoubleColumnCompression() ); - Assert.assertEquals(BitmapIndexType.DictionaryEncodedValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); - Assert.assertEquals(BitmapIndexType.DictionaryEncodedValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); + Assertions.assertEquals(BitmapIndexType.DictionaryEncodedValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); + Assertions.assertEquals(BitmapIndexType.DictionaryEncodedValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); } @Test @@ -129,21 +129,21 @@ public void testEffectiveSpecIndexSpecOverrides() .getEffectiveSpec() ); - Assert.assertEquals(frontcoded, defaults.getObjectFieldsDictionaryEncoding()); - Assert.assertEquals(ObjectStorageEncoding.NONE, defaults.getObjectStorageEncoding()); - Assert.assertEquals(CompressionStrategy.LZ4, defaults.getObjectStorageCompression()); - Assert.assertEquals( + Assertions.assertEquals(frontcoded, defaults.getObjectFieldsDictionaryEncoding()); + Assertions.assertEquals(ObjectStorageEncoding.NONE, defaults.getObjectStorageEncoding()); + Assertions.assertEquals(CompressionStrategy.LZ4, defaults.getObjectStorageCompression()); + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getDimensionCompression(), defaults.getDictionaryEncodedColumnCompression() ); - Assert.assertEquals( + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getStringDictionaryEncoding(), defaults.getStringDictionaryEncoding() ); - Assert.assertEquals(CompressionStrategy.LZF, defaults.getLongColumnCompression()); - Assert.assertEquals(CompressionStrategy.LZF, defaults.getDoubleColumnCompression()); - Assert.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); - Assert.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, defaults.getDoubleFieldBitmapIndexType()); + Assertions.assertEquals(CompressionStrategy.LZF, defaults.getLongColumnCompression()); + Assertions.assertEquals(CompressionStrategy.LZF, defaults.getDoubleColumnCompression()); + Assertions.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, defaults.getLongFieldBitmapIndexType()); + Assertions.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, defaults.getDoubleFieldBitmapIndexType()); } @Test @@ -163,33 +163,33 @@ public void testGetEffectiveSpecMerge() IndexSpec.getDefault().getEffectiveSpec() ); - Assert.assertEquals( + Assertions.assertEquals( new StringEncodingStrategy.FrontCoded(4, FrontCodedIndexed.V1), merged.getObjectFieldsDictionaryEncoding() ); - Assert.assertEquals( + Assertions.assertEquals( new StringEncodingStrategy.FrontCoded(4, FrontCodedIndexed.V1), merged.getStringDictionaryEncoding() ); - Assert.assertEquals(ObjectStorageEncoding.NONE, merged.getObjectStorageEncoding()); - Assert.assertEquals( + Assertions.assertEquals(ObjectStorageEncoding.NONE, merged.getObjectStorageEncoding()); + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getDimensionCompression(), merged.getDictionaryEncodedColumnCompression() ); - Assert.assertEquals(CompressionStrategy.ZSTD, merged.getObjectStorageCompression()); - Assert.assertEquals( + Assertions.assertEquals(CompressionStrategy.ZSTD, merged.getObjectStorageCompression()); + Assertions.assertEquals( IndexSpec.getDefault().getEffectiveSpec().getMetricCompression(), merged.getLongColumnCompression() ); - Assert.assertEquals(CompressionStrategy.ZSTD, merged.getDoubleColumnCompression()); - Assert.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, merged.getLongFieldBitmapIndexType()); - Assert.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, merged.getDoubleFieldBitmapIndexType()); + Assertions.assertEquals(CompressionStrategy.ZSTD, merged.getDoubleColumnCompression()); + Assertions.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, merged.getLongFieldBitmapIndexType()); + Assertions.assertEquals(BitmapIndexType.NullValueIndex.INSTANCE, merged.getDoubleFieldBitmapIndexType()); } @Test public void testGetEffectiveSpecInvalid() { - Throwable t = Assert.assertThrows( + Throwable t = Assertions.assertThrows( ISE.class, () -> NestedCommonFormatColumnFormatSpec.getEffectiveFormatSpec( NestedCommonFormatColumnFormatSpec.builder().setBitmapEncoding(new ConciseBitmapSerdeFactory()).build(), @@ -200,7 +200,7 @@ public void testGetEffectiveSpecInvalid() ) ); - Assert.assertEquals( + Assertions.assertEquals( "bitmapEncoding[ConciseBitmapSerdeFactory{}] does not match indexSpec.bitmap[RoaringBitmapSerdeFactory{}]", t.getMessage() ); diff --git a/processing/src/test/java/org/apache/druid/segment/nested/StructuredDataBuilderTest.java b/processing/src/test/java/org/apache/druid/segment/nested/StructuredDataBuilderTest.java index fa49e1104dc6..bbbba310e256 100644 --- a/processing/src/test/java/org/apache/druid/segment/nested/StructuredDataBuilderTest.java +++ b/processing/src/test/java/org/apache/druid/segment/nested/StructuredDataBuilderTest.java @@ -20,8 +20,8 @@ package org.apache.druid.segment.nested; import org.apache.druid.error.DruidException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -38,7 +38,7 @@ public void testBuildSingleDepth() array, 1 ); - Assert.assertEquals(StructuredData.wrap(array), new StructuredDataBuilder(childArrayElement).build()); + Assertions.assertEquals(StructuredData.wrap(array), new StructuredDataBuilder(childArrayElement).build()); // [null, [1, 2]] StructuredDataBuilder.Element arrayElement = new StructuredDataBuilder.Element( @@ -46,7 +46,7 @@ public void testBuildSingleDepth() array, 0 ); - Assert.assertEquals( + Assertions.assertEquals( StructuredData.wrap(Arrays.asList(null, array)), new StructuredDataBuilder(arrayElement).build() ); @@ -56,7 +56,7 @@ public void testBuildSingleDepth() null, 0 ); - Assert.assertEquals(StructuredData.wrap(Map.of()), new StructuredDataBuilder(nullElement).build()); + Assertions.assertEquals(StructuredData.wrap(Map.of()), new StructuredDataBuilder(nullElement).build()); // {"x": "hi"} StructuredDataBuilder.Element mapElement = new StructuredDataBuilder.Element( @@ -64,7 +64,7 @@ public void testBuildSingleDepth() "hi", 0 ); - Assert.assertEquals( + Assertions.assertEquals( StructuredData.wrap(Map.of("x", "hi")), new StructuredDataBuilder(mapElement, nullElement).build() ); @@ -79,7 +79,7 @@ public void testBuildRootPath() "root-val", 0 ); - Assert.assertEquals(StructuredData.wrap("root-val"), new StructuredDataBuilder(rootElement).build()); + Assertions.assertEquals(StructuredData.wrap("root-val"), new StructuredDataBuilder(rootElement).build()); } @Test @@ -98,7 +98,7 @@ public void testBuildArrayMultipleDepths() 0 ); List expected = List.of(List.of(1), Arrays.asList(null, array)); - Assert.assertEquals(StructuredData.wrap(expected), new StructuredDataBuilder(element1, element2).build()); + Assertions.assertEquals(StructuredData.wrap(expected), new StructuredDataBuilder(element1, element2).build()); } @Test @@ -121,7 +121,7 @@ public void testBuildMapMultipleDepths() 0 ); Map expected = Map.of("x", Map.of("y", "hi-xy", "z", "hi-xz"), "yz", Map.of("z", "hi-yz")); - Assert.assertEquals( + Assertions.assertEquals( StructuredData.wrap(expected), new StructuredDataBuilder(xyElement, xzElement, yzElement).build() ); @@ -151,7 +151,7 @@ public void testBuildMixedMultipleDepths() "x", Map.of("y", "hi-xy", "array", Arrays.asList("hi-x-array-0", null, "hi-x-array-2")) ); - Assert.assertEquals(StructuredData.wrap(expected), new StructuredDataBuilder(xyElement, xArray, xArray2).build()); + Assertions.assertEquals(StructuredData.wrap(expected), new StructuredDataBuilder(xyElement, xArray, xArray2).build()); } @Test @@ -172,29 +172,29 @@ public void testBuildExceptions() 1, 0 ); - DruidException e1 = Assert.assertThrows( + DruidException e1 = Assertions.assertThrows( DruidException.class, () -> new StructuredDataBuilder(rootElement, mapElement).build() ); - Assert.assertEquals( + Assertions.assertEquals( "Error building structured data from paths[[Element{path=[], value=root-val, depth=0}, Element{path=[NestedPathField{field='x'}], value=hi, depth=0}]], " + "cannot have map or array elements when root value is set", e1.getMessage() ); - DruidException e2 = Assert.assertThrows( + DruidException e2 = Assertions.assertThrows( DruidException.class, () -> new StructuredDataBuilder(rootElement, arrayElement).build() ); - Assert.assertEquals( + Assertions.assertEquals( "Error building structured data from paths[[Element{path=[], value=root-val, depth=0}, Element{path=[NestedPathArrayElement{index=0}], value=1, depth=0}]], " + "cannot have map or array elements when root value is set", e2.getMessage() ); - DruidException e3 = Assert.assertThrows( + DruidException e3 = Assertions.assertThrows( DruidException.class, () -> new StructuredDataBuilder(mapElement, arrayElement).build() ); - Assert.assertEquals( + Assertions.assertEquals( "Error building structured data from paths[[Element{path=[NestedPathField{field='x'}], value=hi, depth=0}, Element{path=[NestedPathArrayElement{index=0}], value=1, depth=0}]], " + "cannot have both map and array elements at the same level", e3.getMessage() diff --git a/processing/src/test/java/org/apache/druid/segment/serde/DictionaryEncodedStringIndexSupplierTest.java b/processing/src/test/java/org/apache/druid/segment/serde/DictionaryEncodedStringIndexSupplierTest.java index 74319c884a83..245c3edce4c9 100644 --- a/processing/src/test/java/org/apache/druid/segment/serde/DictionaryEncodedStringIndexSupplierTest.java +++ b/processing/src/test/java/org/apache/druid/segment/serde/DictionaryEncodedStringIndexSupplierTest.java @@ -33,8 +33,8 @@ import org.apache.druid.segment.index.semantic.StringValueSetIndexes; import org.apache.druid.segment.writeout.OnHeapMemorySegmentWriteOutMedium; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.roaringbitmap.IntIterator; import java.io.IOException; @@ -54,44 +54,44 @@ public void testStringColumnWithNullValueSetIndex() throws IOException { StringUtf8ColumnIndexSupplier indexSupplier = makeStringWithNullsSupplier(); StringValueSetIndexes valueSetIndex = indexSupplier.as(StringValueSetIndexes.class); - Assert.assertNotNull(valueSetIndex); + Assertions.assertNotNull(valueSetIndex); // 10 rows // dictionary: [null, b, foo, fooo, z] // column: [foo, null, fooo, b, z, fooo, z, null, null, foo] BitmapColumnIndex columnIndex = valueSetIndex.forValue("b"); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); ImmutableBitmap bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap, 3); // non-existent in local column columnIndex = valueSetIndex.forValue("fo"); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap); // set index columnIndex = valueSetIndex.forSortedValues(InDimFilter.ValuesSet.copyOf(ImmutableSet.of("b", "fooo", "z"))); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap, 2, 3, 4, 5, 6); // set index with single value in middle columnIndex = valueSetIndex.forSortedValues(InDimFilter.ValuesSet.copyOf(ImmutableSet.of("foo"))); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap, 0, 9); // set index with no element in column and all elements less than lowest non-null value columnIndex = valueSetIndex.forSortedValues(InDimFilter.ValuesSet.copyOf(ImmutableSet.of("a", "aa", "aaa"))); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap); // set index with no element in column and all elements greater than highest non-null value columnIndex = valueSetIndex.forSortedValues(InDimFilter.ValuesSet.copyOf(ImmutableSet.of("zz", "zzz", "zzzz"))); - Assert.assertNotNull(columnIndex); + Assertions.assertNotNull(columnIndex); bitmap = columnIndex.computeBitmapResult(bitmapResultFactory, false); checkBitmap(bitmap); } @@ -208,9 +208,9 @@ private void checkBitmap(ImmutableBitmap bitmap, int... expectedRows) { IntIterator iterator = bitmap.iterator(); for (int i : expectedRows) { - Assert.assertTrue(iterator.hasNext()); - Assert.assertEquals(i, iterator.next()); + Assertions.assertTrue(iterator.hasNext()); + Assertions.assertEquals(i, iterator.next()); } - Assert.assertFalse(iterator.hasNext()); + Assertions.assertFalse(iterator.hasNext()); } } diff --git a/processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java b/processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java index 4617317daf34..b88898e6d8cb 100644 --- a/processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java +++ b/processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java @@ -42,8 +42,8 @@ import org.apache.druid.segment.vector.VectorObjectSelector; import org.apache.druid.segment.vector.VectorValueSelector; import org.apache.druid.testing.InitializedNullHandlingTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; @@ -58,7 +58,7 @@ public void testSerde() throws JsonProcessingException final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, RoaringBitmapSerdeFactory.getInstance()); final String json = mapper.writeValueAsString(partSerde); - Assert.assertEquals(partSerde, mapper.readValue(json, ColumnPartSerde.class)); + Assertions.assertEquals(partSerde, mapper.readValue(json, ColumnPartSerde.class)); } @Test @@ -68,13 +68,13 @@ public void testDeserializer() final ColumnBuilder builder = new ColumnBuilder().setType(ValueType.DOUBLE); partSerde.getDeserializer().read(EMPTY_BUFFER, builder, ColumnConfig.DEFAULT, null); final ColumnCapabilities columnCapabilities = builder.build().getCapabilities(); - Assert.assertTrue(Types.is(columnCapabilities, ValueType.DOUBLE)); - Assert.assertTrue(columnCapabilities.hasNulls().isTrue()); - Assert.assertTrue(columnCapabilities.hasMultipleValues().isFalse()); - Assert.assertTrue(columnCapabilities.hasBitmapIndexes()); - Assert.assertTrue(columnCapabilities.isDictionaryEncoded().isTrue()); - Assert.assertTrue(columnCapabilities.areDictionaryValuesSorted().isTrue()); - Assert.assertTrue(columnCapabilities.areDictionaryValuesUnique().isTrue()); + Assertions.assertTrue(Types.is(columnCapabilities, ValueType.DOUBLE)); + Assertions.assertTrue(columnCapabilities.hasNulls().isTrue()); + Assertions.assertTrue(columnCapabilities.hasMultipleValues().isFalse()); + Assertions.assertTrue(columnCapabilities.hasBitmapIndexes()); + Assertions.assertTrue(columnCapabilities.isDictionaryEncoded().isTrue()); + Assertions.assertTrue(columnCapabilities.areDictionaryValuesSorted().isTrue()); + Assertions.assertTrue(columnCapabilities.areDictionaryValuesUnique().isTrue()); } @Test @@ -86,7 +86,7 @@ public void testDimensionSelector() BaseColumnHolder holder = builder.build(); BaseColumn theColumn = holder.getColumn(); - Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn); + Assertions.assertInstanceOf(DictionaryEncodedColumn.class, theColumn); DictionaryEncodedColumn dictionaryEncodedColumn = (DictionaryEncodedColumn) theColumn; ReadableOffset offset = new SimpleAscendingOffset(10); @@ -94,9 +94,9 @@ public void testDimensionSelector() offset, null ); - Assert.assertNull(dimensionSelector.getObject()); - Assert.assertEquals(1, dimensionSelector.getRow().size()); - Assert.assertEquals(0, dimensionSelector.getRow().get(0)); + Assertions.assertNull(dimensionSelector.getObject()); + Assertions.assertEquals(1, dimensionSelector.getRow().size()); + Assertions.assertEquals(0, dimensionSelector.getRow().get(0)); } @Test @@ -108,7 +108,7 @@ public void testDimensionVectorSelector() BaseColumnHolder holder = builder.build(); BaseColumn theColumn = holder.getColumn(); - Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn); + Assertions.assertInstanceOf(DictionaryEncodedColumn.class, theColumn); DictionaryEncodedColumn dictionaryEncodedColumn = (DictionaryEncodedColumn) theColumn; ReadableVectorOffset vectorOffset = new NoFilterVectorOffset(8, 0, 10); @@ -118,11 +118,11 @@ public void testDimensionVectorSelector() int[] rowVector = vectorSelector.getRowVector(); for (int i = 0; i < vectorOffset.getCurrentVectorSize(); i++) { - Assert.assertEquals(0, rowVector[i]); - Assert.assertNull(vectorSelector.lookupName(rowVector[i])); + Assertions.assertEquals(0, rowVector[i]); + Assertions.assertNull(vectorSelector.lookupName(rowVector[i])); } - Assert.assertThrows(UnsupportedOperationException.class, () -> { + Assertions.assertThrows(UnsupportedOperationException.class, () -> { dictionaryEncodedColumn.makeMultiValueDimensionVectorSelector(vectorOffset); }); } @@ -142,7 +142,7 @@ public void testVectorObjectSelector() VectorObjectSelector objectSelector = theColumn.makeVectorObjectSelector(vectorOffset); Object[] vector = objectSelector.getObjectVector(); for (int i = 0; i < vectorOffset.getCurrentVectorSize(); i++) { - Assert.assertNull(vector[i]); + Assertions.assertNull(vector[i]); } } @@ -159,8 +159,8 @@ public void testColumnValueSelector() ReadableOffset offset = new SimpleAscendingOffset(10); ColumnValueSelector valueSelector = theColumn.makeColumnValueSelector(offset); - Assert.assertTrue(valueSelector.isNull()); - Assert.assertEquals(0.0, valueSelector.getDouble(), 0.0); + Assertions.assertTrue(valueSelector.isNull()); + Assertions.assertEquals(0.0, valueSelector.getDouble(), 0.0); } @Test @@ -178,8 +178,8 @@ public void testVectorValueSelector() double[] vector = selector.getDoubleVector(); boolean[] nulls = selector.getNullVector(); for (int i = 0; i < vectorOffset.getCurrentVectorSize(); i++) { - Assert.assertEquals(0.0, vector[i], 0.0); - Assert.assertTrue(nulls[i]); + Assertions.assertEquals(0.0, vector[i], 0.0); + Assertions.assertTrue(nulls[i]); } } @@ -190,6 +190,6 @@ public void testIndexSupplier() final ColumnBuilder builder = new ColumnBuilder().setType(ValueType.DOUBLE); partSerde.getDeserializer().read(EMPTY_BUFFER, builder, ColumnConfig.DEFAULT, null); ColumnHolder holder = builder.build(); - Assert.assertNull(holder.getIndexSupplier()); + Assertions.assertNull(holder.getIndexSupplier()); } } diff --git a/processing/src/test/java/org/apache/druid/segment/writeout/FileWriteOutBytesTest.java b/processing/src/test/java/org/apache/druid/segment/writeout/FileWriteOutBytesTest.java index cd39c76c99d7..ec7b8780d064 100644 --- a/processing/src/test/java/org/apache/druid/segment/writeout/FileWriteOutBytesTest.java +++ b/processing/src/test/java/org/apache/druid/segment/writeout/FileWriteOutBytesTest.java @@ -22,9 +22,9 @@ import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.io.Closer; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -37,7 +37,7 @@ public class FileWriteOutBytesTest private FileChannel mockFileChannel; private File mockFile; - @Before + @BeforeEach public void setUp() { mockFileChannel = EasyMock.mock(FileChannel.class); @@ -72,14 +72,14 @@ public void write32KiBIntsShouldNotFlush() throws IOException public void writeShouldIncrementSize() throws IOException { fileWriteOutBytes.write(1); - Assert.assertEquals(1, fileWriteOutBytes.size()); + Assertions.assertEquals(1, fileWriteOutBytes.size()); } @Test public void writeIntShouldIncrementSize() throws IOException { fileWriteOutBytes.writeInt(1); - Assert.assertEquals(4, fileWriteOutBytes.size()); + Assertions.assertEquals(4, fileWriteOutBytes.size()); } @Test @@ -95,7 +95,7 @@ public void writeBufferLargerThanCapacityShouldIncrementSizeCorrectly() throws I EasyMock.replay(mockFileChannel); ByteBuffer src = ByteBuffer.allocate(32768 + 1); fileWriteOutBytes.write(src); - Assert.assertEquals(src.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(src.capacity(), fileWriteOutBytes.size()); EasyMock.verify(mockFileChannel); } @@ -112,7 +112,7 @@ public void writeBufferLargerThanCapacityWritesDirectlyToFileShouldIncrementSize EasyMock.replay(mockFileChannel); ByteBuffer src = ByteBuffer.allocate(32768 * 2 + 1); fileWriteOutBytes.write(src); - Assert.assertEquals(32768 * 2 + 1, fileWriteOutBytes.size()); + Assertions.assertEquals(32768 * 2 + 1, fileWriteOutBytes.size()); } @Test @@ -120,7 +120,7 @@ public void writeBufferSmallerThanCapacityShouldIncrementSizeCorrectly() throws { ByteBuffer src = ByteBuffer.allocate(32768); fileWriteOutBytes.write(src); - Assert.assertEquals(src.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(src.capacity(), fileWriteOutBytes.size()); } @Test public void sizeDoesNotFlush() throws IOException @@ -129,10 +129,10 @@ public void sizeDoesNotFlush() throws IOException .andThrow(new AssertionError("file channel should not have been written to.")); EasyMock.replay(mockFileChannel); long size = fileWriteOutBytes.size(); - Assert.assertEquals(0, size); + Assertions.assertEquals(0, size); fileWriteOutBytes.writeInt(10); size = fileWriteOutBytes.size(); - Assert.assertEquals(4, size); + Assertions.assertEquals(4, size); } @Test @@ -161,12 +161,12 @@ public void testReadFullyWorks() throws IOException for (int i = 0; i < numOfInt; i++) { fileWriteOutBytes.writeInt(i); } - Assert.assertEquals(underlying.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(underlying.capacity(), fileWriteOutBytes.size()); destination.position(0); fileWriteOutBytes.readFully(100L * Integer.BYTES, destination); destination.position(0); - Assert.assertEquals(100, destination.getInt()); + Assertions.assertEquals(100, destination.getInt()); EasyMock.verify(mockFileChannel); } @@ -180,10 +180,10 @@ public void testReadFullyOutOfBoundsDoesnt() throws IOException for (int i = 0; i < numOfInt; i++) { fileWriteOutBytes.writeInt(i); } - Assert.assertEquals(fileSize, fileWriteOutBytes.size()); + Assertions.assertEquals(fileSize, fileWriteOutBytes.size()); destination.position(0); - Assert.assertThrows(IAE.class, () -> fileWriteOutBytes.readFully(33000, destination)); + Assertions.assertThrows(IAE.class, () -> fileWriteOutBytes.readFully(33000, destination)); EasyMock.verify(mockFileChannel); } @@ -196,8 +196,8 @@ public void testIOExceptionHasFileInfo() throws Exception EasyMock.replay(mockFileChannel, mockFile); fileWriteOutBytes.writeInt(10); fileWriteOutBytes.write(new byte[30]); - IOException actual = Assert.assertThrows(IOException.class, () -> fileWriteOutBytes.flush()); - Assert.assertEquals(String.valueOf(actual.getCause()), actual.getCause(), cause); - Assert.assertEquals(actual.getMessage(), actual.getMessage(), "Failed to write to file: /tmp/file. Current size of file: 34"); + IOException actual = Assertions.assertThrows(IOException.class, () -> fileWriteOutBytes.flush()); + Assertions.assertEquals(cause, actual.getCause(), String.valueOf(actual.getCause())); + Assertions.assertEquals("Failed to write to file: /tmp/file. Current size of file: 34", actual.getMessage(), actual.getMessage()); } } diff --git a/processing/src/test/java/org/apache/druid/segment/writeout/LegacyFileWriteOutBytesTest.java b/processing/src/test/java/org/apache/druid/segment/writeout/LegacyFileWriteOutBytesTest.java index 1ab2f5f785bd..de3a8fed16bf 100644 --- a/processing/src/test/java/org/apache/druid/segment/writeout/LegacyFileWriteOutBytesTest.java +++ b/processing/src/test/java/org/apache/druid/segment/writeout/LegacyFileWriteOutBytesTest.java @@ -21,9 +21,9 @@ import org.apache.druid.java.util.common.IAE; import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -36,7 +36,7 @@ public class LegacyFileWriteOutBytesTest private FileChannel mockFileChannel; private File mockFile; - @Before + @BeforeEach public void setUp() { mockFileChannel = EasyMock.mock(FileChannel.class); @@ -71,14 +71,14 @@ public void write4KiBIntsShouldNotFlush() throws IOException public void writeShouldIncrementSize() throws IOException { fileWriteOutBytes.write(1); - Assert.assertEquals(1, fileWriteOutBytes.size()); + Assertions.assertEquals(1, fileWriteOutBytes.size()); } @Test public void writeIntShouldIncrementSize() throws IOException { fileWriteOutBytes.writeInt(1); - Assert.assertEquals(4, fileWriteOutBytes.size()); + Assertions.assertEquals(4, fileWriteOutBytes.size()); } @Test @@ -94,7 +94,7 @@ public void writeBufferLargerThanCapacityShouldIncrementSizeCorrectly() throws I EasyMock.replay(mockFileChannel); ByteBuffer src = ByteBuffer.allocate(4096 + 1); fileWriteOutBytes.write(src); - Assert.assertEquals(src.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(src.capacity(), fileWriteOutBytes.size()); EasyMock.verify(mockFileChannel); } @@ -115,11 +115,11 @@ public void writeBufferLargerThanCapacityThrowsIOEInTheMiddleShouldIncrementSize ByteBuffer src = ByteBuffer.allocate(4096 * 2 + 1); try { fileWriteOutBytes.write(src); - Assert.fail("IOException should have been thrown."); + Assertions.fail("IOException should have been thrown."); } catch (IOException e) { // The second invocation to flush bytes fails. So the size should count what has already been put successfully - Assert.assertEquals(4096 * 2, fileWriteOutBytes.size()); + Assertions.assertEquals(4096 * 2, fileWriteOutBytes.size()); } } @@ -128,7 +128,7 @@ public void writeBufferSmallerThanCapacityShouldIncrementSizeCorrectly() throws { ByteBuffer src = ByteBuffer.allocate(4096); fileWriteOutBytes.write(src); - Assert.assertEquals(src.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(src.capacity(), fileWriteOutBytes.size()); } @Test public void sizeDoesNotFlush() throws IOException @@ -137,10 +137,10 @@ public void sizeDoesNotFlush() throws IOException .andThrow(new AssertionError("file channel should not have been written to.")); EasyMock.replay(mockFileChannel); long size = fileWriteOutBytes.size(); - Assert.assertEquals(0, size); + Assertions.assertEquals(0, size); fileWriteOutBytes.writeInt(10); size = fileWriteOutBytes.size(); - Assert.assertEquals(4, size); + Assertions.assertEquals(4, size); } @Test @@ -169,12 +169,12 @@ public void testReadFullyWorks() throws IOException for (int i = 0; i < numOfInt; i++) { fileWriteOutBytes.writeInt(i); } - Assert.assertEquals(underlying.capacity(), fileWriteOutBytes.size()); + Assertions.assertEquals(underlying.capacity(), fileWriteOutBytes.size()); destination.position(0); fileWriteOutBytes.readFully(100L * Integer.BYTES, destination); destination.position(0); - Assert.assertEquals(100, destination.getInt()); + Assertions.assertEquals(100, destination.getInt()); EasyMock.verify(mockFileChannel); } @@ -188,10 +188,10 @@ public void testReadFullyOutOfBoundsDoesnt() throws IOException for (int i = 0; i < numOfInt; i++) { fileWriteOutBytes.writeInt(i); } - Assert.assertEquals(fileSize, fileWriteOutBytes.size()); + Assertions.assertEquals(fileSize, fileWriteOutBytes.size()); destination.position(0); - Assert.assertThrows(IAE.class, () -> fileWriteOutBytes.readFully(5000, destination)); + Assertions.assertThrows(IAE.class, () -> fileWriteOutBytes.readFully(5000, destination)); EasyMock.verify(mockFileChannel); } @@ -204,8 +204,8 @@ public void testIOExceptionHasFileInfo() throws Exception EasyMock.replay(mockFileChannel, mockFile); fileWriteOutBytes.writeInt(10); fileWriteOutBytes.write(new byte[30]); - IOException actual = Assert.assertThrows(IOException.class, () -> fileWriteOutBytes.flush()); - Assert.assertEquals(String.valueOf(actual.getCause()), actual.getCause(), cause); - Assert.assertEquals(actual.getMessage(), actual.getMessage(), "Failed to write to file: /tmp/file. Current size of file: 34"); + IOException actual = Assertions.assertThrows(IOException.class, () -> fileWriteOutBytes.flush()); + Assertions.assertEquals(cause, actual.getCause(), String.valueOf(actual.getCause())); + Assertions.assertEquals("Failed to write to file: /tmp/file. Current size of file: 34", actual.getMessage(), actual.getMessage()); } } diff --git a/processing/src/test/java/org/apache/druid/storage/local/LocalFileStorageConnectorTest.java b/processing/src/test/java/org/apache/druid/storage/local/LocalFileStorageConnectorTest.java index d6eec86723b4..627a66871e29 100644 --- a/processing/src/test/java/org/apache/druid/storage/local/LocalFileStorageConnectorTest.java +++ b/processing/src/test/java/org/apache/druid/storage/local/LocalFileStorageConnectorTest.java @@ -26,12 +26,10 @@ import org.apache.druid.java.util.common.IAE; import org.apache.druid.storage.StorageConnector; import org.apache.druid.storage.StorageConnectorProvider; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.io.IOException; @@ -44,18 +42,16 @@ public class LocalFileStorageConnectorTest { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir + public File temporaryFolder; - @Rule - public ExpectedException expectedException = ExpectedException.none(); private File storageDir; private StorageConnector storageConnector; - @Before + @BeforeEach public void init() throws IOException { - storageDir = temporaryFolder.newFolder(); + storageDir = temporaryFolder; storageConnector = new LocalFileStorageConnectorProvider(storageDir).createStorageConnector(null); } @@ -68,15 +64,15 @@ public void sanityCheck() throws IOException createAndPopulateFile(uuid); // check if file is created - Assert.assertTrue(storageConnector.pathExists(uuid)); - Assert.assertTrue(new File(storageDir.getAbsolutePath(), uuid).exists()); + Assertions.assertTrue(storageConnector.pathExists(uuid)); + Assertions.assertTrue(new File(storageDir.getAbsolutePath(), uuid).exists()); // check contents checkContents(uuid); // delete file storageConnector.deleteFile(uuid); - Assert.assertFalse(new File(storageDir.getAbsolutePath(), uuid).exists()); + Assertions.assertFalse(new File(storageDir.getAbsolutePath(), uuid).exists()); } @Test @@ -90,20 +86,20 @@ public void deleteRecursivelyTest() throws IOException createAndPopulateFile(uuid1); createAndPopulateFile(uuid2); - Assert.assertTrue(storageConnector.pathExists(uuid1)); - Assert.assertTrue(storageConnector.pathExists(uuid2)); + Assertions.assertTrue(storageConnector.pathExists(uuid1)); + Assertions.assertTrue(storageConnector.pathExists(uuid2)); checkContents(uuid1); checkContents(uuid2); File baseFile = new File(storageDir.getAbsolutePath(), uuid_base); - Assert.assertTrue(baseFile.exists()); - Assert.assertTrue(baseFile.isDirectory()); - Assert.assertEquals(2, baseFile.listFiles().length); + Assertions.assertTrue(baseFile.exists()); + Assertions.assertTrue(baseFile.isDirectory()); + Assertions.assertEquals(2, baseFile.listFiles().length); storageConnector.deleteRecursively(uuid_base); - Assert.assertFalse(baseFile.exists()); - Assert.assertTrue(new File(storageDir.getAbsolutePath(), topLevelDir).exists()); + Assertions.assertFalse(baseFile.exists()); + Assertions.assertTrue(new File(storageDir.getAbsolutePath(), topLevelDir).exists()); } @Test @@ -118,17 +114,16 @@ public void batchDelete() throws IOException // delete file storageConnector.deleteFiles(ImmutableList.of(uuid1, uuid2)); - Assert.assertFalse(new File(storageDir.getAbsolutePath(), uuid1).exists()); - Assert.assertFalse(new File(storageDir.getAbsolutePath(), uuid2).exists()); + Assertions.assertFalse(new File(storageDir.getAbsolutePath(), uuid1).exists()); + Assertions.assertFalse(new File(storageDir.getAbsolutePath(), uuid2).exists()); } @Test public void incorrectBasePath() throws IOException { - File file = temporaryFolder.newFile(); - expectedException.expect(IAE.class); + File file = File.createTempFile("test", ".tmp", temporaryFolder); StorageConnectorProvider storageConnectorProvider = new LocalFileStorageConnectorProvider(file); - storageConnectorProvider.createStorageConnector(null); + Assertions.assertThrows(IAE.class, () -> storageConnectorProvider.createStorageConnector(null)); } @Test @@ -144,21 +139,21 @@ public void listFilesTest() throws Exception List topLevelDirContents = Lists.newArrayList(storageConnector.listDir(topLevelDir)); List expectedTopLevelDirContents = ImmutableList.of(new File(uuid_base).getName()); - Assert.assertEquals(expectedTopLevelDirContents, topLevelDirContents); + Assertions.assertEquals(expectedTopLevelDirContents, topLevelDirContents); // Converted to a set since the output of the listDir can be shuffled Set nextLevelDirContents = Sets.newHashSet(storageConnector.listDir(uuid_base)); Set expectedNextLevelDirContents = ImmutableSet.of(new File(uuid1).getName(), new File(uuid2).getName()); - Assert.assertEquals(expectedNextLevelDirContents, nextLevelDirContents); + Assertions.assertEquals(expectedNextLevelDirContents, nextLevelDirContents); // Check if listDir throws if an unknown path is passed as an argument - Assert.assertThrows( + Assertions.assertThrows( IAE.class, () -> storageConnector.listDir("unknown_top_path") ); // Check if listDir throws if a file path is passed as an argument - Assert.assertThrows( + Assertions.assertThrows( IAE.class, () -> storageConnector.listDir(uuid1) ); @@ -178,24 +173,24 @@ public void testReadRange() throws Exception for (int length = 1; length <= data.length() - start; length++) { InputStream is = storageConnector.readRange(uuid, start, length); byte[] dataBytes = new byte[length]; - Assert.assertEquals(is.read(dataBytes), length); - Assert.assertEquals(is.read(), -1); // reading further produces no data - Assert.assertEquals(data.substring(start, start + length), new String(dataBytes, StandardCharsets.UTF_8)); + Assertions.assertEquals(is.read(dataBytes), length); + Assertions.assertEquals(is.read(), -1); // reading further produces no data + Assertions.assertEquals(data.substring(start, start + length), new String(dataBytes, StandardCharsets.UTF_8)); } } // empty read InputStream is = storageConnector.readRange(uuid, 0, 0); byte[] dataBytes = new byte[0]; - Assert.assertEquals(is.read(dataBytes), -1); - Assert.assertEquals(data.substring(0, 0), new String(dataBytes, StandardCharsets.UTF_8)); + Assertions.assertEquals(is.read(dataBytes), -1); + Assertions.assertEquals(data.substring(0, 0), new String(dataBytes, StandardCharsets.UTF_8)); } private void checkContents(String uuid) throws IOException { try (InputStream inputStream = storageConnector.read(uuid)) { - Assert.assertEquals(1, inputStream.read()); - Assert.assertEquals(0, inputStream.available()); + Assertions.assertEquals(1, inputStream.read()); + Assertions.assertEquals(0, inputStream.available()); } } diff --git a/processing/src/test/java/org/apache/druid/tasklogs/SwitchingTaskLogsTest.java b/processing/src/test/java/org/apache/druid/tasklogs/SwitchingTaskLogsTest.java index 3d0ccbfa74e1..a3d8f7dcf824 100644 --- a/processing/src/test/java/org/apache/druid/tasklogs/SwitchingTaskLogsTest.java +++ b/processing/src/test/java/org/apache/druid/tasklogs/SwitchingTaskLogsTest.java @@ -21,13 +21,13 @@ import com.google.common.base.Optional; import org.easymock.EasyMock; -import org.easymock.EasyMockRunner; +import org.easymock.EasyMockExtension; import org.easymock.EasyMockSupport; import org.easymock.Mock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.io.ByteArrayInputStream; import java.io.File; @@ -35,7 +35,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; -@RunWith(EasyMockRunner.class) +@ExtendWith(EasyMockExtension.class) public class SwitchingTaskLogsTest extends EasyMockSupport { @Mock @@ -52,7 +52,7 @@ public class SwitchingTaskLogsTest extends EasyMockSupport private SwitchingTaskLogs taskLogs; - @Before + @BeforeEach public void setUp() { taskLogs = new SwitchingTaskLogs(defaultTaskLogs, reportTaskLogs, streamerTaskLogs, pusherTaskLogs); @@ -69,8 +69,8 @@ public void test_streamTaskLog_usesStreamerTaskLogs() throws IOException replayAll(); Optional actualLogStream = taskLogs.streamTaskLog(taskId, offset); - Assert.assertTrue(actualLogStream.isPresent()); - Assert.assertEquals(logStream, actualLogStream.get()); + Assertions.assertTrue(actualLogStream.isPresent()); + Assertions.assertEquals(logStream, actualLogStream.get()); verifyAll(); } @@ -85,8 +85,8 @@ public void test_streamTaskReports_usesReportTaskLogs() throws IOException replayAll(); Optional actualReportStream = taskLogs.streamTaskReports(taskId); - Assert.assertTrue(actualReportStream.isPresent()); - Assert.assertEquals(reportStream, actualReportStream.get()); + Assertions.assertTrue(actualReportStream.isPresent()); + Assertions.assertEquals(reportStream, actualReportStream.get()); verifyAll(); } @@ -101,8 +101,8 @@ public void test_streamTaskStatus_usesReportTaskLogs() throws IOException replayAll(); Optional actualStatusStream = taskLogs.streamTaskStatus(taskId); - Assert.assertTrue(actualStatusStream.isPresent()); - Assert.assertEquals(statusStream, actualStatusStream.get()); + Assertions.assertTrue(actualStatusStream.isPresent()); + Assertions.assertEquals(statusStream, actualStatusStream.get()); verifyAll(); } @@ -117,8 +117,8 @@ public void test_streamTaskPayload_usesReportTaskLogs() throws IOException replayAll(); Optional actualPayloadStream = taskLogs.streamTaskPayload(taskId); - Assert.assertTrue(actualPayloadStream.isPresent()); - Assert.assertEquals(payloadStream, actualPayloadStream.get()); + Assertions.assertTrue(actualPayloadStream.isPresent()); + Assertions.assertEquals(payloadStream, actualPayloadStream.get()); verifyAll(); } diff --git a/processing/src/test/java/org/apache/druid/timeline/partition/DimensionRangeBucketShardSpecTest.java b/processing/src/test/java/org/apache/druid/timeline/partition/DimensionRangeBucketShardSpecTest.java index 7eb607ecffb8..004e389e1c01 100644 --- a/processing/src/test/java/org/apache/druid/timeline/partition/DimensionRangeBucketShardSpecTest.java +++ b/processing/src/test/java/org/apache/druid/timeline/partition/DimensionRangeBucketShardSpecTest.java @@ -29,10 +29,8 @@ import org.apache.druid.data.input.MapBasedInputRow; import org.apache.druid.data.input.StringTuple; import org.apache.druid.java.util.common.DateTimes; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; @@ -43,13 +41,10 @@ public class DimensionRangeBucketShardSpecTest private static final List DIMENSIONS = Arrays.asList("dim1", "dim2"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testConvert() { - Assert.assertEquals( + Assertions.assertEquals( new BuildingDimensionRangeShardSpec( 1, DIMENSIONS, @@ -69,7 +64,7 @@ public void testConvert() @Test public void testConvert_withSingleDimension() { - Assert.assertEquals( + Assertions.assertEquals( new BuildingSingleDimensionShardSpec(1, "dim", "start", "end", 5), new DimensionRangeBucketShardSpec( 1, @@ -83,7 +78,7 @@ public void testConvert_withSingleDimension() @Test public void testCreateChunk() { - Assert.assertEquals( + Assertions.assertEquals( new NumberedPartitionChunk<>(1, 0, "test"), new DimensionRangeBucketShardSpec( 1, @@ -109,7 +104,7 @@ public void testShardSpecLookup() ); final ShardSpecLookup lookup = shardSpecs.get(0).getLookup(shardSpecs); final long currentTime = DateTimes.nowUtc().getMillis(); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(0), lookup.getShardSpec( currentTime, @@ -120,7 +115,7 @@ public void testShardSpecLookup() ) ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(1), lookup.getShardSpec( currentTime, @@ -130,7 +125,7 @@ public void testShardSpecLookup() ) ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(2), lookup.getShardSpec( currentTime, @@ -159,40 +154,37 @@ public void testSerde() throws JsonProcessingException ); final String json = mapper.writeValueAsString(original); ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class); - Assert.assertEquals(ShardSpec.Type.BUCKET_RANGE, shardSpec.getType()); - Assert.assertEquals(original, shardSpec); + Assertions.assertEquals(ShardSpec.Type.BUCKET_RANGE, shardSpec.getType()); + Assertions.assertEquals(original, shardSpec); } @Test public void testInvalidStartTupleSize() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage( - "Start tuple must either be null or of the same size as the number of partition dimensions" - ); - - new DimensionRangeBucketShardSpec( - 1, - DIMENSIONS, - StringTuple.create("a"), - null + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new DimensionRangeBucketShardSpec(1, DIMENSIONS, StringTuple.create("a"), null) ); + Assertions.assertTrue(e.getMessage().contains( + "Start tuple must either be null or of the same size as the number of partition dimensions" + )); } @Test public void testInvalidEndTupleSize() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage( - "End tuple must either be null or of the same size as the number of partition dimensions" - ); - - new DimensionRangeBucketShardSpec( - 1, - DIMENSIONS, - StringTuple.create("a", "b"), - StringTuple.create("e", "f", "g") + IllegalArgumentException e = Assertions.assertThrows( + IllegalArgumentException.class, + () -> new DimensionRangeBucketShardSpec( + 1, + DIMENSIONS, + StringTuple.create("a", "b"), + StringTuple.create("e", "f", "g") + ) ); + Assertions.assertTrue(e.getMessage().contains( + "End tuple must either be null or of the same size as the number of partition dimensions" + )); } @Test diff --git a/processing/src/test/java/org/apache/druid/timeline/partition/SingleDimensionShardSpecTest.java b/processing/src/test/java/org/apache/druid/timeline/partition/SingleDimensionShardSpecTest.java index 55235d62fbec..87c235e4a4db 100644 --- a/processing/src/test/java/org/apache/druid/timeline/partition/SingleDimensionShardSpecTest.java +++ b/processing/src/test/java/org/apache/druid/timeline/partition/SingleDimensionShardSpecTest.java @@ -28,8 +28,8 @@ import com.google.common.collect.RangeSet; import org.apache.druid.data.input.MapBasedInputRow; import org.apache.druid.java.util.common.DateTimes; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Arrays; @@ -57,30 +57,30 @@ public void testPossibleInDomain() ShardSpec shard5 = makeSpec("dim2", "hello", "jk"); ShardSpec shard6 = makeSpec("dim2", "jk", "na"); ShardSpec shard7 = makeSpec("dim2", "na", null); - Assert.assertTrue(shard1.possibleInDomain(domain1)); - Assert.assertFalse(shard2.possibleInDomain(domain1)); - Assert.assertFalse(shard3.possibleInDomain(domain1)); - Assert.assertTrue(shard4.possibleInDomain(domain1)); - Assert.assertTrue(shard5.possibleInDomain(domain1)); - Assert.assertTrue(shard6.possibleInDomain(domain1)); - Assert.assertTrue(shard7.possibleInDomain(domain1)); - Assert.assertFalse(shard1.possibleInDomain(domain2)); - Assert.assertFalse(shard2.possibleInDomain(domain2)); - Assert.assertTrue(shard3.possibleInDomain(domain2)); - Assert.assertFalse(shard4.possibleInDomain(domain2)); - Assert.assertFalse(shard5.possibleInDomain(domain2)); - Assert.assertTrue(shard6.possibleInDomain(domain2)); - Assert.assertTrue(shard7.possibleInDomain(domain2)); + Assertions.assertTrue(shard1.possibleInDomain(domain1)); + Assertions.assertFalse(shard2.possibleInDomain(domain1)); + Assertions.assertFalse(shard3.possibleInDomain(domain1)); + Assertions.assertTrue(shard4.possibleInDomain(domain1)); + Assertions.assertTrue(shard5.possibleInDomain(domain1)); + Assertions.assertTrue(shard6.possibleInDomain(domain1)); + Assertions.assertTrue(shard7.possibleInDomain(domain1)); + Assertions.assertFalse(shard1.possibleInDomain(domain2)); + Assertions.assertFalse(shard2.possibleInDomain(domain2)); + Assertions.assertTrue(shard3.possibleInDomain(domain2)); + Assertions.assertFalse(shard4.possibleInDomain(domain2)); + Assertions.assertFalse(shard5.possibleInDomain(domain2)); + Assertions.assertTrue(shard6.possibleInDomain(domain2)); + Assertions.assertTrue(shard7.possibleInDomain(domain2)); } @Test public void testSharePartitionSpace() { final SingleDimensionShardSpec shardSpec = makeSpec("start", "end"); - Assert.assertTrue(shardSpec.sharePartitionSpace(NumberedPartialShardSpec.instance())); - Assert.assertTrue(shardSpec.sharePartitionSpace(new HashBasedNumberedPartialShardSpec(null, 0, 1, null))); - Assert.assertTrue(shardSpec.sharePartitionSpace(new SingleDimensionPartialShardSpec("dim", 0, null, null, 1))); - Assert.assertFalse(shardSpec.sharePartitionSpace(new NumberedOverwritePartialShardSpec(0, 2, 1))); + Assertions.assertTrue(shardSpec.sharePartitionSpace(NumberedPartialShardSpec.instance())); + Assertions.assertTrue(shardSpec.sharePartitionSpace(new HashBasedNumberedPartialShardSpec(null, 0, 1, null))); + Assertions.assertTrue(shardSpec.sharePartitionSpace(new SingleDimensionPartialShardSpec("dim", 0, null, null, 1))); + Assertions.assertFalse(shardSpec.sharePartitionSpace(new NumberedOverwritePartialShardSpec(0, 2, 1))); } @Test @@ -102,11 +102,11 @@ public void testDeserialize() throws JsonProcessingException + "\"partitionNum\": 5," + "\"numCorePartitions\": 10}"; ShardSpec shardSpec = OBJECT_MAPPER.readValue(json, ShardSpec.class); - Assert.assertTrue(shardSpec instanceof SingleDimensionShardSpec); - Assert.assertEquals(ShardSpec.Type.SINGLE, shardSpec.getType()); + Assertions.assertInstanceOf(SingleDimensionShardSpec.class, shardSpec); + Assertions.assertEquals(ShardSpec.Type.SINGLE, shardSpec.getType()); SingleDimensionShardSpec singleDimShardSpec = (SingleDimensionShardSpec) shardSpec; - Assert.assertEquals( + Assertions.assertEquals( new SingleDimensionShardSpec("dim", "abc", "xyz", 5, 10), singleDimShardSpec ); @@ -122,7 +122,7 @@ public void testShardSpecLookup() ); final ShardSpecLookup lookup = shardSpecs.get(0).getLookup(shardSpecs); final long currentTime = DateTimes.nowUtc().getMillis(); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(0), lookup.getShardSpec( currentTime, @@ -134,7 +134,7 @@ public void testShardSpecLookup() ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(0), lookup.getShardSpec( currentTime, @@ -146,7 +146,7 @@ public void testShardSpecLookup() ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(0), lookup.getShardSpec( currentTime, @@ -158,7 +158,7 @@ public void testShardSpecLookup() ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(1), lookup.getShardSpec( currentTime, @@ -170,7 +170,7 @@ public void testShardSpecLookup() ) ); - Assert.assertEquals( + Assertions.assertEquals( shardSpecs.get(2), lookup.getShardSpec( currentTime, @@ -187,7 +187,7 @@ private void testSerde(SingleDimensionShardSpec shardSpec) throws IOException { String json = OBJECT_MAPPER.writeValueAsString(shardSpec); SingleDimensionShardSpec deserializedSpec = OBJECT_MAPPER.readValue(json, SingleDimensionShardSpec.class); - Assert.assertEquals(shardSpec, deserializedSpec); + Assertions.assertEquals(shardSpec, deserializedSpec); } private static RangeSet rangeSet(List> ranges) diff --git a/processing/src/test/java/org/apache/druid/timeline/partition/StringPartitionChunkTest.java b/processing/src/test/java/org/apache/druid/timeline/partition/StringPartitionChunkTest.java index 63a8c270a17b..9b6d4bc08c78 100644 --- a/processing/src/test/java/org/apache/druid/timeline/partition/StringPartitionChunkTest.java +++ b/processing/src/test/java/org/apache/druid/timeline/partition/StringPartitionChunkTest.java @@ -20,8 +20,8 @@ package org.apache.druid.timeline.partition; import org.apache.druid.data.input.StringTuple; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class StringPartitionChunkTest @@ -32,28 +32,28 @@ public void testAbuts() // Test with multiple dimensions StringPartitionChunk lhs = StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1); - Assert.assertTrue(lhs.abuts(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 1, 2))); - Assert.assertFalse(lhs.abuts(StringPartitionChunk.make(StringTuple.create("10", "xyz"), null, 2, 3))); - Assert.assertFalse(lhs.abuts(StringPartitionChunk.make(StringTuple.create("11", "abc"), null, 2, 3))); - Assert.assertFalse(lhs.abuts(StringPartitionChunk.make(null, null, 3, 4))); + Assertions.assertTrue(lhs.abuts(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 1, 2))); + Assertions.assertFalse(lhs.abuts(StringPartitionChunk.make(StringTuple.create("10", "xyz"), null, 2, 3))); + Assertions.assertFalse(lhs.abuts(StringPartitionChunk.make(StringTuple.create("11", "abc"), null, 2, 3))); + Assertions.assertFalse(lhs.abuts(StringPartitionChunk.make(null, null, 3, 4))); // Test with single dimension lhs = StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1); - Assert.assertTrue(lhs.abuts(StringPartitionChunk.makeForSingleDimension("10", null, 1, 2))); - Assert.assertFalse(lhs.abuts(StringPartitionChunk.makeForSingleDimension("11", null, 2, 3))); - Assert.assertFalse(lhs.abuts(StringPartitionChunk.makeForSingleDimension(null, null, 3, 4))); + Assertions.assertTrue(lhs.abuts(StringPartitionChunk.makeForSingleDimension("10", null, 1, 2))); + Assertions.assertFalse(lhs.abuts(StringPartitionChunk.makeForSingleDimension("11", null, 2, 3))); + Assertions.assertFalse(lhs.abuts(StringPartitionChunk.makeForSingleDimension(null, null, 3, 4))); - Assert.assertFalse(StringPartitionChunk.make(null, null, 0, 1).abuts(StringPartitionChunk.make(null, null, 1, 2))); + Assertions.assertFalse(StringPartitionChunk.make(null, null, 0, 1).abuts(StringPartitionChunk.make(null, null, 1, 2))); } @Test public void testIsStart() { // Test with multiple dimensions - Assert.assertTrue(StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1).isStart()); - Assert.assertFalse(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 1).isStart()); - Assert.assertFalse( + Assertions.assertTrue(StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1).isStart()); + Assertions.assertFalse(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 1).isStart()); + Assertions.assertFalse( StringPartitionChunk.make( StringTuple.create("10", "abc"), StringTuple.create("11", "def"), @@ -63,19 +63,19 @@ public void testIsStart() ); // Test with a single dimension - Assert.assertTrue(StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1).isStart()); - Assert.assertFalse(StringPartitionChunk.makeForSingleDimension("10", null, 0, 1).isStart()); - Assert.assertFalse(StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1).isStart()); - Assert.assertTrue(StringPartitionChunk.makeForSingleDimension(null, null, 0, 1).isStart()); + Assertions.assertTrue(StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1).isStart()); + Assertions.assertFalse(StringPartitionChunk.makeForSingleDimension("10", null, 0, 1).isStart()); + Assertions.assertFalse(StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1).isStart()); + Assertions.assertTrue(StringPartitionChunk.makeForSingleDimension(null, null, 0, 1).isStart()); } @Test public void testIsEnd() { // Test with multiple dimensions - Assert.assertFalse(StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1).isEnd()); - Assert.assertTrue(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 1).isEnd()); - Assert.assertFalse( + Assertions.assertFalse(StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1).isEnd()); + Assertions.assertTrue(StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 1).isEnd()); + Assertions.assertFalse( StringPartitionChunk.make( StringTuple.create("10", "abc"), StringTuple.create("11", "def"), @@ -85,53 +85,53 @@ public void testIsEnd() ); // Test with a single dimension - Assert.assertFalse(StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1).isEnd()); - Assert.assertTrue(StringPartitionChunk.makeForSingleDimension("10", null, 0, 1).isEnd()); - Assert.assertFalse(StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1).isEnd()); - Assert.assertTrue(StringPartitionChunk.makeForSingleDimension(null, null, 0, 1).isEnd()); + Assertions.assertFalse(StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1).isEnd()); + Assertions.assertTrue(StringPartitionChunk.makeForSingleDimension("10", null, 0, 1).isEnd()); + Assertions.assertFalse(StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1).isEnd()); + Assertions.assertTrue(StringPartitionChunk.makeForSingleDimension(null, null, 0, 1).isEnd()); } @Test public void testCompareTo() { // Test with multiple dimensions - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.make(null, null, 0, 1).compareTo( StringPartitionChunk.make(null, null, 0, 2) ) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 1).compareTo( StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 0, 2) ) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 1, 1).compareTo( StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 1, 2) ) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.make(StringTuple.create("10", "abc"), StringTuple.create("11", "aa"), 1, 1).compareTo( StringPartitionChunk.make(StringTuple.create("10", "abc"), StringTuple.create("11", "aa"), 1, 2) ) ); - Assert.assertEquals( + Assertions.assertEquals( -1, StringPartitionChunk.make(null, StringTuple.create("10", "abc"), 0, 1).compareTo( StringPartitionChunk.make(StringTuple.create("10", "abc"), null, 1, 2) ) ); - Assert.assertEquals( + Assertions.assertEquals( -1, StringPartitionChunk.make(StringTuple.create("11", "b"), StringTuple.create("20", "a"), 0, 1).compareTo( StringPartitionChunk.make(StringTuple.create("20", "a"), StringTuple.create("33", "z"), 1, 1) ) ); - Assert.assertEquals( + Assertions.assertEquals( 1, StringPartitionChunk.make(StringTuple.create("20", "a"), StringTuple.create("33", "z"), 1, 1).compareTo( StringPartitionChunk.make(StringTuple.create("11", "b"), StringTuple.create("20", "a"), 0, 1) @@ -139,42 +139,42 @@ public void testCompareTo() ); // Test with a single dimension - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.makeForSingleDimension(null, null, 0, 1) .compareTo(StringPartitionChunk.makeForSingleDimension(null, null, 0, 2)) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.makeForSingleDimension("10", null, 0, 1) .compareTo(StringPartitionChunk.makeForSingleDimension("10", null, 0, 2)) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.makeForSingleDimension(null, "10", 1, 1) .compareTo(StringPartitionChunk.makeForSingleDimension(null, "10", 1, 2)) ); - Assert.assertEquals( + Assertions.assertEquals( 0, StringPartitionChunk.makeForSingleDimension("10", "11", 1, 1) .compareTo(StringPartitionChunk.makeForSingleDimension("10", "11", 1, 2)) ); - Assert.assertEquals( + Assertions.assertEquals( -1, StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1) .compareTo(StringPartitionChunk.makeForSingleDimension("10", null, 1, 2)) ); - Assert.assertEquals( + Assertions.assertEquals( -1, StringPartitionChunk.makeForSingleDimension("11", "20", 0, 1) .compareTo(StringPartitionChunk.makeForSingleDimension("20", "33", 1, 1)) ); - Assert.assertEquals( + Assertions.assertEquals( 1, StringPartitionChunk.makeForSingleDimension("20", "33", 1, 1) .compareTo(StringPartitionChunk.makeForSingleDimension("11", "20", 0, 1)) ); - Assert.assertEquals( + Assertions.assertEquals( 1, StringPartitionChunk.makeForSingleDimension("10", null, 1, 1) .compareTo(StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1)) @@ -184,19 +184,19 @@ public void testCompareTo() @Test public void testEquals() { - Assert.assertEquals( + Assertions.assertEquals( StringPartitionChunk.makeForSingleDimension(null, null, 0, 1), StringPartitionChunk.makeForSingleDimension(null, null, 0, 1) ); - Assert.assertEquals( + Assertions.assertEquals( StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1), StringPartitionChunk.makeForSingleDimension(null, "10", 0, 1) ); - Assert.assertEquals( + Assertions.assertEquals( StringPartitionChunk.makeForSingleDimension("10", null, 0, 1), StringPartitionChunk.makeForSingleDimension("10", null, 0, 1) ); - Assert.assertEquals( + Assertions.assertEquals( StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1), StringPartitionChunk.makeForSingleDimension("10", "11", 0, 1) ); @@ -207,8 +207,8 @@ public void testMakeForSingleDimension() { StringPartitionChunk chunk = StringPartitionChunk .makeForSingleDimension("a", null, 0, 1); - Assert.assertEquals(0, chunk.getChunkNumber()); - Assert.assertTrue(chunk.isEnd()); - Assert.assertFalse(chunk.isStart()); + Assertions.assertEquals(0, chunk.getChunkNumber()); + Assertions.assertTrue(chunk.isEnd()); + Assertions.assertFalse(chunk.isStart()); } }