CreateDefinedIndexesCommand extends SingleGfshCommand { @Override public boolean updateConfigForGroup(String group, CacheConfig config, Object configObject) { @SuppressWarnings("unchecked") Set<RegionConfig.Index> updatedIndexes = (Set<RegionConfig.Index>) configObject; if (updatedIndexes == null) { return false; } for (RegionConfig.Index index : updatedIndexes) { RegionConfig regionConfig = getValidRegionConfig(index.getFromClause(), config); if (regionConfig == null) { throw new IllegalStateException("RegionConfig is null"); } regionConfig.getIndexes().add(index); } return true; }  @CliCommand(value = CliStrings.CREATE_DEFINED_INDEXES, help = CliStrings.CREATE_DEFINED__HELP) @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA}) @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.MANAGE, target = ResourcePermission.Target.QUERY) ResultModel createDefinedIndexes(

      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
          optionContext = ConverterHint.MEMBERIDNAME,
          help = CliStrings.CREATE_DEFINED_INDEXES__MEMBER__HELP) final String[] memberNameOrID,

      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
          optionContext = ConverterHint.MEMBERGROUP,
          help = CliStrings.CREATE_DEFINED_INDEXES__GROUP__HELP) final String[] groups); @Override boolean updateConfigForGroup(String group, CacheConfig config, Object configObject); static final String CREATE_DEFINED_INDEXES_SECTION; }
@Test public void creationSuccess() { DistributedMember member = mock(DistributedMember.class); when(member.getId()).thenReturn("memberId"); InternalConfigurationPersistenceService mockService = mock(InternalConfigurationPersistenceService.class); doReturn(mockService).when(command).getConfigurationPersistenceService(); doReturn(Collections.singleton(member)).when(command).findMembers(any(), any()); List<String> indexes = new ArrayList<>(); indexes.add("index1"); doReturn(Collections.singletonList(new CliFunctionResult(member.getId(), indexes))) .when(resultCollector) .getResult(); IndexDefinition.addIndex("index1", "value1", "TestRegion", FUNCTIONAL); gfshParser.executeAndAssertThat(command, "create defined indexes").statusIsSuccess(); verify(command, Mockito.times(0)).updateConfigForGroup(any(), any(), any()); }