use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationServiceImplTest method testGetActiveApplicationStatus.
/**
* Tests receiving application status for an application in the ACTIVE
* state.
*/
@Test
public void testGetActiveApplicationStatus() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
Set<Application> applications = appService.getApplications();
assertEquals(1, applications.size());
for (Application curApp : applications) {
ApplicationStatus status = appService.getApplicationStatus(curApp);
assertEquals(curApp, status.getApplication());
assertEquals(ApplicationState.ACTIVE, status.getState());
assertTrue(status.getErrorBundles().isEmpty());
assertTrue(status.getErrorFeatures().isEmpty());
}
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class TreeApplicationCommandTest method testTreeApplicationCommand.
/**
* Tests the {@link TreeApplicationCommand} class and its associated methods
*
* @throws Exception
*/
@Test
public void testTreeApplicationCommand() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
TreeApplicationCommand treeApplicationCommand = new TreeApplicationCommand();
Set<ApplicationNode> treeSet = new TreeSet<>();
ApplicationNode testNode1 = mock(ApplicationNodeImpl.class);
ApplicationNode testNode2 = mock(ApplicationNodeImpl.class);
treeSet.add(testNode1);
Set<ApplicationNode> childSet = new TreeSet<>();
childSet.add(testNode2);
Application testApp = mock(ApplicationImpl.class);
when(testApp.getName()).thenReturn("TestApp");
when(testNode1.getApplication()).thenReturn(testApp);
when(testNode2.getApplication()).thenReturn(testApp);
when(testNode2.getChildren()).thenReturn(new TreeSet<ApplicationNode>());
when(testNode1.getChildren()).thenReturn(childSet);
when(testAppService.getApplicationTree()).thenReturn(treeSet);
treeApplicationCommand.doExecute(testAppService);
verify(testAppService).getApplicationTree();
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class AllApplicationsCompleterTest method testAllApplicationsCompleter.
/**
* Tests the {@link AllApplicationsCompleter#complete(String, int, List)} method,
* and the {@link AllApplicationsCompleter#AllApplicationsCompleter(ApplicationService)} constructor
*/
@Test
public void testAllApplicationsCompleter() {
Application testApp = mock(ApplicationImpl.class);
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
Set<Application> testAppSet = new HashSet<>();
testAppSet.add(testApp);
when(testAppService.getApplications()).thenReturn(testAppSet);
when(testApp.getName()).thenReturn("TestApp");
AllApplicationsCompleter applicationsCompleter = new AllApplicationsCompleter();
applicationsCompleter.setApplicationService(testAppService);
assertThat("If the return value is -1, the expected match was not found.", applicationsCompleter.complete(null, commandLine, new ArrayList<>()), is(not(-1)));
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationNodeImplTest method testApplicationNodeImplConstructorAppParam.
/**
* Tests the {@link ApplicationNodeImpl#ApplicationNodeImpl(Application)} constructor
* for the case where the application exists
*/
@Test
public void testApplicationNodeImplConstructorAppParam() {
Application testApp = mock(Application.class);
ApplicationNode testNode = new ApplicationNodeImpl(testApp);
assertEquals(testApp, testNode.getApplication());
}
use of org.codice.ddf.admin.application.service.Application in project ddf by codice.
the class ApplicationNodeImplTest method testStatus.
/**
* Tests the getStatus() method to make sure it returns the correct
* value(s) after initialization, and after a new status has been
* set via setStatus()
*/
@Test
public void testStatus() {
Application testApp = mock(Application.class);
when(testApp.getName()).thenReturn(APP_NAME);
when(testApp.getVersion()).thenReturn(APP_VERSION);
when(testApp.getDescription()).thenReturn(APP_DESCRIPTION);
ApplicationStatusImpl testStatus = mock(ApplicationStatusImpl.class);
ApplicationStatusImpl testStatus2 = mock(ApplicationStatusImpl.class);
ApplicationNodeImpl testNode = new ApplicationNodeImpl(testApp, testStatus);
assertEquals(testStatus, testNode.getStatus());
testNode.setStatus(testStatus2);
assertEquals(testStatus2, testNode.getStatus());
}
Aggregations