use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testIsApplicationStartedReturnsTrueForActiveApplicationState.
/**
* Test method for
* {@link ApplicationServiceImpl#isApplicationStarted(Application)}
* <p>
* Verifies that method returns true when application state is
* {@link ApplicationState#ACTIVE}
*
* @throws Exception
*/
@Test
public void testIsApplicationStartedReturnsTrueForActiveApplicationState() throws Exception {
FeaturesService featuresService = createMockFeaturesService(mainFeatureRepo, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
assertTrue(appService.isApplicationStarted(appService.getApplication(TEST_MAIN_FEATURES_1_MAIN_FEATURE_NAME)));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testStopApplicationStringParamASE.
/**
* Tests the {@link ApplicationServiceImpl#stopApplication(String)} method
* for the case where the application cannot be found
*/
@Test(expected = ApplicationServiceException.class)
public void testStopApplicationStringParamASE() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1, noMainFeatureRepo2));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
appService.stopApplication("");
}
use of org.codice.ddf.admin.application.service.ApplicationService 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.ApplicationService in project ddf by codice.
the class ActiveApplicationsCompleterTest method testActiveApplicationsCompleterNullAppService.
/**
* Tests the {@link ActiveApplicationsCompleter#complete(String, int, List)} method
* for the case where the ApplicationService given to it is null
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testActiveApplicationsCompleterNullAppService() {
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);
ApplicationService testAppService = null;
ActiveApplicationsCompleter activeApplicationsCompleter = new ActiveApplicationsCompleter();
activeApplicationsCompleter.complete(null, commandLine, new ArrayList<>());
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(NO_APP_SERV);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationService 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)));
}
Aggregations