ContextFilePersistenceService implements ConfigPersistenceBackendService<Map<String, String>> { @Override public void remove(Map<String, String> metadata) throws PersistenceException { String contextFileName = getFileNameForMetaData(metadata); File contextPersistenceFile = new File(storageFolder, contextFileName); Boolean fileSuccessFullyDeleted = FileUtils.deleteQuietly(contextPersistenceFile); if (!fileSuccessFullyDeleted) { throw new PersistenceException(String.format("Could not delete context configuration file %s", contextFileName)); } LOGGER.info("Deleted context configuration file %s", contextFileName); }  @Override List<ConfigItem<Map<String, String>>> load(Map<String, String> metadata); @SuppressWarnings("unchecked") @Override void persist(ConfigItem<Map<String, String>> config); @Override void remove(Map<String, String> metadata); @Override boolean supports(Class<? extends ConfigItem<?>> configItemType); void setStorageFolderPath(String storageFolderPath); static final String CONTEXT_FILE_EXTENSION; }
@Test public void testRemovingConfiguration_shouldDeleteFile() throws Exception { File configFileThatShouldBeDeleted = new File(temporaryFolder.getRoot(), "context3.context"); persistenceService.remove(getMetaDataWithContextId("context3")); assertThat(configFileThatShouldBeDeleted.exists(), is(false)); }