Skip to content

Commit 5836f30

Browse files
committed
junit5
1 parent 97e46c3 commit 5836f30

File tree

3 files changed

+40
-44
lines changed

3 files changed

+40
-44
lines changed

processing/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
<artifactId>junit-jupiter-params</artifactId>
455455
<scope>test</scope>
456456
</dependency>
457+
<dependency>
458+
<groupId>org.junit.jupiter</groupId>
459+
<artifactId>junit-jupiter-migrationsupport</artifactId>
460+
<scope>test</scope>
461+
</dependency>
457462
</dependencies>
458463

459464
<build>

processing/src/test/java/org/apache/druid/query/scan/NestedDataScanQueryTest.java

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
import com.fasterxml.jackson.databind.Module;
2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableMap;
25-
import junitparams.JUnitParamsRunner;
26-
import junitparams.Parameters;
27-
import junitparams.naming.TestCaseName;
2825
import org.apache.druid.data.input.impl.DimensionSchema;
2926
import org.apache.druid.data.input.impl.DimensionsSpec;
3027
import org.apache.druid.data.input.impl.LongDimensionSchema;
@@ -57,33 +54,36 @@
5754
import org.apache.druid.segment.nested.StructuredData;
5855
import org.apache.druid.segment.virtual.NestedFieldVirtualColumn;
5956
import org.apache.druid.testing.InitializedNullHandlingTest;
60-
import org.junit.After;
6157
import org.junit.Assert;
62-
import org.junit.Assume;
6358
import org.junit.Rule;
64-
import org.junit.Test;
59+
import org.junit.jupiter.api.AfterEach;
60+
import org.junit.jupiter.api.Assumptions;
61+
import org.junit.jupiter.api.Test;
62+
import org.junit.jupiter.migrationsupport.EnableJUnit4MigrationSupport;
63+
import org.junit.jupiter.params.ParameterizedTest;
64+
import org.junit.jupiter.params.provider.MethodSource;
65+
import org.junit.jupiter.params.provider.ValueSource;
6566
import org.junit.rules.TemporaryFolder;
66-
import org.junit.runner.RunWith;
6767

6868
import java.io.IOException;
6969
import java.util.ArrayList;
7070
import java.util.List;
7171
import java.util.stream.Collectors;
7272
import java.util.stream.Stream;
7373

