mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testGetInactiveProgramsUsingTemplate() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException, ScriptException
    {
        //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(false);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("name");

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

        //verify that script object is not created
        verify(m_ScriptEngine, atMost(5)).eval(eq("something"), Mockito.any(Bindings.class));

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

        //check that the inactive program is returned when all programs are requested
        assertThat(m_SUT.getPrograms(), hasItem(mission));
    }
/**
     * Test getting inactive programs for a specific template.
     * 
     * Verify that only the added program is returned for the getInactiveProgramsUsingTemplate request.
     */
Test getting inactive programs for a specific template.

Verify that only the added program is returned for the getInactiveProgramsUsingTemplate request.
Test getting inactive programs for a specific template . Verify that only the added program is returned for the getInactiveProgramsUsingTemplate request .
@Test
    public void testGetInactiveProgramsUsingTemplate() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException, ScriptException
    {
        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(false);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("name");
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        Program mission = m_SUT.loadParameters(params);
        verify(m_ScriptEngine, atMost(5)).eval(eq("something"), Mockito.any(Bindings.class));
        assertThat(m_SUT.getInactiveProgramsUsingTemplate("test"), hasItem(mission));
        assertThat(m_SUT.getActiveProgramsUsingTemplate("test").contains(mission), is(false));
        assertThat(m_SUT.getPrograms(), hasItem(mission));
    }
@ Test public void testGetInactiveProgramsUsingTemplate ( ) throws ValidationFailedException , MissionProgramException , PersistenceFailedException , ScriptException { 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 ( false ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "test" ) . withParameters ( MapTranslator . translateMap ( arguments ) ) . withSchedule ( schedule ) . withProgramName ( "name" ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; Program mission = m_SUT . loadParameters ( params ) ; verify ( m_ScriptEngine , atMost ( 5 ) ) . eval ( eq ( "something" ) , Mockito . any ( Bindings . class ) ) ; assertThat ( m_SUT . getInactiveProgramsUsingTemplate ( "test" ) , hasItem ( mission ) ) ; assertThat ( m_SUT . getActiveProgramsUsingTemplate ( "test" ) . contains ( mission ) , is ( false ) ) ; assertThat ( m_SUT . getPrograms ( ) , hasItem ( mission ) ) ; }
Test getting inactive programs for a specific template.
Test getting inactive programs for a specific template .
//mock data //five templates are mocked in the 'mockTemplates' //program to add //test getting the  //verify that script object is not created //get inactive templates using the same template name, named in the program just added //check that the inactive program is returned when all programs are requested