IndexConfigManager extends CacheConfigurationManager<Index> { @Override public void delete(Index config, CacheConfig existing) { RegionConfig regionConfig = existing.findRegionConfiguration(config.getRegionName()); if (regionConfig == null) { throw new IllegalArgumentException( "Region provided does not exist: " + config.getRegionName()); } RegionConfig.Index index = regionConfig.getIndexes().stream() .filter(item -> item.getName().equals(config.getName())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Index provided does not exist on Region: " + config.getRegionName() + ", " + config.getName())); regionConfig.getIndexes().remove(index); } 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 delete_regionNotFound() { setupCacheConfig(); index.setName("index3"); index.setIndexType(IndexType.RANGE); index.setRegionPath("region3"); assertThatThrownBy(() -> manager.delete(index, cacheConfig)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Region provided does not exist: region3"); }
@Test public void delete_indexNotFound() { setupCacheConfig(); index.setName("index3"); index.setIndexType(IndexType.RANGE); index.setRegionPath("region2"); assertThatThrownBy(() -> manager.delete(index, cacheConfig)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Index provided does not exist on Region: region2, index3"); }