Search in sources :

Example 1 with ApplicationPlugin

use of org.codice.ddf.admin.application.plugin.ApplicationPlugin in project ddf by codice.

the class ApplicationServiceBeanTest method testGetSetApplicationPlugins.

/**
 * Tests the {@link ApplicationServiceBean#getApplicationPlugins()} method and the {@link
 * ApplicationServiceBean#setApplicationPlugins(List)} method
 *
 * @throws Exception
 */
@Test
public void testGetSetApplicationPlugins() throws Exception {
    ApplicationServiceBean serviceBean = newApplicationServiceBean();
    ApplicationPlugin testPlugin1 = mock(ApplicationPlugin.class);
    ApplicationPlugin testPlugin2 = mock(ApplicationPlugin.class);
    List<ApplicationPlugin> pluginList = new ArrayList<>();
    pluginList.add(testPlugin1);
    pluginList.add(testPlugin2);
    serviceBean.setApplicationPlugins(pluginList);
    assertEquals(pluginList, serviceBean.getApplicationPlugins());
}
Also used : ArrayList(java.util.ArrayList) ApplicationPlugin(org.codice.ddf.admin.application.plugin.ApplicationPlugin) Test(org.junit.Test)

Example 2 with ApplicationPlugin

use of org.codice.ddf.admin.application.plugin.ApplicationPlugin in project ddf by codice.

the class ApplicationServiceBeanTest method testGetPluginsForApplication.

/**
 * Tests the {@link ApplicationServiceBean#getPluginsForApplication(String)} method
 *
 * @throws Exception
 */
@Test
public void testGetPluginsForApplication() throws Exception {
    ApplicationServiceBean serviceBean = newApplicationServiceBean();
    ApplicationPlugin testPlugin1 = mock(ApplicationPlugin.class);
    ApplicationPlugin testPlugin2 = mock(ApplicationPlugin.class);
    List<ApplicationPlugin> pluginList = new ArrayList<>();
    pluginList.add(testPlugin1);
    pluginList.add(testPlugin2);
    Map<String, Object> plugin1JSON = new HashMap<>();
    plugin1JSON.put("TestAppJSON", "Plugin1");
    Map<String, Object> plugin2JSON = new HashMap<>();
    plugin2JSON.put("TestAppJSON", "Plugin2");
    when(testPlugin1.matchesAssocationName(TEST_APP_NAME)).thenReturn(true);
    when(testPlugin2.matchesAssocationName(TEST_APP_NAME)).thenReturn(true);
    when(testPlugin1.toJSON()).thenReturn(plugin1JSON);
    when(testPlugin2.toJSON()).thenReturn(plugin2JSON);
    serviceBean.setApplicationPlugins(pluginList);
    assertThat("Should return the list of plugins given to it.", serviceBean.getPluginsForApplication(TEST_APP_NAME).get(0), is(plugin1JSON));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApplicationPlugin(org.codice.ddf.admin.application.plugin.ApplicationPlugin) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 ApplicationPlugin (org.codice.ddf.admin.application.plugin.ApplicationPlugin)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1