github-advanced-security[bot] commented on code in PR #20031:
URL: https://github.com/apache/druid/pull/20031#discussion_r3795621585
##########
server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java:
##########
@@ -107,29 +108,33 @@
configProvider.inject(properties, configurator);
CacheConfig config = configProvider.get();
- Assert.assertEquals(99, config.getNumBackgroundThreads());
- Assert.assertEquals(false, config.isPopulateCache());
- Assert.assertEquals(false, config.isUseCache());
+ Assertions.assertEquals(99, config.getNumBackgroundThreads());
+ Assertions.assertEquals(false, config.isPopulateCache());
+ Assertions.assertEquals(false, config.isUseCache());
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testValidationError()
{
- properties.put(PROPERTY_PREFIX + ".numBackgroundThreads", "-1");
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ properties.put(PROPERTY_PREFIX + ".numBackgroundThreads", "-1");
- configProvider.inject(properties, configurator);
- CacheConfig config = configProvider.get();
- Assert.assertNotEquals(-1, config.getNumBackgroundThreads());
+ configProvider.inject(properties, configurator);
+ CacheConfig config = configProvider.get();
+ Assertions.assertNotEquals(-1, config.getNumBackgroundThreads());
+ });
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testValidationInsaneError()
{
- properties.put(PROPERTY_PREFIX + ".numBackgroundThreads", "BABBA YAGA");
- configProvider.inject(properties, configurator);
- CacheConfig config = configProvider.get();
- throw new IllegalStateException("Should have already failed");
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ properties.put(PROPERTY_PREFIX + ".numBackgroundThreads", "BABBA YAGA");
+ configProvider.inject(properties, configurator);
+ CacheConfig config = configProvider.get();
Review Comment:
## CodeQL / Unread local variable
Variable 'CacheConfig config' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11821)
##########
server/src/test/java/org/apache/druid/client/cache/CacheConfigTest.java:
##########
@@ -147,17 +152,19 @@
properties.put(PROPERTY_PREFIX + ".populateCache", "FALSE");
configProvider.inject(properties, configurator);
CacheConfig config = configProvider.get();
- Assert.assertFalse(config.isPopulateCache());
+ Assertions.assertFalse(config.isPopulateCache());
}
- @Test(expected = ProvisionException.class)
+ @Test
public void testMixedCaseFalseIsRejected()
{
- properties.put(PROPERTY_PREFIX + ".populateCache", "FaLse");
- configProvider.inject(properties, configurator);
- CacheConfig config = configProvider.get();
- throw new IllegalStateException("Should have already failed");
+ Assertions.assertThrows(ProvisionException.class, () -> {
+ properties.put(PROPERTY_PREFIX + ".populateCache", "FaLse");
+ configProvider.inject(properties, configurator);
+ CacheConfig config = configProvider.get();
Review Comment:
## CodeQL / Unread local variable
Variable 'CacheConfig config' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11822)
##########
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionTaskDimensionsSpecTest.java:
##########
@@ -58,14 +59,16 @@
json,
ClientCompactionTaskDimensionsSpec.class
);
- Assert.assertEquals(expected, fromJson);
+ Assertions.assertEquals(expected, fromJson);
}
- @Test(expected = ParseException.class)
+ @Test
public void testInvalidDimensionsField()
{
- final ClientCompactionTaskDimensionsSpec expected = new
ClientCompactionTaskDimensionsSpec(
- DimensionsSpec.getDefaultSchemas(ImmutableList.of("ts", "dim", "dim"))
- );
+ Assertions.assertThrows(ParseException.class, () -> {
+ final ClientCompactionTaskDimensionsSpec expected = new
ClientCompactionTaskDimensionsSpec(
+ DimensionsSpec.getDefaultSchemas(ImmutableList.of("ts", "dim",
"dim"))
+ );
Review Comment:
## CodeQL / Unread local variable
Variable 'ClientCompactionTaskDimensionsSpec expected' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11823)
##########
server/src/test/java/org/apache/druid/query/dimension/LookupDimensionSpecTest.java:
##########
@@ -217,22 +220,22 @@
};
}
- @Test
- @Parameters
+ @ParameterizedTest
+ @MethodSource("parametersForTestGetCacheKey")
public void testGetCacheKey(DimensionSpec dimensionSpec, boolean
expectedResult)
{
- Assert.assertEquals(expectedResult,
Arrays.equals(lookupDimSpec.getCacheKey(), dimensionSpec.getCacheKey()));
+ Assertions.assertEquals(expectedResult,
Arrays.equals(lookupDimSpec.getCacheKey(), dimensionSpec.getCacheKey()));
}
@Test
public void testPreservesOrdering()
{
- Assert.assertFalse(lookupDimSpec.preservesOrdering());
+ Assertions.assertFalse(lookupDimSpec.preservesOrdering());
}
@Test
public void testIsOneToOne()
{
- Assert.assertEquals(lookupDimSpec.getExtractionFn().getExtractionType(),
ExtractionFn.ExtractionType.ONE_TO_ONE);
+
Assertions.assertEquals(lookupDimSpec.getExtractionFn().getExtractionType(),
ExtractionFn.ExtractionType.ONE_TO_ONE);
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [DimensionSpec.getExtractionFn](1) should be avoided because it has
been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11825)
##########
server/src/test/java/org/apache/druid/client/selector/ServerSelectorTest.java:
##########
@@ -101,17 +102,19 @@
.build()
);
- Assert.assertEquals(ImmutableList.of("a", "b", "c"),
selector.getSegment().getDimensions());
+ Assertions.assertEquals(ImmutableList.of("a", "b", "c"),
selector.getSegment().getDimensions());
}
- @Test(expected = NullPointerException.class)
+ @Test
public void testSegmentCannotBeNull()
{
- final ServerSelector selector = new ServerSelector(
- null,
- new HighestPriorityTierSelectorStrategy(new
RandomServerSelectorStrategy()),
- HistoricalFilter.IDENTITY_FILTER
- );
+ Assertions.assertThrows(NullPointerException.class, () -> {
+ final ServerSelector selector = new ServerSelector(
+ null,
+ new HighestPriorityTierSelectorStrategy(new
RandomServerSelectorStrategy()),
+ HistoricalFilter.IDENTITY_FILTER
+ );
Review Comment:
## CodeQL / Unread local variable
Variable 'ServerSelector selector' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11824)
--
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]