Search in sources :

Example 1 with ConfigurationAdminPlugin

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());
}
Also used : ConfigurationAdminPlugin(org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with ConfigurationAdminPlugin

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);
}
Also used : Filter(org.osgi.framework.Filter) ConfigurationAdminPlugin(org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin) HashMap(java.util.HashMap) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Mockito.anyString(org.mockito.Mockito.anyString) HashMap(java.util.HashMap) Map(java.util.Map) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 3 with ConfigurationAdminPlugin

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;
}
Also used : HashMap(java.util.HashMap) ConfigurationAdminPlugin(org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin)

Aggregations

ConfigurationAdminPlugin (org.codice.ddf.ui.admin.api.plugin.ConfigurationAdminPlugin)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 Mockito.anyString (org.mockito.Mockito.anyString)1 BundleContext (org.osgi.framework.BundleContext)1 Filter (org.osgi.framework.Filter)1