You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org> on 2026/08/07 14:32:41 UTC
Re: [PR] test: migrate nine extensions-contrib modules to JUnit 5 (druid)
github-advanced-security[bot] commented on code in PR #19908:
URL: https://github.com/apache/druid/pull/19908#discussion_r3736491813
##########
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:
## CodeQL / Missing Override annotation
This method overrides [CompressedBigDecimalAggregatorGroupByTestBase.testIngestAndGroupByAllQuery](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/druid/security/code-scanning/11698)
##########
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:
## CodeQL / Deprecated method or constructor invocation
Invoking [ColumnAnalysis.getType](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/11701)
##########
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:
## CodeQL / Missing Override annotation
This method overrides [CompressedBigDecimalAggregatorGroupByTestBase.testIngestAndGroupByAllQuery](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/druid/security/code-scanning/11700)
##########
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:
## CodeQL / Useless parameter
The parameter 'timeUnit' is never used.
[Show more details](https://github.com/apache/druid/security/code-scanning/11695)
##########
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:
## CodeQL / Missing Override annotation
This method overrides [CompressedBigDecimalAggregatorGroupByTestBase.testIngestAndGroupByAllQuery](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/druid/security/code-scanning/11699)
##########
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:
## CodeQL / Useless parameter
The parameter 'timeUnit' is never used.
[Show more details](https://github.com/apache/druid/security/code-scanning/11694)
##########
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:
## CodeQL / Useless parameter
The parameter 'period' is never used.
[Show more details](https://github.com/apache/druid/security/code-scanning/11697)
##########
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:
## CodeQL / Deprecated method or constructor invocation
Invoking [ColumnAnalysis.getType](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/11702)
##########
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:
## CodeQL / Useless parameter
The parameter 'period' is never used.
[Show more details](https://github.com/apache/druid/security/code-scanning/11696)
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org