use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testStopApplicationNoMainFeatureStringParam.
/**
* Tests the {@link ApplicationServiceImpl#stopApplication(String)} method
* for the case where there is no main feature, but other features exist
*
* @throws Exception
*/
@Test
public void testStopApplicationNoMainFeatureStringParam() 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();
Feature[] featureList = noMainFeatureRepo1.getFeatures();
appService.stopApplication(TEST_APP);
verify(featuresService).uninstallFeature(featureList[0].getName(), featureList[0].getVersion(), EnumSet.of(Option.NoAutoRefreshBundles));
verify(featuresService).uninstallFeature(featureList[1].getName(), featureList[1].getVersion(), EnumSet.of(Option.NoAutoRefreshBundles));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testGetApplications.
/**
* Tests that the {@link ApplicationServiceImpl#getApplications()} method
* returns the correct number of applications.
*
* @throws Exception
*/
@Test
public void testGetApplications() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(noMainFeatureRepo1, noMainFeatureRepo2));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
Set<Application> applications = appService.getApplications();
assertNotNull(applications);
assertEquals(2, applications.size());
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testFindFeatureExceptions.
/**
* Tests the {@link ApplicationServiceImpl#findFeature(Feature)} method
* for the case where exceptions are thrown inside findFeature(Feature, Set<Application>)
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix and un-ignore
@Test
@Ignore
public void testFindFeatureExceptions() throws Exception {
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);
Application testApp = mock(ApplicationImpl.class);
final Set<Application> applicationSet = new HashSet<>();
applicationSet.add(testApp);
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = new ApplicationServiceImpl(bundleStateServices) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
@Override
public Set<Application> getApplications() {
return applicationSet;
}
@Override
public boolean isPermittedToViewFeature(String featureName) {
return true;
}
};
Feature testFeature = mock(Feature.class);
doThrow(new NullPointerException()).when(testApp).getFeatures();
appService.findFeature(testFeature);
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(FIND_FEAT_EX);
}
}));
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(FIND_FEAT_EX2);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testApplicationTreeWithNoMainFeature.
/**
* Test that an application tree can be created even if there is an app that
* does not contain a main feature.
*
* @throws Exception
*/
@Test
public void testApplicationTreeWithNoMainFeature() throws Exception {
Repository mainFeaturesRepo2 = createRepo(TEST_MAIN_FEATURE_2_FILE_NAME);
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, mainFeaturesRepo2, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
Set<ApplicationNode> rootApps = appService.getApplicationTree();
assertNotNull(rootApps);
assertEquals(2, rootApps.size());
}
use of org.codice.ddf.admin.application.service.ApplicationService 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());
}
}
Aggregations