@Test public void testPersistImportConfiguration_shouldPersistAndLoadConfig() { ImportConfiguration conf = new ImportConfiguration(new ImportDeclaration("java.util.List")); service.persist(conf); List<ConfigItem<ImportDeclaration>> loaded = service.load(conf.getMetaData()); assertEquals(1, loaded.size()); ImportConfiguration confLoaded = (ImportConfiguration) loaded.get(0); assertTrue(confLoaded.getContent().equals(conf.getContent())); }
@Test public void testRemoveImportConfiguration_ShouldDeleteConfiguration() { ImportConfiguration conf1 = new ImportConfiguration(new ImportDeclaration("java.util.List")); ImportConfiguration conf2 = new ImportConfiguration(new ImportDeclaration("java.util.Map")); service.persist(conf1); service.persist(conf2); service.remove(conf1.getMetaData()); List<ConfigItem<ImportDeclaration>> loaded = service.load(new HashMap<String, String>()); assertEquals(1, loaded.size()); ImportConfiguration confLoaded = (ImportConfiguration) loaded.get(0); assertEquals("java.util.Map", confLoaded.getContent().getClassName()); }
@Test public void testLoadImportConfiguration_shouldOnlyLoadOneConfig() { ImportConfiguration conf1 = new ImportConfiguration(new ImportDeclaration("java.util.List")); ImportConfiguration conf2 = new ImportConfiguration(new ImportDeclaration("java.util.Map")); ImportConfiguration conf3 = new ImportConfiguration(new ImportDeclaration("java.util.Dictionary")); service.persist(conf1); service.persist(conf2); service.persist(conf3); List<ConfigItem<ImportDeclaration>> loaded = service.load(conf2.getMetaData()); assertEquals(1, loaded.size()); ImportConfiguration confLoaded = (ImportConfiguration) loaded.get(0); assertEquals("java.util.Map", confLoaded.getContent().getClassName()); }