ContextFilePersistenceService implements ConfigPersistenceBackendService<Map<String, String>> { @Override public List<ConfigItem<Map<String, String>>> load(Map<String, String> metadata) throws PersistenceException, InvalidConfigurationException { LOGGER.debug("Loading Configuration"); if (metadata == null || metadata.isEmpty()) { return loadAll(); } else { return loadFiltered(metadata); } }  @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 testLoad_shouldGetAllFiles() throws Exception { Map<String, String> metaData = Collections.emptyMap(); List<ConfigItem<Map<String, String>>> items = persistenceService.load(metaData); assertThat(items.size(), is(3)); }
@Test public void testFilteredLoad_shouldReturnConfigurationWithCorrespindingMetaData() throws Exception { Map<String, String> metaData = new HashMap<String, String>(); metaData.put(ContextId.META_KEY_ID, "context2"); List<ConfigItem<Map<String, String>>> items = persistenceService.load(metaData); assertThat(items.size(), is(1)); ConfigItem<?> loadedConfiguration = items.get(0); assertThat(loadedConfiguration.getMetaData().get(ContextId.META_KEY_ID), is("context2")); }