mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testGetActiveProgramsUsingTemplate() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException
    {
        //mock data
        mockMissionProgramPersistentData();
        mockTemplates();

        setScriptEngineAndActivate();
        
        //five templates are mocked in the 'mockTemplates'
        assertThat(m_SUT.getActiveProgramTemplateNames().size(), is(6));

        //program to add
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("arg1", "test-value");
        arguments.put("arg2", 5);
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("something");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("asl");

        //load program
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        Program mission = m_SUT.loadParameters(params);

        //get active templates using the same template name, named in the program just added
        assertThat(m_SUT.getActiveProgramsUsingTemplate("test"), hasItem(mission));

        //make sure the program is not in the inactive programs
        assertThat(m_SUT.getInactiveProgramsUsingTemplate("test").contains(mission), is(false));

        //check that the newly added program is returned when all programs are requested
        assertThat(m_SUT.getPrograms(), hasItem(mission));
        //five are already created, and one was added during this test
        assertThat(m_SUT.getPrograms().size(), is(7));
    }
/**
     * Test getting active programs for a specific template.
     * 
     * Verify that all mock templates are returned for the getActivePrograms.
     * 
     * Verify the added program is the only program returned for the getActiveProgramsUsingTemplate request.
     * 
     * Validation and persistence exceptions are related to the loading process. The mission program exception
     * is thrown in the event that the initialization process fails or execution fails.
     */
Test getting active programs for a specific template.

Verify that all mock templates are returned for the getActivePrograms.

Verify the added program is the only program returned for the getActiveProgramsUsingTemplate request.

Validation and persistence exceptions are related to the loading process. The mission program exception
is thrown in the event that the initialization process fails or execution fails.
Test getting active programs for a specific template . Verify that all mock templates are returned for the getActivePrograms . Verify the added program is the only program returned for the getActiveProgramsUsingTemplate request . Validation and persistence exceptions are related to the loading process . The mission program exception is thrown in the event that the initialization process fails or execution fails .
@Test
    public void testGetActiveProgramsUsingTemplate() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException
    {
        mockMissionProgramPersistentData();
        mockTemplates();
        setScriptEngineAndActivate();
        assertThat(m_SUT.getActiveProgramTemplateNames().size(), is(6));
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("arg1", "test-value");
        arguments.put("arg2", 5);
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("something");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("asl");
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        Program mission = m_SUT.loadParameters(params);
        assertThat(m_SUT.getActiveProgramsUsingTemplate("test"), hasItem(mission));
        assertThat(m_SUT.getInactiveProgramsUsingTemplate("test").contains(mission), is(false));
        assertThat(m_SUT.getPrograms(), hasItem(mission));
        assertThat(m_SUT.getPrograms().size(), is(7));
    }
@ Test public void testGetActiveProgramsUsingTemplate ( ) throws ValidationFailedException , MissionProgramException , PersistenceFailedException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; setScriptEngineAndActivate ( ) ; assertThat ( m_SUT . getActiveProgramTemplateNames ( ) . size ( ) , is ( 6 ) ) ; Map < String , Object > arguments = new HashMap < String , Object > ( ) ; arguments . put ( "arg1" , "test-value" ) ; arguments . put ( "arg2" , 5 ) ; MissionProgramTemplate program = new MissionProgramTemplate ( ) . withName ( "test" ) . withSource ( "something" ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withImmediately ( false ) . withIndefiniteInterval ( false ) . withActive ( true ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "test" ) . withParameters ( MapTranslator . translateMap ( arguments ) ) . withSchedule ( schedule ) . withProgramName ( "asl" ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; Program mission = m_SUT . loadParameters ( params ) ; assertThat ( m_SUT . getActiveProgramsUsingTemplate ( "test" ) , hasItem ( mission ) ) ; assertThat ( m_SUT . getInactiveProgramsUsingTemplate ( "test" ) . contains ( mission ) , is ( false ) ) ; assertThat ( m_SUT . getPrograms ( ) , hasItem ( mission ) ) ; assertThat ( m_SUT . getPrograms ( ) . size ( ) , is ( 7 ) ) ; }
Test getting active programs for a specific template.
Test getting active programs for a specific template .
//mock data //five templates are mocked in the 'mockTemplates' //program to add //load program //get active templates using the same template name, named in the program just added //make sure the program is not in the inactive programs //check that the newly added program is returned when all programs are requested //five are already created, and one was added during this test