mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testUpgradeScriptLoaded() throws MalformedURLException
    {
        // Test upgrade script load error
        m_SUT = new MissionProgramManagerImpl();        
        setupStandardMocks(); 
        when(m_Bundle.getEntry("nashornUpgrade.js")).thenReturn(null);        
      
        try
        {
            setScriptEngineAndActivate();
            fail();
        }
        catch (IllegalStateException e)
        {
            //Expected exception
            assertThat(e.getClass().equals(IllegalStateException.class), is(true));
        }

        // Test successful loading of upgrade script
        m_SUT = new MissionProgramManagerImpl();        
        setupStandardMocks();         
        when(m_Bundle.getEntry("nashornUpgrade.js")).thenReturn(new URL("file:.//resources//nashornUpgrade.js"));
        mockBindings();
        setScriptEngineAndActivate();
        
        //program to add       
        MissionProgramTemplate program2 = new MissionProgramTemplate().withName("testPass").withSource("testPass");
        MissionProgramSchedule schedule2 = new MissionProgramSchedule().withImmediately(true).
                withIndefiniteInterval(false).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withParameters().withTemplateName("testPass").
                withSchedule(schedule2).withProgramName("testPass");

        //add template
        Set<String> templateNames2 = new HashSet<String>();
        templateNames2.add("testPass");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames2);
        doReturn(program2).when(m_TemplateManager).getTemplate("testPass"); 
        
        Program returnedProg = m_SUT.loadParameters(params);        
        assertThat(returnedProg.getProgramStatus().equals(ProgramStatus.INITIALIZATION_ERROR), is(false));

    }
/**
     * Verifies that the Java 8 upgrade script can be loaded, and it fails if not loaded.
     */
Verifies that the Java 8 upgrade script can be loaded, and it fails if not loaded.
Verifies that the Java 8 upgrade script can be loaded and it fails if not loaded .
@Test
    public void testUpgradeScriptLoaded() throws MalformedURLException
    {
        m_SUT = new MissionProgramManagerImpl();        
        setupStandardMocks(); 
        when(m_Bundle.getEntry("nashornUpgrade.js")).thenReturn(null);        
        try
        {
            setScriptEngineAndActivate();
            fail();
        }
        catch (IllegalStateException e)
        {
            assertThat(e.getClass().equals(IllegalStateException.class), is(true));
        }
        m_SUT = new MissionProgramManagerImpl();        
        setupStandardMocks();         
        when(m_Bundle.getEntry("nashornUpgrade.js")).thenReturn(new URL("file:.//resources//nashornUpgrade.js"));
        mockBindings();
        setScriptEngineAndActivate();
        MissionProgramTemplate program2 = new MissionProgramTemplate().withName("testPass").withSource("testPass");
        MissionProgramSchedule schedule2 = new MissionProgramSchedule().withImmediately(true).
                withIndefiniteInterval(false).withActive(true);
        MissionProgramParameters params = new MissionProgramParameters().withParameters().withTemplateName("testPass").
                withSchedule(schedule2).withProgramName("testPass");
        Set<String> templateNames2 = new HashSet<String>();
        templateNames2.add("testPass");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames2);
        doReturn(program2).when(m_TemplateManager).getTemplate("testPass"); 
        Program returnedProg = m_SUT.loadParameters(params);        
        assertThat(returnedProg.getProgramStatus().equals(ProgramStatus.INITIALIZATION_ERROR), is(false));
    }
@ Test public void testUpgradeScriptLoaded ( ) throws MalformedURLException { m_SUT = new MissionProgramManagerImpl ( ) ; setupStandardMocks ( ) ; when ( m_Bundle . getEntry ( "nashornUpgrade.js" ) ) . thenReturn ( null ) ; try { setScriptEngineAndActivate ( ) ; fail ( ) ; } catch ( IllegalStateException e ) { assertThat ( e . getClass ( ) . equals ( IllegalStateException . class ) , is ( true ) ) ; } m_SUT = new MissionProgramManagerImpl ( ) ; setupStandardMocks ( ) ; when ( m_Bundle . getEntry ( "nashornUpgrade.js" ) ) . thenReturn ( new URL ( "file:.//resources//nashornUpgrade.js" ) ) ; mockBindings ( ) ; setScriptEngineAndActivate ( ) ; MissionProgramTemplate program2 = new MissionProgramTemplate ( ) . withName ( "testPass" ) . withSource ( "testPass" ) ; MissionProgramSchedule schedule2 = new MissionProgramSchedule ( ) . withImmediately ( true ) . withIndefiniteInterval ( false ) . withActive ( true ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withParameters ( ) . withTemplateName ( "testPass" ) . withSchedule ( schedule2 ) . withProgramName ( "testPass" ) ; Set < String > templateNames2 = new HashSet < String > ( ) ; templateNames2 . add ( "testPass" ) ; when ( m_TemplateManager . getMissionTemplateNames ( ) ) . thenReturn ( templateNames2 ) ; doReturn ( program2 ) . when ( m_TemplateManager ) . getTemplate ( "testPass" ) ; Program returnedProg = m_SUT . loadParameters ( params ) ; assertThat ( returnedProg . getProgramStatus ( ) . equals ( ProgramStatus . INITIALIZATION_ERROR ) , is ( false ) ) ; }
Verifies that the Java 8 upgrade script can be loaded, and it fails if not loaded.
Verifies that the Java 8 upgrade script can be loaded and it fails if not loaded .
// Test upgrade script load error //Expected exception // Test successful loading of upgrade script //program to add        //add template