74-
@RunWith(JUnitParamsRunner.class)
74+
@EnableJUnit4MigrationSupport
7575
public class NestedDataScanQueryTest extends InitializedNullHandlingTest
7676
{
7777
private static final Logger LOG = new Logger(NestedDataScanQueryTest.class);
7878

7979
DefaultColumnFormatConfig DEFAULT_FORMAT = new DefaultColumnFormatConfig(null, null, null);
8080

81-
private final AggregationTestHelper helper;
82-
private final Closer closer;
83-
8481
@Rule
8582
public final TemporaryFolder tempFolder = new TemporaryFolder();
8683

84+
private final AggregationTestHelper helper;
85+
private final Closer closer;
86+
8787
public static Object[] getNestedColumnFormatSpec()
8888
{
8989
List<Object> specs = new ArrayList<>();
@@ -113,7 +113,7 @@ public static Object[] getNestedColumnFormatSpec()
113113
return specs.toArray();
114114
}
115115

116-
@After
116+
@AfterEach
117117
public void teardown() throws IOException
118118
{
119119
closer.close();
@@ -147,9 +147,8 @@ public void testIngestAndScanSegmentsSimple() throws Exception
147147
logResults(results);
148148
}
149149

150-
@Test
151-
@Parameters(method = "getNestedColumnFormatSpec")
152-
@TestCaseName("{0}")
150+
@ParameterizedTest(name = "{0}")
151+
@MethodSource("getNestedColumnFormatSpec")
153152
public void testIngestAndScanSegmentsWithSpec(String name, boolean auto, NestedCommonFormatColumnFormatSpec spec)
154153
throws Exception
155154
{
@@ -180,9 +179,8 @@ public void testIngestAndScanSegmentsWithSpec(String name, boolean auto, NestedC
180179
logResults(results);
181180
}
182181

183-
@Test
184-
@Parameters(method = "getNestedColumnFormatSpec")
185-
@TestCaseName("{0}")
182+
@ParameterizedTest(name = "{0}")
183+
@MethodSource("getNestedColumnFormatSpec")
186184
public void testIngestAndScanSegmentsNumericWithSpec(
187185
String name,
188186
boolean auto,
@@ -233,9 +231,9 @@ public void testIngestAndScanSegmentsNumericWithSpec(
233231
}
234232
}
235233

236-
@Test
237-
@Parameters({"true", "false"})
238-
public void testIngestAndScanSegmentsNumericRollup(boolean rollup) throws Exception
234+
@ParameterizedTest
235+
@ValueSource(booleans = {true, false})
236+
public void testIngestAndScanSegmentsNumericRollup(Boolean rollup) throws Exception
239237
{
240238
Query<ScanResultValue> scanQuery = queryBuilder()
241239
.virtualColumns(new NestedFieldVirtualColumn("nest", "$.long", "long"))
@@ -326,9 +324,8 @@ public void testIngestAndScanSegmentsRealtimeWithFallback() throws Exception
326324
Assert.assertEquals(resultsRealtime.get(0).getEvents().toString(), resultsSegments.get(0).getEvents().toString());
327325
}
328326

329-
@Test
330-
@Parameters(method = "getNestedColumnFormatSpec")
331-
@TestCaseName("{0}")
327+
@ParameterizedTest(name = "{0}")
328+
@MethodSource("getNestedColumnFormatSpec")
332329
public void testIngestAndScanSegmentsTsv(String name, boolean auto, NestedCommonFormatColumnFormatSpec spec)
333330
throws Exception
334331
{
@@ -403,9 +400,8 @@ public void testIngestWithMoreMergesAndScanSegmentsRollup() throws Exception
403400
logResults(results);
404401
}
405402

406-
@Test
407-
@Parameters(method = "getNestedColumnFormatSpec")
408-
@TestCaseName("{0}")
403+
@ParameterizedTest(name = "{0}")
404+
@MethodSource("getNestedColumnFormatSpec")
409405
public void testIngestAndScanSegmentsAndFilter(String name, boolean auto, NestedCommonFormatColumnFormatSpec spec)
410406
throws Exception
411407
{
@@ -432,9 +428,8 @@ public void testIngestAndScanSegmentsAndFilter(String name, boolean auto, Nested
432428
Assert.assertEquals(1, ((List) results.get(0).getEvents()).size());
433429
}
434430

435-
@Test
436-
@Parameters(method = "getNestedColumnFormatSpec")
437-
@TestCaseName("{0}")
431+
@ParameterizedTest(name = "{0}")
432+
@MethodSource("getNestedColumnFormatSpec")
438433
public void testIngestAndScanSegmentsAndRangeFilter(
439434
String name,
440435
boolean auto,
@@ -488,17 +483,16 @@ public void testIngestAndScanSegmentsRealtimeSchemaDiscovery() throws Exception
488483
Assert.assertEquals(resultsRealtime.get(0).getEvents().toString(), resultsSegments.get(0).getEvents().toString());
489484
}
490485

491-
@Test
492-
@Parameters(method = "getNestedColumnFormatSpec")
493-
@TestCaseName("{0}")
486+
@ParameterizedTest(name = "{0}")
487+
@MethodSource("getNestedColumnFormatSpec")
494488
public void testIngestAndScanSegmentsRealtimeAutoExplicit(
495489
String name,
496490
boolean auto,
497491
NestedCommonFormatColumnFormatSpec spec
498492
) throws Exception
499493
{
500494
// Test with different column format spec
501-
Assume.assumeTrue(auto);
495+
Assumptions.assumeTrue(auto);
502496
DimensionsSpec dimensionsSpec = DimensionsSpec.builder()
503497
.setDimensions(
504498
List.of(
@@ -612,9 +606,8 @@ public void testIngestAndScanSegmentsRealtimeSchemaDiscoveryTypeGauntlet() throw
612606
Assert.assertEquals(resultsRealtime.get(0).getEvents().toString(), resultsSegments.get(0).getEvents().toString());
613607
}
614608

615-
@Test
616-
@Parameters(method = "getNestedColumnFormatSpec")
617-
@TestCaseName("{0}")
609+
@ParameterizedTest(name = "{0}")
610+
@MethodSource("getNestedColumnFormatSpec")
618611
public void testIngestAndScanSegmentsAndFilterPartialPathArrayIndex(
619612
String name,
620613
boolean auto,
@@ -658,9 +651,8 @@ public void testIngestAndScanSegmentsAndFilterPartialPathArrayIndex(
658651
Assert.assertEquals(results.get(0).getEvents().toString(), resultsRealtime.get(0).getEvents().toString());
659652
}
660653

661-
@Test
662-
@Parameters(method = "getNestedColumnFormatSpec")
663-
@TestCaseName("{0}")
654+
@ParameterizedTest(name = "{0}")
655+
@MethodSource("getNestedColumnFormatSpec")
664656
public void testIngestAndScanSegmentsAndFilterPartialPath(
665657
String name,
666658
boolean auto,
@@ -701,9 +693,8 @@ public void testIngestAndScanSegmentsAndFilterPartialPath(
701693
Assert.assertEquals(results.get(0).getEvents().toString(), resultsRealtime.get(0).getEvents().toString());
702694
}
703695

704-
@Test
705-
@Parameters(method = "getNestedColumnFormatSpec")
706-
@TestCaseName("{0}")
696+
@ParameterizedTest(name = "{0}")
697+
@MethodSource("getNestedColumnFormatSpec")
707698
public void testIngestAndScanSegmentsNestedColumnNotNullFilter(
708699
String name,
709700
boolean auto,

rewrite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type: specs.openrewrite.org/v1beta/recipe
2727
name: org.apache.druid.UpgradeCalciteTestsToJunit5
2828
preconditions:
2929
- org.openrewrite.java.search.FindImplementations:
30-
typeName: org.apache.druid.sql.calcite.util.CalciteTestBase
30+
typeName: org.apache.druid.query.scan.InitializedNullHandlingTest1
3131
recipeList:
3232
- org.apache.druid.JUnit4to5Migration
3333
- org.openrewrite.staticanalysis.UnnecessaryThrows

0 commit comments

Comments
 (0)