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

        setScriptEngineAndActivate();
        
        //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)).withProgramName("Jim").withSchedule(schedule);

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

        //five templates are mocked in the 'mockTemplates'
        assertThat(m_SUT.getPrograms().size(), is(7));

        //try to load the same parameters
        try
        {
            m_SUT.loadParameters(params);
            fail("Expected exception because the name of the program overlaps with another program!");
        }
        catch (IllegalArgumentException e)
        {
            //expecting exception
        }

        //verify that the program was not recreated
        assertThat(m_SUT.getPrograms().size(), is(7));
    }
/**
     * Test loading parameters when the desired name overlaps with another program.
     * 
     * Verify IllegalArgumentException is thrown and that the new program was not created.
     */
Test loading parameters when the desired name overlaps with another program.

Verify IllegalArgumentException is thrown and that the new program was not created.
Test loading parameters when the desired name overlaps with another program . Verify IllegalArgumentException is thrown and that the new program was not created .
@Test
    public void testLoadParamsException() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException
    {
        mockMissionProgramPersistentData();
        mockTemplates();
        setScriptEngineAndActivate();
        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)).withProgramName("Jim").withSchedule(schedule);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        m_SUT.loadParameters(params);
        assertThat(m_SUT.getPrograms().size(), is(7));
        try
        {
            m_SUT.loadParameters(params);
            fail("Expected exception because the name of the program overlaps with another program!");
        }
        catch (IllegalArgumentException e)
        {
        }
        assertThat(m_SUT.getPrograms().size(), is(7));
    }
@ Test public void testLoadParamsException ( ) throws ValidationFailedException , MissionProgramException , PersistenceFailedException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; setScriptEngineAndActivate ( ) ; 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 ) ) . withProgramName ( "Jim" ) . withSchedule ( schedule ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; m_SUT . loadParameters ( params ) ; assertThat ( m_SUT . getPrograms ( ) . size ( ) , is ( 7 ) ) ; try { m_SUT . loadParameters ( params ) ; fail ( "Expected exception because the name of the program overlaps with another program!" ) ; } catch ( IllegalArgumentException e ) { } assertThat ( m_SUT . getPrograms ( ) . size ( ) , is ( 7 ) ) ; }
Test loading parameters when the desired name overlaps with another program.
Test loading parameters when the desired name overlaps with another program .
//mock data //program to add //test getting the  //five templates are mocked in the 'mockTemplates' //try to load the same parameters //expecting exception //verify that the program was not recreated