Search in sources :

Example 16 with Application

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());
    }
}
Also used : Repository(org.apache.karaf.features.Repository) ApplicationStatus(org.codice.ddf.admin.application.service.ApplicationStatus) FeaturesService(org.apache.karaf.features.FeaturesService) Application(org.codice.ddf.admin.application.service.Application) HashSet(java.util.HashSet) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) Test(org.junit.Test)

Example 17 with Application

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();
}
Also used : TreeSet(java.util.TreeSet) ApplicationNode(org.codice.ddf.admin.application.service.ApplicationNode) Application(org.codice.ddf.admin.application.service.Application) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) Test(org.junit.Test)

Example 18 with Application

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)));
}
Also used : ArrayList(java.util.ArrayList) Application(org.codice.ddf.admin.application.service.Application) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with Application

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());
}
Also used : ApplicationNode(org.codice.ddf.admin.application.service.ApplicationNode) Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Example 20 with Application

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());
}
Also used : Application(org.codice.ddf.admin.application.service.Application) Test(org.junit.Test)

Aggregations

Application (org.codice.ddf.admin.application.service.Application)55 Test (org.junit.Test)43 HashSet (java.util.HashSet)28 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)26 Repository (org.apache.karaf.features.Repository)21 FeaturesService (org.apache.karaf.features.FeaturesService)19 Feature (org.apache.karaf.features.Feature)14 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)13 ApplicationStatus (org.codice.ddf.admin.application.service.ApplicationStatus)13 ApplicationNode (org.codice.ddf.admin.application.service.ApplicationNode)11 ArrayList (java.util.ArrayList)9 RepositoryImpl (org.apache.karaf.features.internal.service.RepositoryImpl)7 HashMap (java.util.HashMap)5 Logger (org.slf4j.Logger)5 Appender (ch.qos.logback.core.Appender)4 URI (java.net.URI)4 TreeSet (java.util.TreeSet)4 ArgumentMatcher (org.mockito.ArgumentMatcher)4 Mockito.anyString (org.mockito.Mockito.anyString)4 SecurityServiceException (ddf.security.service.SecurityServiceException)3