mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testActivate() 
        throws IllegalArgumentException, MissionProgramException, ScriptException
    {
        // mock
        mockMissionProgramPersistentData();
        mockTemplates();
        
        // replay
        setScriptEngineAndActivate();
        
        // verify copying of base bindings
        verify(m_ScriptEngine).put(MissionProgramManager.BUNDLE_CONTEXT, m_Context);
        verify(m_ScriptEngine).put(MissionProgramManager.ASSET_DIRECTORY_SERVICE, m_AssetDirectoryService);
        verify(m_ScriptEngine).put(MissionProgramManager.CUSTOM_COMMS_SERVICE, m_CustomCommsService);
        verify(m_ScriptEngine).put(MissionProgramManager.ADDRESS_MANAGER_SERVICE, m_AddressManagerService);
        ArgumentCaptor<Object> service = ArgumentCaptor.forClass(Object.class);
        verify(m_ScriptEngine).put(eq(MissionProgramManager.LOGGING_SERVICE), service.capture());
        assertThat(service.getValue(), is(instanceOf(LoggingService.class)));
        verify(m_ScriptEngine).put(MissionProgramManager.EVENT_HANDLER_HELPER, m_EventHandlerHelper);
        verify(m_ScriptEngine).put(MissionProgramManager.OBSERVATION_STORE, m_ObservationStore);
        verify(m_ScriptEngine).put(MissionProgramManager.PERSISTENT_DATA_STORE, m_PersistentDataStore);
        verify(m_ScriptEngine).put(MissionProgramManager.MISSION_PROGRAM_MANAGER, m_SUT);
        verify(m_ScriptEngine).put(MissionProgramManager.MANAGED_EXECUTORS, m_ManagedExecutors);
        verify(m_ScriptEngine).put(MissionProgramManager.TERRA_HARVEST_SYSTEM, m_TerraHarvestSystem);
        verify(m_ScriptEngine).put(MissionProgramManager.TERRA_HARVEST_CONTROLLER, m_TerraHarvestController);
        verify(m_ScriptEngine).put(MissionProgramManager.XML_MARSHAL_SERVICE, m_XMLMarshalService);
        verify(m_ScriptEngine).put(MissionProgramManager.XML_UNMARSHAL_SERVICE, m_XMLUnmarshalService);
        verify(m_ScriptEngine).put(MissionProgramManager.JAXB_PROTO_OBJECT_CONVERTER,    
                m_JaxbProtoObjectConverter);
        verify(m_ScriptEngine).put(MissionProgramManager.META_TYPE_SERVICE, m_MetaTypeService);
        verify(m_ScriptEngine).put(MissionProgramManager.VALIDATOR, m_Validator);
        
        assertThat(m_SUT.getActiveProgramTemplateNames().size(), greaterThan(1));
                
        // verify restoring of programs
        Set<Program> programs =  m_SUT.getActiveProgramsUsingTemplate("saved-program1");
        assertThat(programs.size(), is(1));
        Program program1 = programs.iterator().next();
        assertThat(program1.getSource(), is("test"));
        assertThat(program1.getFactoryObjectDeps(Asset.class).size(), is(2));
        assertThat(program1.getFactoryObjectDeps(Asset.class), hasItem("assetX"));
        assertThat(program1.getFactoryObjectDeps(Asset.class), hasItem("assetZ"));
        assertThat(program1.getFactoryObjectDeps(TransportLayer.class).size(), is(1));
        assertThat(program1.getFactoryObjectDeps(TransportLayer.class), hasItem("tl7"));
        assertThat(program1.getProgramDeps().size(), is(1));
        assertThat(program1.getProgramDeps(), hasItem("saved-program5"));
        //check that values are as expected.
        programs =  m_SUT.getActiveProgramsUsingTemplate("saved-program2");
        assertThat(programs.size(), is(1));
        Program program2 = programs.iterator().next();
        assertThat(program2.getSource(), is("blah"));
        assertThat(program2.getFactoryObjectDeps(PhysicalLink.class).size(), is(1));
        assertThat(program2.getFactoryObjectDeps(PhysicalLink.class), hasItem("pl5"));
        assertThat(program2.getFactoryObjectDeps(LinkLayer.class).size(), is(1));
        assertThat(program2.getFactoryObjectDeps(LinkLayer.class), hasItem("ll1"));
    }
