MemberValidator { public String[] findGroupsWithThisElement(AbstractConfiguration config, CacheConfigurationManager manager) { return findCacheElement(config, manager).keySet().toArray(new String[0]); } MemberValidator(InternalCache cache, ConfigurationPersistenceService persistenceService); void validateCreate(AbstractConfiguration config, CacheConfigurationManager manager); String[] findGroupsWithThisElement(AbstractConfiguration config,
      CacheConfigurationManager manager); Map<String, AbstractConfiguration> findCacheElement(AbstractConfiguration config,
      CacheConfigurationManager manager); Set<String> findGroups(String regionName); Set<DistributedMember> findServers(String... groups); Set<DistributedMember> findServers(AbstractConfiguration configuration); Set<DistributedMember> findMembers(String id, String... groups); Set<DistributedMember> findMembers(boolean includeLocators, String... groups);  }
@Test public void findGroupsWithThisElement() { cacheConfig.getRegions().add(xmlRegionConfig); when(service.getCacheConfig("cluster", true)).thenReturn(cacheConfig); assertThat(validator.findGroupsWithThisElement(regionConfig, regionManager)) .containsExactly("cluster"); when(service.getCacheConfig("cluster", true)).thenReturn(new CacheConfig()); when(service.getCacheConfig("group1", true)).thenReturn(cacheConfig); when(service.getCacheConfig("group2", true)).thenReturn(cacheConfig); CacheConfig another = new CacheConfig(); when(service.getCacheConfig("group3", true)).thenReturn(another); assertThat(validator.findGroupsWithThisElement(regionConfig, regionManager)) .containsExactlyInAnyOrder("group1", "group2"); }