use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationNodeImplTest method testCompareToIAE.
/**
* Tests the {@link ApplicationNodeImpl#compareTo(ApplicationNode)} method for the case
* where the parameter node is null
*/
@Test(expected = IllegalArgumentException.class)
public void testCompareToIAE() {
Application testApp = mock(Application.class);
ApplicationNodeImpl testNode = new ApplicationNodeImpl(testApp);
testNode.compareTo(null);
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationNodeImplTest method testHashCode.
/**
* Tests the {@link ApplicationNodeImpl#hashCode()} method
*/
@Test
public void testHashCode() {
try {
Repository testRepo = new RepositoryImpl(ApplicationNodeImpl.class.getClassLoader().getResource(FEATURES_FILE_NAME).toURI());
Application testApp = new ApplicationImpl(testRepo);
ApplicationNode testNode = new ApplicationNodeImpl(testApp);
assertEquals(testApp.hashCode(), testNode.hashCode());
} catch (Exception e) {
LOGGER.info("Exception: ", e);
fail();
}
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class StatusApplicationCommand method doExecute.
@Override
protected void doExecute(ApplicationService applicationService) throws ApplicationServiceException {
Application application = applicationService.getApplication(appName);
if (application != null) {
ApplicationStatus appStatus = applicationService.getApplicationStatus(application);
console.println(application.getName());
console.println("\nCurrent State is: " + appStatus.getState().toString());
console.println("\nFeatures Located within this Application:");
for (Feature curFeature : application.getFeatures()) {
console.println("\t" + curFeature.getName());
}
console.println("\nRequired Features Not Started");
if (appStatus.getErrorFeatures().isEmpty()) {
console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
console.println("\tNONE");
console.print(Ansi.ansi().reset().toString());
} else {
for (Feature curFeature : appStatus.getErrorFeatures()) {
console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
console.println("\t" + curFeature.getName());
console.print(Ansi.ansi().reset().toString());
}
}
console.println("\nRequired Bundles Not Started");
if (appStatus.getErrorBundles().isEmpty()) {
console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
console.println("\tNONE");
console.print(Ansi.ansi().reset().toString());
} else {
for (Bundle curBundle : appStatus.getErrorBundles()) {
console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
console.println("\t[" + curBundle.getBundleId() + "]\t" + curBundle.getSymbolicName());
console.print(Ansi.ansi().reset().toString());
}
}
} else {
console.println("No application found with name " + appName);
}
return;
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ListApplicationCommand method doExecute.
@Override
protected void doExecute(ApplicationService applicationService) throws ApplicationServiceException {
Set<Application> applications = applicationService.getApplications();
console.printf("%s%10s%n", "State", "Name");
for (Application curApp : applications) {
ApplicationStatus appStatus = applicationService.getApplicationStatus(curApp);
// aggregator 'apps')
if (!curApp.getFeatures().isEmpty()) {
console.print("[");
switch(appStatus.getState()) {
case ACTIVE:
console.print(Ansi.ansi().fg(Ansi.Color.GREEN).toString());
break;
case FAILED:
console.print(Ansi.ansi().fg(Ansi.Color.RED).toString());
break;
case INACTIVE:
// don't set a color
break;
case UNKNOWN:
console.print(Ansi.ansi().fg(Ansi.Color.YELLOW).toString());
break;
default:
break;
}
console.print(StringUtils.rightPad(appStatus.getState().toString(), STATUS_COLUMN_LENGTH));
console.print(Ansi.ansi().reset().toString());
console.println("] " + curApp.getName());
}
}
return;
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationServiceBean method convertApplicationNode.
private Map<String, Object> convertApplicationNode(ApplicationNode application) {
LOGGER.debug("Converting {} to a map", application.getApplication().getName());
Map<String, Object> appMap = new HashMap<String, Object>();
Application internalApplication = application.getApplication();
appMap.put(MAP_NAME, internalApplication.getName());
appMap.put(MAP_VERSION, internalApplication.getVersion());
appMap.put(MAP_DESCRIPTION, internalApplication.getDescription());
appMap.put(MAP_STATE, application.getStatus().getState().toString());
appMap.put(MAP_URI, internalApplication.getURI().toString());
List<Map<String, Object>> children = new ArrayList<Map<String, Object>>();
for (ApplicationNode curNode : application.getChildren()) {
children.add(convertApplicationNode(curNode));
}
appMap.put(MAP_CHILDREN, children);
return appMap;
}
Aggregations