/**
     * Verify that MPM activates correctly.
     */
Verify that MPM activates correctly.
Verify that MPM activates correctly .
@Test
    public void testActivate() 
        throws IllegalArgumentException, MissionProgramException, ScriptException
    {
        mockMissionProgramPersistentData();
        mockTemplates();
        setScriptEngineAndActivate();
        verify(m_ScriptEngine).put(MissionProgramManager.BUNDLE_CONTEXT, m_Context);
        verify(m_ScriptEngine).put(MissionProgramManager.ASSET_DIRECTORY_SERVICE, m_AssetDirectoryService);
        verify(m_ScriptEngine).put(MissionProgramManager.CUSTOM_COMMS_SERVICE, m_CustomCommsService);
        verify(m_ScriptEngine).put(MissionProgramManager.ADDRESS_MANAGER_SERVICE, m_AddressManagerService);
        ArgumentCaptor<Object> service = ArgumentCaptor.forClass(Object.class);
        verify(m_ScriptEngine).put(eq(MissionProgramManager.LOGGING_SERVICE), service.capture());
        assertThat(service.getValue(), is(instanceOf(LoggingService.class)));
        verify(m_ScriptEngine).put(MissionProgramManager.EVENT_HANDLER_HELPER, m_EventHandlerHelper);
        verify(m_ScriptEngine).put(MissionProgramManager.OBSERVATION_STORE, m_ObservationStore);
        verify(m_ScriptEngine).put(MissionProgramManager.PERSISTENT_DATA_STORE, m_PersistentDataStore);
        verify(m_ScriptEngine).put(MissionProgramManager.MISSION_PROGRAM_MANAGER, m_SUT);
        verify(m_ScriptEngine).put(MissionProgramManager.MANAGED_EXECUTORS, m_ManagedExecutors);
        verify(m_ScriptEngine).put(MissionProgramManager.TERRA_HARVEST_SYSTEM, m_TerraHarvestSystem);
        verify(m_ScriptEngine).put(MissionProgramManager.TERRA_HARVEST_CONTROLLER, m_TerraHarvestController);
        verify(m_ScriptEngine).put(MissionProgramManager.XML_MARSHAL_SERVICE, m_XMLMarshalService);
        verify(m_ScriptEngine).put(MissionProgramManager.XML_UNMARSHAL_SERVICE, m_XMLUnmarshalService);
        verify(m_ScriptEngine).put(MissionProgramManager.JAXB_PROTO_OBJECT_CONVERTER,    
                m_JaxbProtoObjectConverter);
        verify(m_ScriptEngine).put(MissionProgramManager.META_TYPE_SERVICE, m_MetaTypeService);
        verify(m_ScriptEngine).put(MissionProgramManager.VALIDATOR, m_Validator);
        assertThat(m_SUT.getActiveProgramTemplateNames().size(), greaterThan(1));
        Set<Program> programs =  m_SUT.getActiveProgramsUsingTemplate("saved-program1");
        assertThat(programs.size(), is(1));
        Program program1 = programs.iterator().next();
        assertThat(program1.getSource(), is("test"));
        assertThat(program1.getFactoryObjectDeps(Asset.class).size(), is(2));
        assertThat(program1.getFactoryObjectDeps(Asset.class), hasItem("assetX"));
        assertThat(program1.getFactoryObjectDeps(Asset.class), hasItem("assetZ"));
        assertThat(program1.getFactoryObjectDeps(TransportLayer.class).size(), is(1));
        assertThat(program1.getFactoryObjectDeps(TransportLayer.class), hasItem("tl7"));
        assertThat(program1.getProgramDeps().size(), is(1));
        assertThat(program1.getProgramDeps(), hasItem("saved-program5"));
        programs =  m_SUT.getActiveProgramsUsingTemplate("saved-program2");
        assertThat(programs.size(), is(1));
        Program program2 = programs.iterator().next();
        assertThat(program2.getSource(), is("blah"));
        assertThat(program2.getFactoryObjectDeps(PhysicalLink.class).size(), is(1));
        assertThat(program2.getFactoryObjectDeps(PhysicalLink.class), hasItem("pl5"));
        assertThat(program2.getFactoryObjectDeps(LinkLayer.class).size(), is(1));
        assertThat(program2.getFactoryObjectDeps(LinkLayer.class), hasItem("ll1"));
    }
