@Test public void invokeCommandWithUpdateAllConfigsInterface_noGroupOptionSpecifiedWhenSingleConfiguredGroups_CallsUpdateConfigForGroup() { Set<String> configuredGroups = new HashSet<>(); configuredGroups.add("group1"); when(parseResult.getParamValueAsString("group")).thenReturn(null); doReturn(result).when(executor).callInvokeMethod(any(), any()); doReturn(configuredGroups).when(ccService).getGroups(); Object thisResult = executor.invokeCommand(testCommand, parseResult); verify(testCommand, times(1)).updateConfigForGroup(eq("group1"), any(), any()); }
@Test public void invokeCommandWithUpdateAllConfigsInterface_singleGroupOptionSpecifiedWhenMultipleConfiguredGroups_CallsUpdateConfigForGroup() { Set<String> configuredGroups = new HashSet<>(); configuredGroups.add("group1"); configuredGroups.add("group2"); when(parseResult.getParamValueAsString("group")).thenReturn("group1"); doReturn(result).when(executor).callInvokeMethod(any(), any()); doReturn(configuredGroups).when(ccService).getGroups(); Object thisResult = executor.invokeCommand(testCommand, parseResult); verify(testCommand, times(1)).updateConfigForGroup(eq("group1"), any(), any()); }
@Test public void invokeCommandWithUpdateAllConfigsInterface_multipleGroupOptionSpecifiedWhenSingleConfiguredGroups_CallsUpdateConfigForGroupTwice() { Set<String> configuredGroups = new HashSet<>(); configuredGroups.add("group1"); when(parseResult.getParamValueAsString("group")).thenReturn("Group1,Group2"); doReturn(result).when(executor).callInvokeMethod(any(), any()); doReturn(configuredGroups).when(ccService).getGroups(); Object thisResult = executor.invokeCommand(testCommand, parseResult); verify(testCommand, times(1)).updateConfigForGroup(eq("Group1"), any(), any()); verify(testCommand, times(1)).updateConfigForGroup(eq("Group2"), any(), any()); }
@Test public void invokeCommandWithOutUpdateAllConfigsInterface_noGroupOptionSpecifiedWhenSingleConfiguredGroups_CallsUpdateConfigForCluster() { testCommand = mock(SingleGfshCommand.class); doReturn(ccService).when(testCommand).getConfigurationPersistenceService(); Set<String> configuredGroups = new HashSet<>(); configuredGroups.add("group1"); when(parseResult.getParamValueAsString("group")).thenReturn(null); doReturn(result).when(executor).callInvokeMethod(any(), any()); doReturn(configuredGroups).when(ccService).getGroups(); Object thisResult = executor.invokeCommand(testCommand, parseResult); verify(testCommand, times(1)).updateConfigForGroup(eq("cluster"), any(), any()); } }
CacheConfig.AsyncEventQueue findAEQ(String aeqId) { CacheConfig.AsyncEventQueue queue = null; InternalConfigurationPersistenceService ccService = (InternalConfigurationPersistenceService) this.getConfigurationPersistenceService(); if (ccService == null) { return null; } Set<String> groups = ccService.getGroups(); for (String group : groups) { queue = CacheElement.findElement(ccService.getCacheConfig(group).getAsyncEventQueues(), aeqId); if (queue != null) { return queue; } } return queue; }
@Before public void before() throws Exception { command = spy(AlterAsyncEventQueueCommand.class); service = spy(InternalConfigurationPersistenceService.class); configRegion = mock(AbstractRegion.class); doReturn(service).when(command).getConfigurationPersistenceService(); groupSet.add("group1"); groupSet.add("group2"); doReturn(groupSet).when(service).getGroups(); CacheConfig config = new CacheConfig(); CacheConfig.AsyncEventQueue aeq1 = new CacheConfig.AsyncEventQueue(); aeq1.setId("queue1"); config.getAsyncEventQueues().add(aeq1); doReturn(config).when(service).getCacheConfig("group1"); doReturn(new CacheConfig()).when(service).getCacheConfig("group2"); doReturn(config).when(service).getCacheConfig("group1", true); doReturn(new CacheConfig()).when(service).getCacheConfig("group2", true); doReturn(true).when(service).lockSharedConfiguration(); doNothing().when(service).unlockSharedConfiguration(); doReturn(null).when(service).getConfiguration(any()); doReturn(configRegion).when(service).getConfigurationRegion(); doCallRealMethod().when(service).updateCacheConfig(any(), any()); }
groupsToUpdate = Arrays.asList(groupInput.split(",")); } else if (gfshCommand instanceof UpdateAllConfigurationGroupsMarker) { groupsToUpdate = ccService.getGroups().stream().collect(Collectors.toList()); table = resultModel.addTable(GROUP_STATUS_SECTION); table.setColumnHeader("Group", "Status");