LocatorClusterManagementService implements ClusterManagementService { @VisibleForTesting void setResultStatus(ClusterManagementRealizationResult result, List<String> updatedGroups, List<String> failedGroups) { String successMessage = null; String failedMessage = null; if (!updatedGroups.isEmpty()) { successMessage = "Successfully updated configuration for " + String.join(", ", updatedGroups) + "."; } if (!failedGroups.isEmpty()) { failedMessage = "Failed to update configuration for " + String.join(", ", failedGroups) + "."; } if (failedMessage == null) { result.setStatus(StatusCode.OK, successMessage); return; } if (successMessage == null) { result.setStatus(StatusCode.FAIL_TO_PERSIST, failedMessage); return; } result.setStatus(StatusCode.FAIL_TO_PERSIST, successMessage + " " + failedMessage); return; } LocatorClusterManagementService(InternalCache cache,
      InternalConfigurationPersistenceService persistenceService); @VisibleForTesting  LocatorClusterManagementService(
      InternalCache cache,
      InternalConfigurationPersistenceService persistenceService,
      Map<Class, ConfigurationManager> managers,
      Map<Class, ConfigurationValidator> validators,
      MemberValidator memberValidator,
      CommonConfigurationValidator commonValidator,
      OperationManager operationManager); @Override ClusterManagementRealizationResult create(T config); @Override ClusterManagementRealizationResult delete(
      T config); @Override ClusterManagementRealizationResult update(
      T config); @Override ClusterManagementListResult<T, R> list(
      T filter); @Override ClusterManagementGetResult<T, R> get(
      T config); @Override ClusterManagementOperationResult<A, V> start(
      A op); @Override ClusterManagementListOperationsResult<A, V> list(
      A opType); @Override ClusterManagementOperationResult<A, V> get(
      A opType, String opId); @Override CompletableFuture<ClusterManagementOperationResult<A, V>> getFuture(
      A opType, String opId); boolean isConnected(); @Override void close(); @VisibleForTesting
  // the dlock service name used by the CMS
  static final String CMS_DLOCK_SERVICE_NAME; }
@Test public void setResultStatus() { ClusterManagementRealizationResult result = new ClusterManagementRealizationResult(); service.setResultStatus(result, Arrays.asList("group1"), Collections.EMPTY_LIST); assertThat(result.isSuccessful()).isTrue(); assertThat(result.getStatusMessage()) .isEqualTo("Successfully updated configuration for group1."); service.setResultStatus(result, Arrays.asList("group1", "group2"), Collections.EMPTY_LIST); assertThat(result.isSuccessful()).isTrue(); assertThat(result.getStatusMessage()) .isEqualTo("Successfully updated configuration for group1, group2."); service.setResultStatus(result, Collections.EMPTY_LIST, Arrays.asList("group1, group2")); assertThat(result.isSuccessful()).isFalse(); assertThat(result.getStatusMessage()) .isEqualTo("Failed to update configuration for group1, group2."); service.setResultStatus(result, Arrays.asList("group1"), Arrays.asList("group2")); assertThat(result.isSuccessful()).isFalse(); assertThat(result.getStatusMessage()).isEqualTo( "Successfully updated configuration for group1. Failed to update configuration for group2."); }