DescribeQueryServiceCommand extends GfshCommand { QueryConfigService getQueryConfigService() { InternalConfigurationPersistenceService configService = getConfigurationPersistenceService(); if (configService != null) { CacheConfig cacheConfig = configService.getCacheConfig(null); if (cacheConfig != null) { return cacheConfig.findCustomCacheElement(QueryConfigService.ELEMENT_ID, QueryConfigService.class); } } return null; }  @CliCommand(value = COMMAND_NAME, help = COMMAND_HELP) @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.READ) ResultModel execute(); static final String ALL_METHODS_ALLOWED; static final String FUNCTION_FAILED_ON_ALL_MEMBERS; static final String NO_CLUSTER_CONFIG_AND_NO_MEMBERS; static final String AUTHORIZER_CLASS_NAME; }
@Test public void commandReturnsErrorWhenClusterConfigDoesNotContainQueryConfigurationServiceAndFunctionFailsOnAllMembers() { doReturn(null).when(command).getQueryConfigService(); CliFunctionResult mockResult = mock(CliFunctionResult.class); doReturn(mockResult).when(command).executeFunctionAndGetFunctionResult(any( DescribeQueryServiceFunction.class), eq(null), any(DistributedMember.class)); when(mockResult.isSuccessful()).thenReturn(false); when(mockResult.getResultObject()).thenReturn(queryConfigService); memberSet.add(mock(DistributedMember.class)); memberSet.add(mock(DistributedMember.class)); gfsh.executeAndAssertThat(command, COMMAND_NAME).statusIsError() .containsOutput(FUNCTION_FAILED_ON_ALL_MEMBERS); verify(command, times(2)).executeFunctionAndGetFunctionResult(any( DescribeQueryServiceFunction.class), eq(null), any(DistributedMember.class)); }
@Test public void commandReturnsErrorWhenClusterConfigDoesNotContainQueryConfigurationServiceAndNoMembersFound() { doReturn(null).when(command).getQueryConfigService(); gfsh.executeAndAssertThat(command, COMMAND_NAME).statusIsError() .containsOutput(NO_CLUSTER_CONFIG_AND_NO_MEMBERS); }