github-advanced-security[bot] commented on code in PR #16291:
URL: https://github.com/apache/druid/pull/16291#discussion_r1670986384


##########
server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java:
##########
@@ -401,6 +412,115 @@
     Assert.assertNotNull(newConfigCaptor.getValue());
     Assert.assertEquals(1, 
newConfigCaptor.getValue().getCompactionConfigs().size());
     Assert.assertEquals(newConfig, 
newConfigCaptor.getValue().getCompactionConfigs().get(0));
+    Assert.assertEquals(newConfig.getEngine(), 
newConfigCaptor.getValue().getCompactionConfigs().get(0).getEngine());
+  }
+
+  @Test
+  public void 
testAddOrUpdateCompactionConfigWithoutExistingConfigAndEngineAsNull()
+  {
+    Mockito.when(mockConnector.lookup(
+                     ArgumentMatchers.anyString(),
+                     ArgumentMatchers.eq("name"),
+                     ArgumentMatchers.eq("payload"),
+                     
ArgumentMatchers.eq(CoordinatorCompactionConfig.CONFIG_KEY)
+                 )
+    ).thenReturn(null);
+    Mockito.when(mockJacksonConfigManager.convertByteToConfig(
+                     ArgumentMatchers.eq(null),
+                     ArgumentMatchers.eq(CoordinatorCompactionConfig.class),
+                     ArgumentMatchers.eq(CoordinatorCompactionConfig.empty())
+                 )
+    ).thenReturn(CoordinatorCompactionConfig.empty());
+    final ArgumentCaptor<byte[]> oldConfigCaptor = 
ArgumentCaptor.forClass(byte[].class);
+    final ArgumentCaptor<CoordinatorCompactionConfig> newConfigCaptor = 
ArgumentCaptor.forClass(
+        CoordinatorCompactionConfig.class);
+    Mockito.when(mockJacksonConfigManager.set(
+                     
ArgumentMatchers.eq(CoordinatorCompactionConfig.CONFIG_KEY),
+                     oldConfigCaptor.capture(),
+                     newConfigCaptor.capture(),
+                     ArgumentMatchers.any()
+                 )
+    ).thenReturn(ConfigManager.SetResult.ok());
+
+    final DataSourceCompactionConfig newConfig = new 
DataSourceCompactionConfig(
+        "dataSource",
+        null,
+        500L,
+        null,
+        new Period(3600),
+        null,
+        new UserCompactionTaskGranularityConfig(Granularities.HOUR, null, 
null),
+        null,
+        null,
+        null,
+        null,
+        null,
+        ImmutableMap.of("key", "val")
+    );
+    Response ignore = 
coordinatorCompactionConfigsResource.addOrUpdateCompactionConfig(
+        newConfig,
+        mockHttpServletRequest
+    );

Review Comment:
   ## Unread local variable
   
   Variable 'Response ignore' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/7551)



-- 
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]

Reply via email to