use of org.codice.ddf.admin.core.impl.ServiceImpl in project ddf by codice.
the class ApplicationServiceBeanTest method testGetServicesASE.
/**
* Tests the {@link ApplicationServiceBean#getServices(String)} method for the case where an
* ApplicationServiceException is thrown
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testGetServicesASE() throws Exception {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
final Appender mockAppender = mock(Appender.class);
when(mockAppender.getName()).thenReturn("MOCK");
root.addAppender(mockAppender);
root.setLevel(Level.ALL);
ApplicationServiceBean serviceBean = newApplicationServiceBean();
Bundle testBundle = mock(Bundle.class);
Bundle[] bundles = { testBundle };
when(bundleContext.getBundles()).thenReturn(bundles);
List<Service> services = new ArrayList<>();
Service testService1 = new ServiceImpl();
services.add(testService1);
when(testAppService.getApplication(TEST_APP_NAME)).thenReturn(testApp);
when(testConfigAdminExt.listServices(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(services);
serviceBean.getServices(TEST_APP_NAME);
}
use of org.codice.ddf.admin.core.impl.ServiceImpl in project ddf by codice.
the class ApplicationServiceBeanTest method testGetServices.
/**
* Tests the {@link ApplicationServiceBean#getServices(String)} method
*
* @throws Exception
*/
@Test
public void testGetServices() throws Exception {
ApplicationServiceBean serviceBean = newApplicationServiceBean();
Bundle testBundle = mock(Bundle.class);
Bundle[] bundles = { testBundle };
when(bundleContext.getBundles()).thenReturn(bundles);
List<Service> services = new ArrayList<>();
Service testService1 = new ServiceImpl();
List<Map<String, Object>> testService1Configs = new ArrayList<>();
Map<String, Object> testConfig1 = new HashMap<>();
testConfig1.put("bundle_location", TEST_LOCATION);
testService1Configs.add(testConfig1);
services.add(testService1);
testService1.put("configurations", testService1Configs);
BundleInfo testBundle1 = mock(BundleInfo.class);
Set<BundleInfo> testBundles = new HashSet<>();
testBundles.add(testBundle1);
when(testApp.getBundles()).thenReturn(testBundles);
when(testBundle1.getLocation()).thenReturn(TEST_LOCATION);
when(testAppService.getApplication(TEST_APP_NAME)).thenReturn(testApp);
when(testConfigAdminExt.listServices(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(services);
assertThat("Should find the given services.", serviceBean.getServices(TEST_APP_NAME).get(0), is(testService1));
}
Aggregations