mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestMissionProgramming.java
@Test
    public void testTimedDataCaptureLoop() throws IllegalArgumentException, PersistenceFailedException, 
        InterruptedException, AssetException, FactoryException, IOException
    {
        AssetDirectoryService assetDirectoryService = 
                ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset loopAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "loopAsset");
        
        //schedule and params to use for execution of the template
        MissionProgramSchedule schedule = new MissionProgramSchedule()
            .withIndefiniteInterval(true)
            .withImmediately(true)
            .withActive(true);
        final MapEntry entryAsset = new MapEntry("asset", "loopAsset");
        final MapEntry entryInitDelay = new MapEntry("initTimeDelay", 0);
        final MapEntry entryDelayInt = new MapEntry("timeDelayInterval", 4); 
        final MapEntry entryTimeUnit = new MapEntry("timeUnitStr", "Second");
        
        EventHandlerSyncer executeMissionSyncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "timed-data-loop-test"));
        
        MissionProgramParameters params = new MissionProgramParameters()
            .withTemplateName("timed-data-capture-loop")
            .withSchedule(schedule)
            .withParameters(entryAsset, entryInitDelay, entryDelayInt, entryTimeUnit)
            .withProgramName("timed-data-loop-test");
        
        //load the parameters
        Program program = m_MissionProgramManager.loadParameters(params);
        
        executeMissionSyncer.waitForEvent(5);
        
        // the mission should execute immediately, it only sets up to run on a scheduled interval
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        
        // allow 2 observations to be made
        Thread.sleep(6000);
        
        // stop executor used by mission        
        ManagedExecutors managedExecutors = ServiceUtils.getService(m_Context, ManagedExecutors.class);
        managedExecutors.shutdownAllExecutorServices();
        
        // allow current iteration to finish
        Thread.sleep(1500);
        
        // should have capture 1 every 4 seconds, for a total of 2
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        Collection<Observation> observations = observationStore.newQuery()
                .withAsset(loopAsset)
                .withSubType(ObservationSubTypeEnum.DETECTION)
                .execute();
        assertThat(observations.size(), is(2));
    }
/**
     * Test running of the timed-data-capture-loop template.  Test that an asset will produce assets based on the 
     * interval.
     */
Test running of the timed-data-capture-loop template.  Test that an asset will produce assets based on the
interval.
Test running of the timed - data - capture - loop template . Test that an asset will produce assets based on the interval .
@Test
    public void testTimedDataCaptureLoop() throws IllegalArgumentException, PersistenceFailedException, 
        InterruptedException, AssetException, FactoryException, IOException
    {
        AssetDirectoryService assetDirectoryService = 
                ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        Asset loopAsset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "loopAsset");
        MissionProgramSchedule schedule = new MissionProgramSchedule()
            .withIndefiniteInterval(true)
            .withImmediately(true)
            .withActive(true);
        final MapEntry entryAsset = new MapEntry("asset", "loopAsset");
        final MapEntry entryInitDelay = new MapEntry("initTimeDelay", 0);
        final MapEntry entryDelayInt = new MapEntry("timeDelayInterval", 4); 
        final MapEntry entryTimeUnit = new MapEntry("timeUnitStr", "Second");
        EventHandlerSyncer executeMissionSyncer = new EventHandlerSyncer(m_Context, Program.TOPIC_PROGRAM_EXECUTED, 
                        String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "timed-data-loop-test"));
        MissionProgramParameters params = new MissionProgramParameters()
            .withTemplateName("timed-data-capture-loop")
            .withSchedule(schedule)
            .withParameters(entryAsset, entryInitDelay, entryDelayInt, entryTimeUnit)
            .withProgramName("timed-data-loop-test");
        Program program = m_MissionProgramManager.loadParameters(params);
        executeMissionSyncer.waitForEvent(5);
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        Thread.sleep(6000);
        ManagedExecutors managedExecutors = ServiceUtils.getService(m_Context, ManagedExecutors.class);
        managedExecutors.shutdownAllExecutorServices();
        Thread.sleep(1500);
        ObservationStore observationStore = ServiceUtils.getService(m_Context, ObservationStore.class);
        Collection<Observation> observations = observationStore.newQuery()
                .withAsset(loopAsset)
                .withSubType(ObservationSubTypeEnum.DETECTION)
                .execute();
        assertThat(observations.size(), is(2));
    }
@ Test public void testTimedDataCaptureLoop ( ) throws IllegalArgumentException , PersistenceFailedException , InterruptedException , AssetException , FactoryException , IOException { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; Asset loopAsset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) , "loopAsset" ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( true ) . withImmediately ( true ) . withActive ( true ) ; final MapEntry entryAsset = new MapEntry ( "asset" , "loopAsset" ) ; final MapEntry entryInitDelay = new MapEntry ( "initTimeDelay" , 0 ) ; final MapEntry entryDelayInt = new MapEntry ( "timeDelayInterval" , 4 ) ; final MapEntry entryTimeUnit = new MapEntry ( "timeUnitStr" , "Second" ) ; EventHandlerSyncer executeMissionSyncer = new EventHandlerSyncer ( m_Context , Program . TOPIC_PROGRAM_EXECUTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , "timed-data-loop-test" ) ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "timed-data-capture-loop" ) . withSchedule ( schedule ) . withParameters ( entryAsset , entryInitDelay , entryDelayInt , entryTimeUnit ) . withProgramName ( "timed-data-loop-test" ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; executeMissionSyncer . waitForEvent ( 5 ) ; assertThat ( program . getProgramStatus ( ) , is ( ProgramStatus . EXECUTED ) ) ; Thread . sleep ( 6000 ) ; ManagedExecutors managedExecutors = ServiceUtils . getService ( m_Context , ManagedExecutors . class ) ; managedExecutors . shutdownAllExecutorServices ( ) ; Thread . sleep ( 1500 ) ; ObservationStore observationStore = ServiceUtils . getService ( m_Context , ObservationStore . class ) ; Collection < Observation > observations = observationStore . newQuery ( ) . withAsset ( loopAsset ) . withSubType ( ObservationSubTypeEnum . DETECTION ) . execute ( ) ; assertThat ( observations . size ( ) , is ( 2 ) ) ; }
Test running of the timed-data-capture-loop template.
Test running of the timed - data - capture - loop template .
//schedule and params to use for execution of the template //load the parameters // the mission should execute immediately, it only sets up to run on a scheduled interval // allow 2 observations to be made // stop executor used by mission         // allow current iteration to finish // should have capture 1 every 4 seconds, for a total of 2