GlobalDeclarationPersistenceBackendService implements ConfigPersistenceBackendService<GlobalDeclaration> { @SuppressWarnings("unchecked") @Override public void persist(ConfigItem<GlobalDeclaration> config) throws PersistenceException, InvalidConfigurationException { LOGGER.debug("persisting global \"{}\"", config.getContent().getVariableName()); Preconditions.checkArgument(supports((Class<? extends ConfigItem<?>>) config.getClass()), "Argument type not supported"); Map<String, String> globals = readStorageFile(); GlobalDeclaration global = config.getContent(); globals.put(global.getVariableName(), global.getClassName()); writeStorageFile(globals); }  void setStorageFilePath(String storageFilePath); @Override List<ConfigItem<GlobalDeclaration>> load(Map<String, String> metadata); @SuppressWarnings("unchecked") @Override void persist(ConfigItem<GlobalDeclaration> config); @Override void remove(Map<String, String> metadata); @Override boolean supports(Class<? extends ConfigItem<?>> configItemType);  }
@Test public void testPersistGlobalConfiguration_shouldCreateFileIfNoneExists() throws Exception { FileUtils.forceDelete(storageFile); assertFalse(storageFile.exists()); GlobalConfiguration conf = new GlobalConfiguration(new GlobalDeclaration("java.util.List", "list")); service.persist(conf); assertTrue(storageFile.exists()); }