mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestTemplateProgramManagerImpl.java
@Test
    public void testIllegalStateLoadFromFile() throws ValidationFailedException, MalformedURLException, 
        UnmarshalException, PersistenceFailedException, URISyntaxException
    {
        //activate the manager
        m_SUT.activate(context);

        //create a template
        MissionProgramTemplate localTemplate = new MissionProgramTemplate().withName("Spider").
            withSource("ASpiderBite");
        URL url = templateUrl(localTemplate);

        //mock behavior of validator
        doThrow(new IllegalStateException()).when(m_MissionProgramValidator)
           .validate(Mockito.any(MissionProgramTemplate.class));
        
        try
        {
            m_SUT.loadFromFile(url, true);
            fail("Expected exception, as the model should fail validation!");
        }
        catch (IllegalArgumentException exception)
        {
            //expected exception
        }
    }
/**
     * Verify that if a template fails marshalling that the template is not loaded.
     */
Verify that if a template fails marshalling that the template is not loaded.
Verify that if a template fails marshalling that the template is not loaded .
@Test
    public void testIllegalStateLoadFromFile() throws ValidationFailedException, MalformedURLException, 
        UnmarshalException, PersistenceFailedException, URISyntaxException
    {
        m_SUT.activate(context);
        MissionProgramTemplate localTemplate = new MissionProgramTemplate().withName("Spider").
            withSource("ASpiderBite");
        URL url = templateUrl(localTemplate);
        doThrow(new IllegalStateException()).when(m_MissionProgramValidator)
           .validate(Mockito.any(MissionProgramTemplate.class));
        try
        {
            m_SUT.loadFromFile(url, true);
            fail("Expected exception, as the model should fail validation!");
        }
        catch (IllegalArgumentException exception)
        {
        }
    }
@ Test public void testIllegalStateLoadFromFile ( ) throws ValidationFailedException , MalformedURLException , UnmarshalException , PersistenceFailedException , URISyntaxException { m_SUT . activate ( context ) ; MissionProgramTemplate localTemplate = new MissionProgramTemplate ( ) . withName ( "Spider" ) . withSource ( "ASpiderBite" ) ; URL url = templateUrl ( localTemplate ) ; doThrow ( new IllegalStateException ( ) ) . when ( m_MissionProgramValidator ) . validate ( Mockito . any ( MissionProgramTemplate . class ) ) ; try { m_SUT . loadFromFile ( url , true ) ; fail ( "Expected exception, as the model should fail validation!" ) ; } catch ( IllegalArgumentException exception ) { } }
Verify that if a template fails marshalling that the template is not loaded.
Verify that if a template fails marshalling that the template is not loaded .
//activate the manager //create a template //mock behavior of validator //expected exception