use of org.codice.ddf.admin.application.service.ApplicationNode in project ddf by codice.
the class ApplicationServiceBeanTest method testGetApplicationsMultiChildDependencies.
/**
* Tests the {@link ApplicationServiceBean#getApplications()} method for the case where
* more than one child node has dependencies
*
* @throws Exception
*/
@Test
public void testGetApplicationsMultiChildDependencies() throws Exception {
setUpTree();
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
serviceBean.init();
ApplicationNode testNode4 = mock(ApplicationNodeImpl.class);
when(testNode4.getApplication()).thenReturn(testApp);
when(testNode4.getStatus()).thenReturn(testStatus);
Set<ApplicationNode> testNode1ChildrenSet = new TreeSet<>();
testNode1ChildrenSet.add(testNode2);
testNode1ChildrenSet.add(testNode4);
when(testNode1.getChildren()).thenReturn(testNode1ChildrenSet);
List<Map<String, Object>> result = serviceBean.getApplications();
assertThat("Should return the applications set up previously.", (String) result.get(0).get("name"), is(TEST_APP_NAME));
assertThat("Size of root should be three.", result.size(), is(3));
}
use of org.codice.ddf.admin.application.service.ApplicationNode in project ddf by codice.
the class ApplicationServiceBeanTest method testGetApplicationsChildDependencies.
/**
* Tests the {@link ApplicationServiceBean#getApplications()} method for the case where
* a child node has dependencies
*
* @throws Exception
*/
@Test
public void testGetApplicationsChildDependencies() throws Exception {
setUpTree();
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
serviceBean.init();
ApplicationNode testNode4 = mock(ApplicationNodeImpl.class);
when(testNode4.getApplication()).thenReturn(testApp);
when(testNode4.getStatus()).thenReturn(testStatus);
Set<ApplicationNode> testNode3ChildrenSet = new TreeSet<>();
testNode3ChildrenSet.add(testNode4);
when(testNode3.getChildren()).thenReturn(testNode3ChildrenSet);
List<Map<String, Object>> result = serviceBean.getApplications();
assertThat("Should return the applications set up previously.", (String) result.get(0).get("name"), is(TEST_APP_NAME));
assertThat("Size of root should be three.", result.size(), is(3));
}
use of org.codice.ddf.admin.application.service.ApplicationNode 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.ApplicationNode in project ddf by codice.
the class TreeApplicationCommand method printNode.
private void printNode(ApplicationNode appNode, String appender) {
PrintStream console = System.out;
String appendStr = appender;
console.println(appendStr + "+- " + appNode.getApplication().getName());
appendStr += "| ";
for (ApplicationNode curChild : appNode.getChildren()) {
printNode(curChild, appendStr);
}
}
use of org.codice.ddf.admin.application.service.ApplicationNode 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