@ Test public void testActivate ( ) throws IllegalArgumentException , MissionProgramException , ScriptException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; setScriptEngineAndActivate ( ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . BUNDLE_CONTEXT , m_Context ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . ASSET_DIRECTORY_SERVICE , m_AssetDirectoryService ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . CUSTOM_COMMS_SERVICE , m_CustomCommsService ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . ADDRESS_MANAGER_SERVICE , m_AddressManagerService ) ; ArgumentCaptor < Object > service = ArgumentCaptor . forClass ( Object . class ) ; verify ( m_ScriptEngine ) . put ( eq ( MissionProgramManager . LOGGING_SERVICE ) , service . capture ( ) ) ; assertThat ( service . getValue ( ) , is ( instanceOf ( LoggingService . class ) ) ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . EVENT_HANDLER_HELPER , m_EventHandlerHelper ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . OBSERVATION_STORE , m_ObservationStore ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . PERSISTENT_DATA_STORE , m_PersistentDataStore ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . MISSION_PROGRAM_MANAGER , m_SUT ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . MANAGED_EXECUTORS , m_ManagedExecutors ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . TERRA_HARVEST_SYSTEM , m_TerraHarvestSystem ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . TERRA_HARVEST_CONTROLLER , m_TerraHarvestController ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . XML_MARSHAL_SERVICE , m_XMLMarshalService ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . XML_UNMARSHAL_SERVICE , m_XMLUnmarshalService ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . JAXB_PROTO_OBJECT_CONVERTER , m_JaxbProtoObjectConverter ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . META_TYPE_SERVICE , m_MetaTypeService ) ; verify ( m_ScriptEngine ) . put ( MissionProgramManager . VALIDATOR , m_Validator ) ; assertThat ( m_SUT . getActiveProgramTemplateNames ( ) . size ( ) , greaterThan ( 1 ) ) ; Set < Program > programs = m_SUT . getActiveProgramsUsingTemplate ( "saved-program1" ) ; assertThat ( programs . size ( ) , is ( 1 ) ) ; Program program1 = programs . iterator ( ) . next ( ) ; assertThat ( program1 . getSource ( ) , is ( "test" ) ) ; assertThat ( program1 . getFactoryObjectDeps ( Asset . class ) . size ( ) , is ( 2 ) ) ; assertThat ( program1 . getFactoryObjectDeps ( Asset . class ) , hasItem ( "assetX" ) ) ; assertThat ( program1 . getFactoryObjectDeps ( Asset . class ) , hasItem ( "assetZ" ) ) ; assertThat ( program1 . getFactoryObjectDeps ( TransportLayer . class ) . size ( ) , is ( 1 ) ) ; assertThat ( program1 . getFactoryObjectDeps ( TransportLayer . class ) , hasItem ( "tl7" ) ) ; assertThat ( program1 . getProgramDeps ( ) . size ( ) , is ( 1 ) ) ; assertThat ( program1 . getProgramDeps ( ) , hasItem ( "saved-program5" ) ) ; programs = m_SUT . getActiveProgramsUsingTemplate ( "saved-program2" ) ; assertThat ( programs . size ( ) , is ( 1 ) ) ; Program program2 = programs . iterator ( ) . next ( ) ; assertThat ( program2 . getSource ( ) , is ( "blah" ) ) ; assertThat ( program2 . getFactoryObjectDeps ( PhysicalLink . class ) . size ( ) , is ( 1 ) ) ; assertThat ( program2 . getFactoryObjectDeps ( PhysicalLink . class ) , hasItem ( "pl5" ) ) ; assertThat ( program2 . getFactoryObjectDeps ( LinkLayer . class ) . size ( ) , is ( 1 ) ) ; assertThat ( program2 . getFactoryObjectDeps ( LinkLayer . class ) , hasItem ( "ll1" ) ) ; }
Verify that MPM activates correctly.
Verify that MPM activates correctly .
// mock // replay // verify copying of base bindings // verify restoring of programs //check that values are as expected.