mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testActivateAutoExecuteProg2PhysicalLinkMissing() throws ScriptException,
        IllegalArgumentException, MissionProgramException
    {
        // mock
        mockMissionProgramPersistentData();
        mockTemplates();
        
        //mock deps
        LinkLayer link = mock(LinkLayer.class);
        PhysicalLink phys = mock(PhysicalLink.class);
        
        // make others available
        when(m_CustomCommsService.isLinkLayerCreated("ll1")).thenReturn(true);
        when(m_CustomCommsService.getLinkLayer("ll1")).thenReturn(link);
        
        MissionScript missionMock = mock(MissionScript.class);
        when(m_ScriptEngine.eval(eq("test"), Mockito.any(Bindings.class))).thenReturn(new Object());
        when(((Invocable) m_ScriptEngine).getInterface(any(), eq(MissionScript.class))).thenReturn(missionMock);
        
        setScriptEngineAndActivate();
        
        // verify still not executed
        ArgumentCaptor<ScriptContext> context = ArgumentCaptor.forClass(ScriptContext.class);
        verify(m_ScriptEngine, never()).eval(eq("blah"), context.capture());
        
        // make physical link available
        List<String> plNames = new ArrayList<String>();
        plNames.add("pl5");
        when(m_CustomCommsService.getPhysicalLinkNames()).thenReturn(plNames);
        when(m_CustomCommsService.requestPhysicalLink("pl5")).thenReturn(phys);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_NAME, "pl5");
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE, "PhysicalLink");
        m_EventHandlerAnswer.getHandler().handleEvent(new Event(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED, props));
        
        // verify now called
        verify(m_ScriptEngine, times(1)).eval(eq("blah"), context.capture());
    }
/**
     * Test that the script engine will not initialize a script or execute the script until the deps are satisfied.
     * 
     * Verify that that script successfully initializes and executes once the deps (Physical Link) are satisfied.
     */
Test that the script engine will not initialize a script or execute the script until the deps are satisfied.

Verify that that script successfully initializes and executes once the deps (Physical Link) are satisfied.
Test that the script engine will not initialize a script or execute the script until the deps are satisfied . Verify that that script successfully initializes and executes once the deps ( Physical Link ) are satisfied .
@Test
    public void testActivateAutoExecuteProg2PhysicalLinkMissing() throws ScriptException,
        IllegalArgumentException, MissionProgramException
    {
        mockMissionProgramPersistentData();
        mockTemplates();
        LinkLayer link = mock(LinkLayer.class);
        PhysicalLink phys = mock(PhysicalLink.class);
        when(m_CustomCommsService.isLinkLayerCreated("ll1")).thenReturn(true);
        when(m_CustomCommsService.getLinkLayer("ll1")).thenReturn(link);
        MissionScript missionMock = mock(MissionScript.class);
        when(m_ScriptEngine.eval(eq("test"), Mockito.any(Bindings.class))).thenReturn(new Object());
        when(((Invocable) m_ScriptEngine).getInterface(any(), eq(MissionScript.class))).thenReturn(missionMock);
        setScriptEngineAndActivate();
        ArgumentCaptor<ScriptContext> context = ArgumentCaptor.forClass(ScriptContext.class);
        verify(m_ScriptEngine, never()).eval(eq("blah"), context.capture());
        List<String> plNames = new ArrayList<String>();
        plNames.add("pl5");
        when(m_CustomCommsService.getPhysicalLinkNames()).thenReturn(plNames);
        when(m_CustomCommsService.requestPhysicalLink("pl5")).thenReturn(phys);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_NAME, "pl5");
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE, "PhysicalLink");
        m_EventHandlerAnswer.getHandler().handleEvent(new Event(FactoryDescriptor.TOPIC_FACTORY_OBJ_CREATED, props));
        verify(m_ScriptEngine, times(1)).eval(eq("blah"), context.capture());
    }
@ Test public void testActivateAutoExecuteProg2PhysicalLinkMissing ( ) throws ScriptException , IllegalArgumentException , MissionProgramException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; LinkLayer link = mock ( LinkLayer . class ) ; PhysicalLink phys = mock ( PhysicalLink . class ) ; when ( m_CustomCommsService . isLinkLayerCreated ( "ll1" ) ) . thenReturn ( true ) ; when ( m_CustomCommsService . getLinkLayer ( "ll1" ) ) . thenReturn ( link ) ; MissionScript missionMock = mock ( MissionScript . class ) ; when ( m_ScriptEngine . eval ( eq ( "test" ) , Mockito . any ( Bindings . class ) ) ) . thenReturn ( new Object ( ) ) ; when ( ( ( Invocable ) m_ScriptEngine ) . getInterface ( any ( ) , eq ( MissionScript . class ) ) ) . thenReturn ( missionMock ) ; setScriptEngineAndActivate ( ) ; ArgumentCaptor < ScriptContext > context = ArgumentCaptor . forClass ( ScriptContext . class ) ; verify ( m_ScriptEngine , never ( ) ) . eval ( eq ( "blah" ) , context . capture ( ) ) ; List < String > plNames = new ArrayList < String > ( ) ; plNames . add ( "pl5" ) ; when ( m_CustomCommsService . getPhysicalLinkNames ( ) ) . thenReturn ( plNames ) ; when ( m_CustomCommsService . requestPhysicalLink ( "pl5" ) ) . thenReturn ( phys ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ_NAME , "pl5" ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ_BASE_TYPE , "PhysicalLink" ) ; m_EventHandlerAnswer . getHandler ( ) . handleEvent ( new Event ( FactoryDescriptor . TOPIC_FACTORY_OBJ_CREATED , props ) ) ; verify ( m_ScriptEngine , times ( 1 ) ) . eval ( eq ( "blah" ) , context . capture ( ) ) ; }
Test that the script engine will not initialize a script or execute the script until the deps are satisfied.
Test that the script engine will not initialize a script or execute the script until the deps are satisfied .
// mock //mock deps // make others available // verify still not executed // make physical link available // verify now called