mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestMissionProgramming.java
@Test
    public void testTriggeredDataCapture_AllModalities() throws Exception
    {
        //create assets
        AssetDirectoryService assetDirectoryService = 
            ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset triggerAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "triggerAsset");
        Asset captureAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "captureAsset");
        
        for (SensingModalityEnum modality : SensingModalityEnum.values())
        {
            //schedule and params to use for execution of the template
            MissionProgramSchedule schedule = new MissionProgramSchedule()
                .withIndefiniteInterval(true)
                .withImmediately(true)
                .withActive(true);
            final MapEntry entrySubEvent = new MapEntry("subscribeEvent", "Both");  // just to be different from above
            //assets created earlier
            final MapEntry entryTrigger = new MapEntry("triggerAsset", "triggerAsset");
            final MapEntry entryCapture = new MapEntry("captureAsset", "captureAsset");
            // this time do a specific modality, results should be the same as that is what the asset produces
            final MapEntry entryModType = new MapEntry("modalityType", modality.value()); 
            final MapEntry entrySenId = new MapEntry("triggerSensorId", "n/a");
            
            String programName = "triggered-data-captured-" + modality.value();
            EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, programName));
            
            MissionProgramParameters params = new MissionProgramParameters()
                .withTemplateName("triggered-data-captured")
                .withSchedule(schedule)
                .withParameters(entrySubEvent, entryTrigger, entryCapture, entryModType, entrySenId)
                .withProgramName(programName);
            
            //load the parameters
            Program program = m_MissionProgramManager.loadParameters(params);
            
            syncer.waitForEvent(10);
                    
            // the mission should have executed, registers an event handler and captures data for each observation 
            assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
            
            // mission will only be triggered if trigger asset supports the modality
            if (triggerAsset.getFactory().getAssetCapabilities().getModalities().contains(modality))
            {
                // set up to wait for an observation persisted from the capture asset
                syncer = new EventHandlerSyncer(m_Context, ObservationStore.TOPIC_OBSERVATION_PERSISTED, 
                    String.format("(%s=%s)", FactoryDescriptor.EVENT_PROP_OBJ_UUID, captureAsset.getUuid().toString()));
                
                // have trigger asset persist observation to trigger other asset to capture data
                triggerAsset.captureData();
                
                syncer.waitForEvent(5);
            }
        }
    }
/**
     * Test running of the triggered-data-capture template, but with all modality types, not "Any".  When 
     * the trigger asset produces a detection, the capture asset should capture data.
     */
Test running of the triggered-data-capture template, but with all modality types, not "Any".  When
the trigger asset produces a detection, the capture asset should capture data.
Test running of the triggered - data - capture template but with all modality types not " Any " . When the trigger asset produces a detection the capture asset should capture data .
@Test
    public void testTriggeredDataCapture_AllModalities() throws Exception
    {
        AssetDirectoryService assetDirectoryService = 
            ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset triggerAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "triggerAsset");
        Asset captureAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "captureAsset");
        for (SensingModalityEnum modality : SensingModalityEnum.values())
        {
            MissionProgramSchedule schedule = new MissionProgramSchedule()
                .withIndefiniteInterval(true)
                .withImmediately(true)
                .withActive(true);
            final MapEntry entrySubEvent = new MapEntry("subscribeEvent", "Both");  
            final MapEntry entryTrigger = new MapEntry("triggerAsset", "triggerAsset");
            final MapEntry entryCapture = new MapEntry("captureAsset", "captureAsset");
            final MapEntry entryModType = new MapEntry("modalityType", modality.value()); 
            final MapEntry entrySenId = new MapEntry("triggerSensorId", "n/a");
            String programName = "triggered-data-captured-" + modality.value();
            EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, programName));
            MissionProgramParameters params = new MissionProgramParameters()
                .withTemplateName("triggered-data-captured")
                .withSchedule(schedule)
                .withParameters(entrySubEvent, entryTrigger, entryCapture, entryModType, entrySenId)
                .withProgramName(programName);
            Program program = m_MissionProgramManager.loadParameters(params);
            syncer.waitForEvent(10);
            assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
            if (triggerAsset.getFactory().getAssetCapabilities().getModalities().contains(modality))
            {
                syncer = new EventHandlerSyncer(m_Context, ObservationStore.TOPIC_OBSERVATION_PERSISTED, 
                    String.format("(%s=%s)", FactoryDescriptor.EVENT_PROP_OBJ_UUID, captureAsset.getUuid().toString()));
                triggerAsset.captureData();
                syncer.waitForEvent(5);
            }
        }
    }
@ Test public void testTriggeredDataCapture_AllModalities ( ) throws Exception { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; Asset triggerAsset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) , "triggerAsset" ) ; Asset captureAsset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) , "captureAsset" ) ; for ( SensingModalityEnum modality : SensingModalityEnum . values ( ) ) { MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( true ) . withImmediately ( true ) . withActive ( true ) ; final MapEntry entrySubEvent = new MapEntry ( "subscribeEvent" , "Both" ) ; final MapEntry entryTrigger = new MapEntry ( "triggerAsset" , "triggerAsset" ) ; final MapEntry entryCapture = new MapEntry ( "captureAsset" , "captureAsset" ) ; final MapEntry entryModType = new MapEntry ( "modalityType" , modality . value ( ) ) ; final MapEntry entrySenId = new MapEntry ( "triggerSensorId" , "n/a" ) ; String programName = "triggered-data-captured-" + modality . value ( ) ; EventHandlerSyncer syncer = new EventHandlerSyncer ( m_Context , Program . TOPIC_PROGRAM_EXECUTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , programName ) ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "triggered-data-captured" ) . withSchedule ( schedule ) . withParameters ( entrySubEvent , entryTrigger , entryCapture , entryModType , entrySenId ) . withProgramName ( programName ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; syncer . waitForEvent ( 10 ) ; assertThat ( program . getProgramStatus ( ) , is ( ProgramStatus . EXECUTED ) ) ; if ( triggerAsset . getFactory ( ) . getAssetCapabilities ( ) . getModalities ( ) . contains ( modality ) ) { syncer = new EventHandlerSyncer ( m_Context , ObservationStore . TOPIC_OBSERVATION_PERSISTED , String . format ( "(%s=%s)" , FactoryDescriptor . EVENT_PROP_OBJ_UUID , captureAsset . getUuid ( ) . toString ( ) ) ) ; triggerAsset . captureData ( ) ; syncer . waitForEvent ( 5 ) ; } } }
Test running of the triggered-data-capture template, but with all modality types, not "Any".
Test running of the triggered - data - capture template but with all modality types not " Any " .
//create assets //schedule and params to use for execution of the template // just to be different from above //assets created earlier // this time do a specific modality, results should be the same as that is what the asset produces //load the parameters // the mission should have executed, registers an event handler and captures data for each observation  // mission will only be triggered if trigger asset supports the modality // set up to wait for an observation persisted from the capture asset // have trigger asset persist observation to trigger other asset to capture data