mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAssetDirectoryService.java
public void testAssetExecuteCommand() throws InterruptedException, AssetException, CommandExecutionException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());

        // Test execute for value within range
        // Syncer to listen for Asset Capability Command Response
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Asset.TOPIC_COMMAND_RESPONSE,
                String.format("(%s=%s)", Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, 
                        SetPanTiltResponse.class.getName()));
        final Command setPT = new SetPanTiltCommand().withPanTilt(SpatialTypesFactory.newOrientationOffset(30));
        assertThat(setPT, is(notNullValue()));
        final SetPanTiltResponse setPTResponse = (SetPanTiltResponse)asset.executeCommand(setPT);
        assertThat(setPTResponse.isSetSensorId(), is(false));
        assertThat("PT Response is null", setPTResponse, is(notNullValue()));
        syncer.waitForEvent(5);
        
        // Test validate for value out of range
        final Command badCommand = new SetPanTiltCommand().withPanTilt(SpatialTypesFactory.newOrientationOffset(185));
        try
        {
            asset.executeCommand(badCommand);
            fail("CommandExecutionException should have been thrown");
        }
        catch (CommandExecutionException ex)
        {
            // do nothing, this exception is expected and does not need to be handled
        }
    }
/**
     * Tests executing a command for an asset.
     * 
     * Verifies response is actually posted as an event and someone can listen for a specific response by type.
     * Verifies invalid commands can throw exception that is thrown back to the caller.
     */
Tests executing a command for an asset.

Verifies response is actually posted as an event and someone can listen for a specific response by type.
Verifies invalid commands can throw exception that is thrown back to the caller.
Tests executing a command for an asset . Verifies response is actually posted as an event and someone can listen for a specific response by type . Verifies invalid commands can throw exception that is thrown back to the caller .
public void testAssetExecuteCommand() throws InterruptedException, AssetException, CommandExecutionException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, Asset.TOPIC_COMMAND_RESPONSE,
                String.format("(%s=%s)", Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, 
                        SetPanTiltResponse.class.getName()));
        final Command setPT = new SetPanTiltCommand().withPanTilt(SpatialTypesFactory.newOrientationOffset(30));
        assertThat(setPT, is(notNullValue()));
        final SetPanTiltResponse setPTResponse = (SetPanTiltResponse)asset.executeCommand(setPT);
        assertThat(setPTResponse.isSetSensorId(), is(false));
        assertThat("PT Response is null", setPTResponse, is(notNullValue()));
        syncer.waitForEvent(5);
        final Command badCommand = new SetPanTiltCommand().withPanTilt(SpatialTypesFactory.newOrientationOffset(185));
        try
        {
            asset.executeCommand(badCommand);
            fail("CommandExecutionException should have been thrown");
        }
        catch (CommandExecutionException ex)
        {
        }
    }
public void testAssetExecuteCommand ( ) throws InterruptedException , AssetException , CommandExecutionException { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; assertThat ( assetDirectoryService , is ( notNullValue ( ) ) ) ; Asset asset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) ) ; EventHandlerSyncer syncer = new EventHandlerSyncer ( m_Context , Asset . TOPIC_COMMAND_RESPONSE , String . format ( "(%s=%s)" , Asset . EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE , SetPanTiltResponse . class . getName ( ) ) ) ; final Command setPT = new SetPanTiltCommand ( ) . withPanTilt ( SpatialTypesFactory . newOrientationOffset ( 30 ) ) ; assertThat ( setPT , is ( notNullValue ( ) ) ) ; final SetPanTiltResponse setPTResponse = ( SetPanTiltResponse ) asset . executeCommand ( setPT ) ; assertThat ( setPTResponse . isSetSensorId ( ) , is ( false ) ) ; assertThat ( "PT Response is null" , setPTResponse , is ( notNullValue ( ) ) ) ; syncer . waitForEvent ( 5 ) ; final Command badCommand = new SetPanTiltCommand ( ) . withPanTilt ( SpatialTypesFactory . newOrientationOffset ( 185 ) ) ; try { asset . executeCommand ( badCommand ) ; fail ( "CommandExecutionException should have been thrown" ) ; } catch ( CommandExecutionException ex ) { } }
Tests executing a command for an asset.
Tests executing a command for an asset .
// Test execute for value within range // Syncer to listen for Asset Capability Command Response // Test validate for value out of range // do nothing, this exception is expected and does not need to be handled