mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testActivateAutoExecuteProg2LinkLayerMissing() throws ScriptException,
        IllegalArgumentException, MissionProgramException
    {
        // mock
        mockMissionProgramPersistentData();
        mockTemplates();
        
        //mock deps
        LinkLayer link = mock(LinkLayer.class);
        PhysicalLink phys = mock(PhysicalLink.class);
        
        // make others available
        List<String> plNames = new ArrayList<String>();
        plNames.add("pl5");
        when(m_CustomCommsService.getPhysicalLinkNames()).thenReturn(plNames);
        when(m_CustomCommsService.requestPhysicalLink("pl5")).thenReturn(phys);
        Set<String> isoNames = new HashSet<String>();
        isoNames.add("iso0");
        isoNames.add("iso1");
        
        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 link layer available
        when(m_CustomCommsService.isLinkLayerCreated("ll1")).thenReturn(true);
        when(m_CustomCommsService.getLinkLayer("ll1")).thenReturn(link);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_NAME, "ll1");
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE, "LinkLayer");
        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 (Link layer) 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 (Link layer) 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 ( Link layer ) are satisfied .
@Test
    public void testActivateAutoExecuteProg2LinkLayerMissing() throws ScriptException,
        IllegalArgumentException, MissionProgramException
    {
        mockMissionProgramPersistentData();
        mockTemplates();
        LinkLayer link = mock(LinkLayer.class);
        PhysicalLink phys = mock(PhysicalLink.class);
        List<String> plNames = new ArrayList<String>();
        plNames.add("pl5");
        when(m_CustomCommsService.getPhysicalLinkNames()).thenReturn(plNames);
        when(m_CustomCommsService.requestPhysicalLink("pl5")).thenReturn(phys);
        Set<String> isoNames = new HashSet<String>();
        isoNames.add("iso0");
        isoNames.add("iso1");
        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());
        when(m_CustomCommsService.isLinkLayerCreated("ll1")).thenReturn(true);
        when(m_CustomCommsService.getLinkLayer("ll1")).thenReturn(link);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_NAME, "ll1");
        props.put(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE, "LinkLayer");
        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 testActivateAutoExecuteProg2LinkLayerMissing ( ) throws ScriptException , IllegalArgumentException , MissionProgramException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; LinkLayer link = mock ( LinkLayer . class ) ; PhysicalLink phys = mock ( PhysicalLink . class ) ; List < String > plNames = new ArrayList < String > ( ) ; plNames . add ( "pl5" ) ; when ( m_CustomCommsService . getPhysicalLinkNames ( ) ) . thenReturn ( plNames ) ; when ( m_CustomCommsService . requestPhysicalLink ( "pl5" ) ) . thenReturn ( phys ) ; Set < String > isoNames = new HashSet < String > ( ) ; isoNames . add ( "iso0" ) ; isoNames . add ( "iso1" ) ; 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 ( ) ) ; when ( m_CustomCommsService . isLinkLayerCreated ( "ll1" ) ) . thenReturn ( true ) ; when ( m_CustomCommsService . getLinkLayer ( "ll1" ) ) . thenReturn ( link ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ_NAME , "ll1" ) ; props . put ( FactoryDescriptor . EVENT_PROP_OBJ_BASE_TYPE , "LinkLayer" ) ; 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 link layer available // verify now called