mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestMissionProgramming.java
@Test
    public void testTriggeredSlewDataCapture() 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");
         
        //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", "New");
        //assets created earlier
        final MapEntry entryTrigger = new MapEntry("triggerAsset", "triggerAsset");
        final MapEntry entryCapture = new MapEntry("captureAsset", "captureAsset"); 
        final MapEntry entryPan = new MapEntry("pan", 30.0f);
        final MapEntry entryTilt = new MapEntry("tilt", 30.0f);
        
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "triggered-slew-data-capture-any"));
        
        MissionProgramParameters params = new MissionProgramParameters()
            .withTemplateName("triggered-slew-data-capture")
            .withSchedule(schedule)
            .withParameters(entrySubEvent, entryTrigger, entryCapture, entryPan, entryTilt)
            .withProgramName("triggered-slew-data-capture-any");
        
        //load the parameters
        Program program = m_MissionProgramManager.loadParameters(params);
        
        syncer.waitForEvent(5);
                
        // the mission should have executed, registers an event handler and captures data for each observation 
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        
        // 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);
        //check if captureAsset captured data
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        Collection<Observation> observations = observationStore.newQuery()
                .withAsset(captureAsset)
                .withSubType(ObservationSubTypeEnum.DETECTION)
                .execute();
        assertThat(observations.size(), is(1));
        
        //since the capture asset has already panned and tilted during the onexecutecommand,
        //our aim is to get back that pan and tilt and verify that it really panned by that value
        //and tilted by that value.
        syncer = new EventHandlerSyncer(m_Context, Asset.TOPIC_COMMAND_RESPONSE,
            String.format("(%s=%s)", Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, 
                GetPanTiltResponse.class.getName()));
        final Command getPT = new GetPanTiltCommand();
        final GetPanTiltResponse getPTResponse = (GetPanTiltResponse)captureAsset.executeCommand(getPT);
        assertThat("PT Response is null",getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getPanTilt().getAzimuth().getValue(), is(30.0));
        assertThat(getPTResponse.getPanTilt().isSetElevation(), is(false));
    }
/**
     * Test running of the triggered-slew-data-capture template.  When the trigger asset produces a detection,
     *  the capture asset should capture data after the specified pan/tilt is done.
     */
Test running of the triggered-slew-data-capture template.  When the trigger asset produces a detection,
the capture asset should capture data after the specified pan/tilt is done.
Test running of the triggered - slew - data - capture template . When the trigger asset produces a detection the capture asset should capture data after the specified pan / tilt is done .
@Test
    public void testTriggeredSlewDataCapture() 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");
        MissionProgramSchedule schedule = new MissionProgramSchedule()
            .withIndefiniteInterval(true)
            .withImmediately(true)
            .withActive(true);
        final MapEntry entrySubEvent = new MapEntry("subscribeEvent", "New");
        final MapEntry entryTrigger = new MapEntry("triggerAsset", "triggerAsset");
        final MapEntry entryCapture = new MapEntry("captureAsset", "captureAsset"); 
        final MapEntry entryPan = new MapEntry("pan", 30.0f);
        final MapEntry entryTilt = new MapEntry("tilt", 30.0f);
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "triggered-slew-data-capture-any"));
        MissionProgramParameters params = new MissionProgramParameters()
            .withTemplateName("triggered-slew-data-capture")
            .withSchedule(schedule)
            .withParameters(entrySubEvent, entryTrigger, entryCapture, entryPan, entryTilt)
            .withProgramName("triggered-slew-data-capture-any");
        Program program = m_MissionProgramManager.loadParameters(params);
        syncer.waitForEvent(5);
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        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);
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        Collection<Observation> observations = observationStore.newQuery()
                .withAsset(captureAsset)
                .withSubType(ObservationSubTypeEnum.DETECTION)
                .execute();
        assertThat(observations.size(), is(1));
        syncer = new EventHandlerSyncer(m_Context, Asset.TOPIC_COMMAND_RESPONSE,
            String.format("(%s=%s)", Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, 
                GetPanTiltResponse.class.getName()));
        final Command getPT = new GetPanTiltCommand();
        final GetPanTiltResponse getPTResponse = (GetPanTiltResponse)captureAsset.executeCommand(getPT);
        assertThat("PT Response is null",getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getPanTilt().getAzimuth().getValue(), is(30.0));
        assertThat(getPTResponse.getPanTilt().isSetElevation(), is(false));
    }
@ Test public void testTriggeredSlewDataCapture ( ) 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" ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( true ) . withImmediately ( true ) . withActive ( true ) ; final MapEntry entrySubEvent = new MapEntry ( "subscribeEvent" , "New" ) ; final MapEntry entryTrigger = new MapEntry ( "triggerAsset" , "triggerAsset" ) ; final MapEntry entryCapture = new MapEntry ( "captureAsset" , "captureAsset" ) ; final MapEntry entryPan = new MapEntry ( "pan" , 30.0f ) ; final MapEntry entryTilt = new MapEntry ( "tilt" , 30.0f ) ; EventHandlerSyncer syncer = new EventHandlerSyncer ( m_Context , Program . TOPIC_PROGRAM_EXECUTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , "triggered-slew-data-capture-any" ) ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "triggered-slew-data-capture" ) . withSchedule ( schedule ) . withParameters ( entrySubEvent , entryTrigger , entryCapture , entryPan , entryTilt ) . withProgramName ( "triggered-slew-data-capture-any" ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; syncer . waitForEvent ( 5 ) ; assertThat ( program . getProgramStatus ( ) , is ( ProgramStatus . EXECUTED ) ) ; 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 ) ; ObservationStore observationStore = ServiceUtils . getService ( m_Context , ObservationStore . class ) ; Collection < Observation > observations = observationStore . newQuery ( ) . withAsset ( captureAsset ) . withSubType ( ObservationSubTypeEnum . DETECTION ) . execute ( ) ; assertThat ( observations . size ( ) , is ( 1 ) ) ; syncer = new EventHandlerSyncer ( m_Context , Asset . TOPIC_COMMAND_RESPONSE , String . format ( "(%s=%s)" , Asset . EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE , GetPanTiltResponse . class . getName ( ) ) ) ; final Command getPT = new GetPanTiltCommand ( ) ; final GetPanTiltResponse getPTResponse = ( GetPanTiltResponse ) captureAsset . executeCommand ( getPT ) ; assertThat ( "PT Response is null" , getPTResponse , is ( notNullValue ( ) ) ) ; assertThat ( getPTResponse . getPanTilt ( ) . getAzimuth ( ) . getValue ( ) , is ( 30.0 ) ) ; assertThat ( getPTResponse . getPanTilt ( ) . isSetElevation ( ) , is ( false ) ) ; }
Test running of the triggered-slew-data-capture template.
Test running of the triggered - slew - data - capture template .
//create assets //schedule and params to use for execution of the template //assets created earlier //load the parameters // the mission should have executed, registers an event handler and captures data for each observation  // set up to wait for an observation persisted from the capture asset // have trigger asset persist observation to trigger other asset to capture data //check if captureAsset captured data //since the capture asset has already panned and tilted during the onexecutecommand, //our aim is to get back that pan and tilt and verify that it really panned by that value //and tilted by that value.