use of org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.ACTIVE in project ddf by codice.
the class TestApplicationService method bTestAppStatus.
@Test
public void bTestAppStatus() throws ApplicationServiceException, InterruptedException {
systemSubject.execute(() -> {
// Test AppService
ApplicationService applicationService = getServiceManager().getService(ApplicationService.class);
Set<Application> apps = applicationService.getApplications();
List<Application> catalogList = apps.stream().filter(a -> CATALOG_APP.equals(a.getName())).collect(Collectors.toList());
if (catalogList.size() != 1) {
fail("Expected to find 1 " + CATALOG_APP + " in Application list.");
}
Application catalog = catalogList.get(0);
try {
applicationService.startApplication(catalog);
getServiceManager().waitForAllBundles();
} catch (ApplicationServiceException e) {
LOGGER.error("Failed to start the {}: {}", CATALOG_APP, e.getMessage());
fail();
} catch (InterruptedException e) {
LOGGER.error("Failed to start start all bundles {}", e.getMessage());
fail();
}
assertNotNull("Application [" + CATALOG_APP + "] must not be null", catalog);
ApplicationStatus status = applicationService.getApplicationStatus(catalog);
assertThat("Application [" + CATALOG_APP + "] should be ACTIVE", status.getState(), is(ACTIVE));
List<Application> registryList = apps.stream().filter(a -> REGISTRY_APP.equals(a.getName())).collect(Collectors.toList());
if (catalogList.size() != 1) {
fail("Expected to find 1 " + REGISTRY_APP + " in Application list.");
}
Application registry = registryList.get(0);
assertNotNull("Application [" + REGISTRY_APP + "] must not be null", registry);
status = applicationService.getApplicationStatus(registry);
assertThat("Application [" + REGISTRY_APP + "] should be INACTIVE", status.getState(), is(INACTIVE));
// Test Commands
String response = console.runCommand(STATUS_COMMAND + CATALOG_APP);
assertThat(CATALOG_APP + " should be ACTIVE", response, containsString(ACTIVE_APP));
response = console.runCommand(STATUS_COMMAND + REGISTRY_APP);
assertThat(REGISTRY_APP + " should be INACTIVE", response, containsString(INACTIVE_APP));
});
}
Aggregations