ImportDeclarationPersistenceBackendService implements ConfigPersistenceBackendService<ImportDeclaration> { @SuppressWarnings("unchecked") @Override public void persist(ConfigItem<ImportDeclaration> config) throws PersistenceException, InvalidConfigurationException { LOGGER.debug("persisting import \"{}\"", config.getContent().getClassName()); Preconditions.checkArgument(supports((Class<? extends ConfigItem<?>>) config.getClass()), "Argument type not supported"); List<String> imports = readStorageFile(); String clazz = config.getContent().getClassName(); if (!imports.contains(clazz)) { imports.add(clazz); } writeStorageFile(imports); }  @Override List<ConfigItem<ImportDeclaration>> load(Map<String, String> metadata); @SuppressWarnings("unchecked") @Override void persist(ConfigItem<ImportDeclaration> config); @Override void remove(Map<String, String> metadata); @Override boolean supports(Class<? extends ConfigItem<?>> configItemType); void setStorageFilePath(String storageFilePath);  }
@Test public void testPersistImportConfiguration_shouldCreateFileIfNoneExists() throws Exception { FileUtils.forceDelete(storageFile); assertFalse(storageFile.exists()); ImportConfiguration conf = new ImportConfiguration(new ImportDeclaration("java.util.List")); service.persist(conf); assertTrue(storageFile.exists()); }