DiskStoreRealizer implements ConfigurationRealizer<DiskStore, DiskStoreInfo> { @Override public RealizationResult delete(DiskStore config, InternalCache cache) throws Exception { org.apache.geode.cache.DiskStore diskStore = cache.findDiskStore(config.getName()); if (diskStore != null) { diskStore.destroy(); return new RealizationResult() .setMessage("DiskStore " + config.getName() + " deleted successfully."); } else { return new RealizationResult().setMessage("DiskStore " + config.getName() + " not found.") .setSuccess(false); } }  @Override RealizationResult create(DiskStore config, InternalCache cache); @Override boolean exists(DiskStore config, InternalCache cache); @Override DiskStoreInfo get(DiskStore config, InternalCache cache); @Override RealizationResult update(DiskStore config, InternalCache cache); @Override RealizationResult delete(DiskStore config, InternalCache cache); @Override boolean isReadyOnly();  }
@Test public void deletingDiskStoreShouldFailIfDiskStoreNotFound() throws Exception { DiskStore config = new DiskStore(); String name = "diskStoreName"; config.setName(name); config.setDirectories(new ArrayList()); RealizationResult result = diskStoreRealizer.delete(config, cache); assertThat(result.getMessage()).isEqualTo("DiskStore " + config.getName() + " not found."); assertThat(result.isSuccess()).isFalse(); }
@Test public void deletingDiskStoreShouldSucceedIfDiskStoreFound() throws Exception { DiskStore config = new DiskStore(); config.setDirectories(new ArrayList()); String name = "diskStoreName"; config.setName(name); when(cache.findDiskStore(name)).thenReturn(mock(org.apache.geode.cache.DiskStore.class)); RealizationResult result = diskStoreRealizer.delete(config, cache); assertThat(result.getMessage()) .isEqualTo("DiskStore " + config.getName() + " deleted successfully."); assertThat(result.isSuccess()).isTrue(); }