FrankChen021 commented on code in PR #19908:
URL: https://github.com/apache/druid/pull/19908#discussion_r3736688839
##########
sql/src/test/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtilsTest.java:
##########
@@ -114,72 +105,78 @@
);
}
- TimeUnit timeUnit;
- Period period;
- Granularity expectedGranularity;
-
- public FloorToGranularityConversionTest(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
- {
- this.timeUnit = timeUnit;
- this.period = period;
- this.expectedGranularity = expectedGranularity;
- }
-
- @Test
- public void testGetGranularityFromFloor()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testGetGranularityFromFloor(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
Review Comment:
This parameter is intentional: the parameterized test uses `name = "{1}"`,
so `period` supplies the test-case display name and preserves the previous
JUnit 4 naming. No code change is needed for this finding.
##########
sql/src/test/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtilsTest.java:
##########
@@ -114,72 +105,78 @@
);
}
- TimeUnit timeUnit;
- Period period;
- Granularity expectedGranularity;
-
- public FloorToGranularityConversionTest(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
- {
- this.timeUnit = timeUnit;
- this.period = period;
- this.expectedGranularity = expectedGranularity;
- }
-
- @Test
- public void testGetGranularityFromFloor()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testGetGranularityFromFloor(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
{
// parserPos doesn't matter
final SqlNodeList args = new SqlNodeList(SqlParserPos.ZERO);
args.add(new SqlIdentifier("__time", SqlParserPos.ZERO));
- args.add(new SqlIntervalQualifier(this.timeUnit, null,
SqlParserPos.ZERO));
+ args.add(new SqlIntervalQualifier(timeUnit, null, SqlParserPos.ZERO));
final SqlNode floorCall = SqlStdOperatorTable.FLOOR.createCall(args);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(floorCall);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY 'day'"
*/
- @Test
- public void testConvertSqlNodeToGranularityAsLiteral()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToGranularityAsLiteral(
+ TimeUnit timeUnit,
+ Period period,
+ Granularity expectedGranularity
+ )
{
SqlNode sqlNode = SqlLiteral.createCharString(timeUnit.name(),
SqlParserPos.ZERO);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(sqlNode);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY PT1D"
*/
- @Test
- public void testConvertSqlNodeToPeriodFormGranularityAsIdentifier()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToPeriodFormGranularityAsIdentifier(
+ TimeUnit timeUnit,
Review Comment:
Fixed in commit `77413749cb`: this test now uses a two-argument
`periodConstructorFeeder` and no longer accepts the unused `timeUnit`
parameter. The focused `DruidSqlParserUtilsTest` passed 57 tests with 0
failures or errors.
##########
extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/sum/CompressedBigDecimalSumAggregatorGroupByTest.java:
##########
@@ -34,20 +34,21 @@
public class CompressedBigDecimalSumAggregatorGroupByTest extends
CompressedBigDecimalAggregatorGroupByTestBase
{
- public CompressedBigDecimalSumAggregatorGroupByTest(
+ @ParameterizedTest
+ @MethodSource("constructorFeeder")
+ public void testIngestAndGroupByAllQuery(
Review Comment:
Fixed in commit `77413749cb`: added `@Override` to
`testIngestAndGroupByAllQuery`. The focused compressed-bigdecimal group-by
tests pass (12 tests total, 0 failures), and Checkstyle, SpotBugs, and
forbidden-API checks pass.
##########
sql/src/test/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtilsTest.java:
##########
@@ -114,72 +105,78 @@
);
}
- TimeUnit timeUnit;
- Period period;
- Granularity expectedGranularity;
-
- public FloorToGranularityConversionTest(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
- {
- this.timeUnit = timeUnit;
- this.period = period;
- this.expectedGranularity = expectedGranularity;
- }
-
- @Test
- public void testGetGranularityFromFloor()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testGetGranularityFromFloor(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
{
// parserPos doesn't matter
final SqlNodeList args = new SqlNodeList(SqlParserPos.ZERO);
args.add(new SqlIdentifier("__time", SqlParserPos.ZERO));
- args.add(new SqlIntervalQualifier(this.timeUnit, null,
SqlParserPos.ZERO));
+ args.add(new SqlIntervalQualifier(timeUnit, null, SqlParserPos.ZERO));
final SqlNode floorCall = SqlStdOperatorTable.FLOOR.createCall(args);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(floorCall);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY 'day'"
*/
- @Test
- public void testConvertSqlNodeToGranularityAsLiteral()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToGranularityAsLiteral(
+ TimeUnit timeUnit,
+ Period period,
Review Comment:
This parameter is intentional: the parameterized test uses `name = "{1}"`,
so `period` supplies the test-case display name and preserves the previous
JUnit 4 naming. No code change is needed for this finding.
##########
extensions-contrib/spectator-histogram/src/test/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorTest.java:
##########
@@ -541,15 +607,17 @@
.build();
List<SegmentAnalysis> results =
runner.run(QueryPlus.wrap(segmentMetadataQuery)).toList();
System.out.println(results);
- Assert.assertEquals(1, results.size());
+ Assertions.assertEquals(1, results.size());
Map<String, ColumnAnalysis> columns = results.get(0).getColumns();
- Assert.assertNotNull(columns.get("histogram"));
- Assert.assertEquals("spectatorHistogramDistribution",
columns.get("histogram").getType());
+ Assertions.assertNotNull(columns.get("histogram"));
+ Assertions.assertEquals("spectatorHistogramDistribution",
columns.get("histogram").getType());
Review Comment:
Thanks. This deprecated call was already present on the base branch; this PR
only changed the assertion API in this test. I’m leaving it unchanged to keep
the JUnit 5 migration scoped. A separate cleanup can replace it with
`getTypeSignature().getComplexTypeName()`.
##########
extensions-contrib/spectator-histogram/src/test/java/org/apache/druid/spectator/histogram/SpectatorHistogramAggregatorTest.java:
##########
@@ -495,16 +559,18 @@
.build();
List<SegmentAnalysis> results =
runner.run(QueryPlus.wrap(segmentMetadataQuery)).toList();
System.out.println(results);
- Assert.assertEquals(1, results.size());
+ Assertions.assertEquals(1, results.size());
Map<String, ColumnAnalysis> columns = results.get(0).getColumns();
- Assert.assertNotNull(columns.get("histogram"));
- Assert.assertEquals("spectatorHistogramTimer",
columns.get("histogram").getType());
+ Assertions.assertNotNull(columns.get("histogram"));
+ Assertions.assertEquals("spectatorHistogramTimer",
columns.get("histogram").getType());
Review Comment:
Thanks. This deprecated call was already present on the base branch; this PR
only changed the assertion API in this test. I’m leaving it unchanged to keep
the JUnit 5 migration scoped. A separate cleanup can replace it with
`getTypeSignature().getComplexTypeName()`.
##########
extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/max/CompressedBigDecimalMaxAggregatorGroupByTest.java:
##########
@@ -34,20 +34,21 @@
public class CompressedBigDecimalMaxAggregatorGroupByTest extends
CompressedBigDecimalAggregatorGroupByTestBase
{
- public CompressedBigDecimalMaxAggregatorGroupByTest(
+ @ParameterizedTest
+ @MethodSource("constructorFeeder")
+ public void testIngestAndGroupByAllQuery(
Review Comment:
Fixed in commit `77413749cb`: added `@Override` to
`testIngestAndGroupByAllQuery`. The focused compressed-bigdecimal group-by
tests pass (12 tests total, 0 failures), and Checkstyle, SpotBugs, and
forbidden-API checks pass.
##########
extensions-contrib/compressed-bigdecimal/src/test/java/org/apache/druid/compressedbigdecimal/aggregator/min/CompressedBigDecimalMinAggregatorGroupByTest.java:
##########
@@ -24,32 +24,31 @@
import org.apache.druid.java.util.common.granularity.Granularities;
import org.apache.druid.query.groupby.GroupByQuery;
import org.apache.druid.query.groupby.GroupByQueryConfig;
-import org.apache.druid.query.groupby.GroupByQueryRunnerTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-@RunWith(Parameterized.class)
public class CompressedBigDecimalMinAggregatorGroupByTest extends
CompressedBigDecimalAggregatorGroupByTestBase
{
- public CompressedBigDecimalMinAggregatorGroupByTest(
+ @ParameterizedTest
+ @MethodSource("constructorFeeder")
+ public void testIngestAndGroupByAllQuery(
Review Comment:
Fixed in commit `77413749cb`: added `@Override` to
`testIngestAndGroupByAllQuery`. The focused compressed-bigdecimal group-by
tests pass (12 tests total, 0 failures), and Checkstyle, SpotBugs, and
forbidden-API checks pass.
##########
sql/src/test/java/org/apache/druid/sql/calcite/parser/DruidSqlParserUtilsTest.java:
##########
@@ -114,72 +105,78 @@
);
}
- TimeUnit timeUnit;
- Period period;
- Granularity expectedGranularity;
-
- public FloorToGranularityConversionTest(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
- {
- this.timeUnit = timeUnit;
- this.period = period;
- this.expectedGranularity = expectedGranularity;
- }
-
- @Test
- public void testGetGranularityFromFloor()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testGetGranularityFromFloor(TimeUnit timeUnit, Period period,
Granularity expectedGranularity)
{
// parserPos doesn't matter
final SqlNodeList args = new SqlNodeList(SqlParserPos.ZERO);
args.add(new SqlIdentifier("__time", SqlParserPos.ZERO));
- args.add(new SqlIntervalQualifier(this.timeUnit, null,
SqlParserPos.ZERO));
+ args.add(new SqlIntervalQualifier(timeUnit, null, SqlParserPos.ZERO));
final SqlNode floorCall = SqlStdOperatorTable.FLOOR.createCall(args);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(floorCall);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY 'day'"
*/
- @Test
- public void testConvertSqlNodeToGranularityAsLiteral()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToGranularityAsLiteral(
+ TimeUnit timeUnit,
+ Period period,
+ Granularity expectedGranularity
+ )
{
SqlNode sqlNode = SqlLiteral.createCharString(timeUnit.name(),
SqlParserPos.ZERO);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(sqlNode);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY PT1D"
*/
- @Test
- public void testConvertSqlNodeToPeriodFormGranularityAsIdentifier()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToPeriodFormGranularityAsIdentifier(
+ TimeUnit timeUnit,
+ Period period,
+ Granularity expectedGranularity
+ )
{
SqlNode sqlNode = new SqlIdentifier(period.toString(),
SqlParserPos.ZERO);
Granularity actualGranularity =
DruidSqlParserUtils.convertSqlNodeToGranularity(sqlNode);
- Assert.assertEquals(expectedGranularity, actualGranularity);
+ Assertions.assertEquals(expectedGranularity, actualGranularity);
}
/**
* Tests clause like "PARTITIONED BY 'PT1D'"
*/
- @Test
- public void testConvertSqlNodeToPeriodFormGranularityAsLiteral()
+ @ParameterizedTest(name = "{1}")
+ @MethodSource("constructorFeeder")
+ public void testConvertSqlNodeToPeriodFormGranularityAsLiteral(
+ TimeUnit timeUnit,
Review Comment:
Fixed in commit `77413749cb`: this test now uses a two-argument
`periodConstructorFeeder` and no longer accepts the unused `timeUnit`
parameter. The focused `DruidSqlParserUtilsTest` passed 57 tests with 0
failures or errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]