use of org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin in project ddf by codice.
the class ConfigurationAdminTest method testSetGetConfigurationAdminPluginList.
/**
* Tests the {@link ConfigurationAdmin#setConfigurationAdminPluginList(List)} and
* {@link ConfigurationAdmin#getConfigurationAdminPluginList()} methods
*
* @throws Exception
*/
@Test
public void testSetGetConfigurationAdminPluginList() throws Exception {
org.osgi.service.cm.ConfigurationAdmin testConfigAdmin = mock(org.osgi.service.cm.ConfigurationAdmin.class);
ConfigurationAdmin configAdmin = new ConfigurationAdmin(testConfigAdmin);
ConfigurationAdminPlugin testPlugin1 = mock(ConfigurationAdminPlugin.class);
ConfigurationAdminPlugin testPlugin2 = mock(ConfigurationAdminPlugin.class);
List<ConfigurationAdminPlugin> pluginList = new ArrayList<>();
pluginList.add(testPlugin1);
pluginList.add(testPlugin2);
configAdmin.setConfigurationAdminPluginList(pluginList);
assertNotNull(configAdmin.getConfigurationAdminPluginList());
assertEquals(pluginList, configAdmin.getConfigurationAdminPluginList());
}
use of org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin in project ddf by codice.
the class ConfigurationAdminExtTest method testListServicesExistingFilter.
/**
* Tests the {@link ConfigurationAdminExt#listServices(String, String)} method for the case
* where there is a filter returned by the bundleContext
*
* @throws Exception
*/
@Test
public void testListServicesExistingFilter() throws Exception {
setUpTestConfig();
setUpListServices();
Filter testFilter = mock(Filter.class);
List<ConfigurationAdminPlugin> testPluginList = new ArrayList<>();
ConfigurationAdminPlugin testPlugin = mock(ConfigurationAdminPlugin.class);
testPluginList.add(testPlugin);
Map<String, Object> testConfigData = new HashMap<>();
testConfigData.put(TEST_KEY, TEST_VALUE);
when(testPlugin.getConfigurationData(anyString(), any(Map.class), any(BundleContext.class))).thenReturn(testConfigData);
when(testFilter.match(any(Hashtable.class))).thenReturn(true);
when(testBundleContext.createFilter(anyString())).thenReturn(testFilter);
configurationAdminExt.setConfigurationAdminPluginList(testPluginList);
List<Map<String, Object>> result = configurationAdminExt.listServices(TEST_FACT_FILTER, TEST_FILTER);
assertThat("Should return the correct services.", (String) result.get(0).get("id"), is(TEST_PID));
verify(testConfigAdmin, atLeastOnce()).listConfigurations(LIST_CONFIG_STRING);
}
use of org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin in project ddf by codice.
the class ConfigurationAdminExt method getConfigurationPluginData.
private Map<String, Object> getConfigurationPluginData(String servicePid, Map<String, Object> dataMap) {
Map<String, Object> allPluginMap = new HashMap<String, Object>();
if (configurationAdminPluginList != null) {
for (ConfigurationAdminPlugin plugin : configurationAdminPluginList) {
Map<String, Object> pluginDataMap = plugin.getConfigurationData(servicePid, dataMap, getBundleContext());
allPluginMap.putAll(pluginDataMap);
}
}
return allPluginMap;
}
Aggregations