mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testGetProgram() throws IllegalArgumentException, MissionProgramException, PersistenceFailedException
    {
        setScriptEngineAndActivate();
        
        try
        {
            //test that an exception is thrown if the program does not exist.(Is null).
            m_SUT.getProgram("blah");
            fail("Expecting exception");
        }
        catch (IllegalArgumentException e)
        {
            
        }
        
        // mock
        List<PersistentData> missionPrograms = new ArrayList<PersistentData>();
        doReturn(missionPrograms).when(m_PersistentDataStore).query(MissionProgramManagerImpl.class);
        PersistentData data = mock(PersistentData.class);
        missionPrograms.add(data);
        
        // replay
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("asdf");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false);
        MissionProgramParameters params = new MissionProgramParameters().withParameters().withTemplateName("test").
            withSchedule(schedule).withProgramName("name");
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        m_SUT.loadParameters(params);
    }
/**
     * Verify program can be retrieved.
     */
Verify program can be retrieved.
Verify program can be retrieved .
@Test
    public void testGetProgram() throws IllegalArgumentException, MissionProgramException, PersistenceFailedException
    {
        setScriptEngineAndActivate();
        try
        {
            m_SUT.getProgram("blah");
            fail("Expecting exception");
        }
        catch (IllegalArgumentException e)
        {
        }
        List<PersistentData> missionPrograms = new ArrayList<PersistentData>();
        doReturn(missionPrograms).when(m_PersistentDataStore).query(MissionProgramManagerImpl.class);
        PersistentData data = mock(PersistentData.class);
        missionPrograms.add(data);
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("asdf");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false);
        MissionProgramParameters params = new MissionProgramParameters().withParameters().withTemplateName("test").
            withSchedule(schedule).withProgramName("name");
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        m_SUT.loadParameters(params);
    }
@ Test public void testGetProgram ( ) throws IllegalArgumentException , MissionProgramException , PersistenceFailedException { setScriptEngineAndActivate ( ) ; try { m_SUT . getProgram ( "blah" ) ; fail ( "Expecting exception" ) ; } catch ( IllegalArgumentException e ) { } List < PersistentData > missionPrograms = new ArrayList < PersistentData > ( ) ; doReturn ( missionPrograms ) . when ( m_PersistentDataStore ) . query ( MissionProgramManagerImpl . class ) ; PersistentData data = mock ( PersistentData . class ) ; missionPrograms . add ( data ) ; MissionProgramTemplate program = new MissionProgramTemplate ( ) . withName ( "test" ) . withSource ( "asdf" ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withImmediately ( false ) . withIndefiniteInterval ( false ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withParameters ( ) . withTemplateName ( "test" ) . withSchedule ( schedule ) . withProgramName ( "name" ) ; Set < String > templateNames = new HashSet < String > ( ) ; templateNames . add ( "test" ) ; when ( m_TemplateManager . getMissionTemplateNames ( ) ) . thenReturn ( templateNames ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; m_SUT . loadParameters ( params ) ; }
Verify program can be retrieved.
Verify program can be retrieved .
//test that an exception is thrown if the program does not exist.(Is null). // mock // replay