RebalanceOperationPerformer implements OperationPerformer<RebalanceOperation, RebalanceResult> { public RebalanceResult perform(Cache cache, RebalanceOperation parameters) { List<String> includeRegions = parameters.getIncludeRegions(); List<String> excludeRegions = parameters.getExcludeRegions(); boolean simulate = parameters.isSimulate(); RebalanceResultImpl result = new RebalanceResultImpl(); result.setSuccess(false); if (!includeRegions.isEmpty()) { List<RebalanceRegionResult> rebalanceRegionResults = new ArrayList<>(); NoMembersException latestNoMembersException = null; for (String regionName : includeRegions) { RebalanceRegionResult rebalanceResult; try { rebalanceResult = performRebalance(cache, regionName, simulate); } catch (NoMembersException ex) { latestNoMembersException = ex; continue; } catch (Exception e) { result.setStatusMessage(e.getMessage()); continue; } rebalanceRegionResults.add(rebalanceResult); result.setSuccess(true); } if (latestNoMembersException != null && !result.getSuccess()) { result.setStatusMessage(latestNoMembersException.getMessage()); } else { result.setRebalanceSummary(rebalanceRegionResults); } return result; } else { result = (RebalanceResultImpl) executeRebalanceOnDS(ManagementService.getManagementService(cache), (InternalCache) cache, String.valueOf(simulate), excludeRegions, new FunctionExecutor()); } return result; }  RebalanceResult perform(Cache cache, RebalanceOperation parameters); static DistributedMember getAssociatedMembers(String region, InternalCache cache); static List<MemberPRInfo> getMemberRegionList(ManagementService managementService,
      InternalCache cache,
      List<String> listExcludedRegion);  }
@Test public void performWithIncludeRegionsWhenRegionOnNoMembersReturnsFalseWithCorrectMessage() { RebalanceOperation rebalanceOperation = mock(RebalanceOperation.class); when(rebalanceOperation.getIncludeRegions()).thenReturn(Collections.singletonList("region1")); InternalCacheForClientAccess cache = mock(InternalCacheForClientAccess.class); when(cache.getCacheForProcessingClientRequests()).thenReturn(cache); BaseManagementService managementService = mock(BaseManagementService.class); BaseManagementService.setManagementService(cache, managementService); RebalanceResult result = performer.perform(cache, rebalanceOperation); assertThat(result.getSuccess()).isFalse(); assertThat(result.getStatusMessage()) .isEqualTo("For the region " + SEPARATOR + "region1, no member was found."); }