mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testIllegalArgException() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException
    {
        //mock exception response of a failed validation
        doThrow(new ValidationFailedException()).when(m_MissionProgramValidator)
            .validate(Mockito.any(MissionProgramTemplate.class));
        
        //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);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule);
         
        //mocking
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        try
        {
            m_SUT.loadParameters(params);
            fail("Expected Exception");
        }
        catch (IllegalArgumentException e)
        {
            //expected exception
        }
    }
/**
     * Test a mission program loaded that does not have a valid xml template.
     * Verify exception.
     */
Test a mission program loaded that does not have a valid xml template.
Verify exception.
Test a mission program loaded that does not have a valid xml template . Verify exception .
@Test
    public void testIllegalArgException() throws ValidationFailedException, MissionProgramException, 
        PersistenceFailedException
    {
        doThrow(new ValidationFailedException()).when(m_MissionProgramValidator)
            .validate(Mockito.any(MissionProgramTemplate.class));
        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);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule);
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        try
        {
            m_SUT.loadParameters(params);
            fail("Expected Exception");
        }
        catch (IllegalArgumentException e)
        {
        }
    }
@ Test public void testIllegalArgException ( ) throws ValidationFailedException , MissionProgramException , PersistenceFailedException { doThrow ( new ValidationFailedException ( ) ) . when ( m_MissionProgramValidator ) . validate ( Mockito . any ( MissionProgramTemplate . class ) ) ; 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 ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "test" ) . withParameters ( MapTranslator . translateMap ( arguments ) ) . withSchedule ( schedule ) ; Set < String > templateNames = new HashSet < String > ( ) ; templateNames . add ( "test" ) ; when ( m_TemplateManager . getMissionTemplateNames ( ) ) . thenReturn ( templateNames ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; try { m_SUT . loadParameters ( params ) ; fail ( "Expected Exception" ) ; } catch ( IllegalArgumentException e ) { } }
Test a mission program loaded that does not have a valid xml template.
Test a mission program loaded that does not have a valid xml template .
//mock exception response of a failed validation //program to add //mocking //expected exception