IndexConfigManager extends CacheConfigurationManager<Index> { @Override public List<Index> list(Index filterConfig, CacheConfig existing) { List<Index> result = new ArrayList<>(); for (RegionConfig region : existing.getRegions()) { if (filterConfig.getRegionName() != null && !region.getName().equals(filterConfig.getRegionName())) { continue; } for (RegionConfig.Index index : region.getIndexes()) { if (filterConfig.getName() != null && !index.getName().equals(filterConfig.getName())) { continue; } Index matchingIndex = converter.fromXmlObject(index); result.add(matchingIndex); } } return result; } IndexConfigManager(ConfigurationPersistenceService persistenceService); @Override void add(Index config, CacheConfig existing); @Override void update(Index config, CacheConfig existing); @Override void delete(Index config, CacheConfig existing); @Override List<Index> list(Index filterConfig, CacheConfig existing); @Override Index get(Index config, CacheConfig existing);  }
@Test public void emptyConfig() { assertThat(manager.list(index, cacheConfig)).isEmpty(); }
@Test public void listWithoutFilter() { setupCacheConfig(); List<Index> list = manager.list(index, cacheConfig); assertSoftly(softly -> { softly.assertThat(list).hasSize(2) .extracting(Index::getName) .containsExactlyInAnyOrder("index1", "index2"); softly.assertThat(list).extracting(Index::getRegionName) .containsExactlyInAnyOrder("region1", "region2"); }); }
@Test public void listWithUnMatchingFilter() { setupCacheConfig(); index.setName("index1"); index.setRegionPath("region2"); List<Index> list = manager.list(index, cacheConfig); assertThat(list).hasSize(0); }