use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class AllApplicationsCompleterTest method testAllApplicationsCompleterNullAppService.
/**
* Tests the {@link AllApplicationsCompleter#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 testAllApplicationsCompleterNullAppService() {
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;
AllApplicationsCompleter allApplicationsCompleter = new AllApplicationsCompleter();
allApplicationsCompleter.setApplicationService(testAppService);
allApplicationsCompleter.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 StartApplicationCommandTest method testStartApplicationCommand.
/**
* Tests the {@link StartApplicationCommand} class and its associated methods
*
* @throws Exception
*/
@Test
public void testStartApplicationCommand() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
StartApplicationCommand startApplicationCommand = new StartApplicationCommand();
startApplicationCommand.appName = APP_NAME;
startApplicationCommand.doExecute(testAppService);
verify(testAppService).startApplication(APP_NAME);
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testGetAllFeaturesFTRException.
/**
* Tests the {@link ApplicationServiceImpl#getAllFeatures()} method for the case where an
* exception is thrown in getFeatureToRepository(..)
*/
@Test
public void testGetAllFeaturesFTRException() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl(featuresService);
doThrow(new NullPointerException()).when(featuresService).listRepositories();
List<FeatureDetails> details = appService.getAllFeatures();
assertThat("List of feature details should have 7 entries", details, hasSize(4));
details.forEach(d -> assertThat(d.getName() + " should not have a mapped repository", d.getRepository(), is(nullValue())));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testGetInstallProfilesException.
/**
* Tests the {@link ApplicationServiceImpl#getInstallationProfiles()} method for the case where
* featuresService.listFeatures() throws an exception
*/
@Test
public void testGetInstallProfilesException() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = new ApplicationServiceImpl(featuresService, new Security()) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
};
doThrow(new NullPointerException()).when(featuresService).listFeatures();
assertThat("No installation profiles should of been found, expected an empty collection", appService.getInstallationProfiles(), is(empty()));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class AddApplicationCommandTest method testAddApplicationCommand.
/**
* Tests the {@link AddApplicationCommand} class and its contained methods
*
* @Throws Exception
*/
@Test
public void testAddApplicationCommand() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
AddApplicationCommand addApplicationCommand = new AddApplicationCommand();
addApplicationCommand.appName = "TestApp";
addApplicationCommand.doExecute(testAppService);
verify(testAppService).addApplication(any(URI.class));
}
Aggregations