mil.dod.th.ose.integration/src/mil/dod/th/ose/controller/integration/core/TestMissionProgramManager.java
@Test
    public void testAssetDirectoryService() 
        throws IllegalArgumentException, MissionProgramException, AssetException, IOException, 
            PersistenceFailedException, FactoryException, InterruptedException
    {
        //syncer used to listen for executed event, mission's execute on a separate thread
        EventHandlerSyncer programExecutedSyncer = new EventHandlerSyncer(Program.TOPIC_PROGRAM_EXECUTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "ads-test"));

        //get directory service, and create/register an asset with the service
        AssetDirectoryService assetDirectoryService = IntegrationTestRunner.getService(AssetDirectoryService.class);
        assetDirectoryService.createAsset(ExampleAsset.class.getName(), "adsTestAsset");   

        //verify the template was loaded correctly
        assertThat(m_TemplateProgramManager.getMissionTemplateNames(), hasItem("asset-directory-service-template"));
        
        //parameters and schedule for the mission program    
        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
            withImmediately(false).withActive(true).withAtReset(false);
        MissionProgramParameters params = new MissionProgramParameters().
                withTemplateName("asset-directory-service-template").
                withProgramName("ads-test").withSchedule(schedule).
                withParameters(new MapEntry("asset", "adsTestAsset"));
        //load the parameters, this indirectly verifies that the script was fulfilled/valid, and executed successfully
        Program program = m_MissionProgramManager.loadParameters(params);
        
        //ask the program to execute.
        program.execute();
        //wait for execute event
        programExecutedSyncer.waitForEvent(5);
        
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        
        //create a 'bad' program with an invalid asset
        schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(false).withActive(true).withAtReset(false);
        params = new MissionProgramParameters().
                withTemplateName("asset-directory-service-template").
                withProgramName("ads-test-failure").
            withSchedule(schedule).withParameters(new MapEntry("assetName", "bad-name"));
        
        //the asset will not be found in the asset directory
        try
        {
            m_MissionProgramManager.loadParameters(params);
            fail("Expecting exception");
        }
        catch (IllegalArgumentException e)
        {
            
        }
    }
/**
     * Tests that asset type dependencies can be looked up within the AssetDirectoryService and satisfied in a way
     * that the scripts that depend on the asset can execute correctly.
     * Re-tested {@link TestPersistedMissionPrograms#testAssetDirectoryService()}.
     */
Tests that asset type dependencies can be looked up within the AssetDirectoryService and satisfied in a way
that the scripts that depend on the asset can execute correctly.
Tests that asset type dependencies can be looked up within the AssetDirectoryService and satisfied in a way that the scripts that depend on the asset can execute correctly .
@Test
    public void testAssetDirectoryService() 
        throws IllegalArgumentException, MissionProgramException, AssetException, IOException, 
            PersistenceFailedException, FactoryException, InterruptedException
    {
        EventHandlerSyncer programExecutedSyncer = new EventHandlerSyncer(Program.TOPIC_PROGRAM_EXECUTED, 
                String.format("(%s=%s)", Program.EVENT_PROP_PROGRAM_NAME, "ads-test"));
        AssetDirectoryService assetDirectoryService = IntegrationTestRunner.getService(AssetDirectoryService.class);
        assetDirectoryService.createAsset(ExampleAsset.class.getName(), "adsTestAsset");   
        assertThat(m_TemplateProgramManager.getMissionTemplateNames(), hasItem("asset-directory-service-template"));
        MissionProgramSchedule schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
            withImmediately(false).withActive(true).withAtReset(false);
        MissionProgramParameters params = new MissionProgramParameters().
                withTemplateName("asset-directory-service-template").
                withProgramName("ads-test").withSchedule(schedule).
                withParameters(new MapEntry("asset", "adsTestAsset"));
        Program program = m_MissionProgramManager.loadParameters(params);
        program.execute();
        programExecutedSyncer.waitForEvent(5);
        assertThat(program.getProgramStatus(), is(ProgramStatus.EXECUTED));
        schedule = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(false).withActive(true).withAtReset(false);
        params = new MissionProgramParameters().
                withTemplateName("asset-directory-service-template").
                withProgramName("ads-test-failure").
            withSchedule(schedule).withParameters(new MapEntry("assetName", "bad-name"));
        try
        {
            m_MissionProgramManager.loadParameters(params);
            fail("Expecting exception");
        }
        catch (IllegalArgumentException e)
        {
        }
    }
@ Test public void testAssetDirectoryService ( ) throws IllegalArgumentException , MissionProgramException , AssetException , IOException , PersistenceFailedException , FactoryException , InterruptedException { EventHandlerSyncer programExecutedSyncer = new EventHandlerSyncer ( Program . TOPIC_PROGRAM_EXECUTED , String . format ( "(%s=%s)" , Program . EVENT_PROP_PROGRAM_NAME , "ads-test" ) ) ; AssetDirectoryService assetDirectoryService = IntegrationTestRunner . getService ( AssetDirectoryService . class ) ; assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) , "adsTestAsset" ) ; assertThat ( m_TemplateProgramManager . getMissionTemplateNames ( ) , hasItem ( "asset-directory-service-template" ) ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( false ) . withImmediately ( false ) . withActive ( true ) . withAtReset ( false ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "asset-directory-service-template" ) . withProgramName ( "ads-test" ) . withSchedule ( schedule ) . withParameters ( new MapEntry ( "asset" , "adsTestAsset" ) ) ; Program program = m_MissionProgramManager . loadParameters ( params ) ; program . execute ( ) ; programExecutedSyncer . waitForEvent ( 5 ) ; assertThat ( program . getProgramStatus ( ) , is ( ProgramStatus . EXECUTED ) ) ; schedule = new MissionProgramSchedule ( ) . withIndefiniteInterval ( false ) . withImmediately ( false ) . withActive ( true ) . withAtReset ( false ) ; params = new MissionProgramParameters ( ) . withTemplateName ( "asset-directory-service-template" ) . withProgramName ( "ads-test-failure" ) . withSchedule ( schedule ) . withParameters ( new MapEntry ( "assetName" , "bad-name" ) ) ; try { m_MissionProgramManager . loadParameters ( params ) ; fail ( "Expecting exception" ) ; } catch ( IllegalArgumentException e ) { } }
Tests that asset type dependencies can be looked up within the AssetDirectoryService and satisfied in a way
 that the scripts that depend on the asset can execute correctly.
Tests that asset type dependencies can be looked up within the AssetDirectoryService and satisfied in a way that the scripts that depend on the asset can execute correctly .
//syncer used to listen for executed event, mission's execute on a separate thread //get directory service, and create/register an asset with the service //verify the template was loaded correctly //parameters and schedule for the mission program     //load the parameters, this indirectly verifies that the script was fulfilled/valid, and executed successfully //ask the program to execute. //wait for execute event //create a 'bad' program with an invalid asset //the asset will not be found in the asset directory