mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAssetDirectoryService.java
public void testAssetExecuteCommandPosition() throws InterruptedException, AssetException, 
        CommandExecutionException, IllegalArgumentException, IllegalStateException, FactoryException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        
        //verify override if false as GPS is not available per caps, default is true if caps aren't available
        assertThat(asset.getConfig().pluginOverridesPosition(), is(false));
        
        // Test execute for value within range
        // Syncer to listen event that data was persisted
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, PersistentDataStore.TOPIC_DATA_MERGED);
        
        //location without sensor ID
        Command setPos = new SetPositionCommand().withLocation(
            new Coordinates().
                withLongitude(
                    new LongitudeWgsDegrees().withValue(31)).
                withLatitude(
                    new LatitudeWgsDegrees().withValue(-15)));
        assertThat(setPos, is(notNullValue()));
        SetPositionResponse setPTResponse = (SetPositionResponse)asset.executeCommand(setPos);
        syncer.waitForEvent(10);
        assertThat("Position Response is null", setPTResponse, is(notNullValue()));
        assertThat(setPTResponse.getSensorId(), is(nullValue()));
        
        // Syncer to listen event that data was persisted
        syncer = new EventHandlerSyncer(m_Context, PersistentDataStore.TOPIC_DATA_MERGED);

        //location with sensor ID
        setPos = new SetPositionCommand().withSensorId("sensor-1").withLocation(
            new Coordinates().
                withLongitude(
                    new LongitudeWgsDegrees().withValue(41)).
                withLatitude(
                    new LatitudeWgsDegrees().withValue(-25)));
        assertThat(setPos, is(notNullValue()));
        setPTResponse = (SetPositionResponse)asset.executeCommand(setPos);
        syncer.waitForEvent(10);
        assertThat("Position Response is null", setPTResponse, is(notNullValue()));
        assertThat(setPTResponse.getSensorId(), is("sensor-1"));
        
        //verify that the value is retrievable when sensor ID is not set
        Command getPos = new GetPositionCommand();
        
        GetPositionResponse getPTResponse = (GetPositionResponse)asset.executeCommand(getPos);
        assertThat("Get Position Response is null", getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getSensorId(), is(nullValue()));
        
        assertThat(getPTResponse.getLocation().getLongitude().getValue(), is((double)31));
        assertThat(getPTResponse.getLocation().getLatitude().getValue(), is((double)-15));

        //verify that the value is retrievable when sensor ID is set
        getPos = new GetPositionCommand().withSensorId("sensor-1");
        
        getPTResponse = (GetPositionResponse)asset.executeCommand(getPos);
        assertThat("Get Position Response is null", getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getSensorId(), is("sensor-1"));
        
        assertThat(getPTResponse.getLocation().getLongitude().getValue(), is((double)41));
        assertThat(getPTResponse.getLocation().getLatitude().getValue(), is((double)-25));
    }
/**
     * Tests executing a position 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 position 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 position 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 testAssetExecuteCommandPosition() throws InterruptedException, AssetException, 
        CommandExecutionException, IllegalArgumentException, IllegalStateException, FactoryException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        assertThat(asset.getConfig().pluginOverridesPosition(), is(false));
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, PersistentDataStore.TOPIC_DATA_MERGED);
        Command setPos = new SetPositionCommand().withLocation(
            new Coordinates().
                withLongitude(
                    new LongitudeWgsDegrees().withValue(31)).
                withLatitude(
                    new LatitudeWgsDegrees().withValue(-15)));
        assertThat(setPos, is(notNullValue()));
        SetPositionResponse setPTResponse = (SetPositionResponse)asset.executeCommand(setPos);
        syncer.waitForEvent(10);
        assertThat("Position Response is null", setPTResponse, is(notNullValue()));
        assertThat(setPTResponse.getSensorId(), is(nullValue()));
        syncer = new EventHandlerSyncer(m_Context, PersistentDataStore.TOPIC_DATA_MERGED);
        setPos = new SetPositionCommand().withSensorId("sensor-1").withLocation(
            new Coordinates().
                withLongitude(
                    new LongitudeWgsDegrees().withValue(41)).
                withLatitude(
                    new LatitudeWgsDegrees().withValue(-25)));
        assertThat(setPos, is(notNullValue()));
        setPTResponse = (SetPositionResponse)asset.executeCommand(setPos);
        syncer.waitForEvent(10);
        assertThat("Position Response is null", setPTResponse, is(notNullValue()));
        assertThat(setPTResponse.getSensorId(), is("sensor-1"));
        Command getPos = new GetPositionCommand();
        GetPositionResponse getPTResponse = (GetPositionResponse)asset.executeCommand(getPos);
        assertThat("Get Position Response is null", getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getSensorId(), is(nullValue()));
        assertThat(getPTResponse.getLocation().getLongitude().getValue(), is((double)31));
        assertThat(getPTResponse.getLocation().getLatitude().getValue(), is((double)-15));
        getPos = new GetPositionCommand().withSensorId("sensor-1");
        getPTResponse = (GetPositionResponse)asset.executeCommand(getPos);
        assertThat("Get Position Response is null", getPTResponse, is(notNullValue()));
        assertThat(getPTResponse.getSensorId(), is("sensor-1"));
        assertThat(getPTResponse.getLocation().getLongitude().getValue(), is((double)41));
        assertThat(getPTResponse.getLocation().getLatitude().getValue(), is((double)-25));
    }
public void testAssetExecuteCommandPosition ( ) throws InterruptedException , AssetException , CommandExecutionException , IllegalArgumentException , IllegalStateException , FactoryException { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; assertThat ( assetDirectoryService , is ( notNullValue ( ) ) ) ; Asset asset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) ) ; assertThat ( asset . getConfig ( ) . pluginOverridesPosition ( ) , is ( false ) ) ; EventHandlerSyncer syncer = new EventHandlerSyncer ( m_Context , PersistentDataStore . TOPIC_DATA_MERGED ) ; Command setPos = new SetPositionCommand ( ) . withLocation ( new Coordinates ( ) . withLongitude ( new LongitudeWgsDegrees ( ) . withValue ( 31 ) ) . withLatitude ( new LatitudeWgsDegrees ( ) . withValue ( - 15 ) ) ) ; assertThat ( setPos , is ( notNullValue ( ) ) ) ; SetPositionResponse setPTResponse = ( SetPositionResponse ) asset . executeCommand ( setPos ) ; syncer . waitForEvent ( 10 ) ; assertThat ( "Position Response is null" , setPTResponse , is ( notNullValue ( ) ) ) ; assertThat ( setPTResponse . getSensorId ( ) , is ( nullValue ( ) ) ) ; syncer = new EventHandlerSyncer ( m_Context , PersistentDataStore . TOPIC_DATA_MERGED ) ; setPos = new SetPositionCommand ( ) . withSensorId ( "sensor-1" ) . withLocation ( new Coordinates ( ) . withLongitude ( new LongitudeWgsDegrees ( ) . withValue ( 41 ) ) . withLatitude ( new LatitudeWgsDegrees ( ) . withValue ( - 25 ) ) ) ; assertThat ( setPos , is ( notNullValue ( ) ) ) ; setPTResponse = ( SetPositionResponse ) asset . executeCommand ( setPos ) ; syncer . waitForEvent ( 10 ) ; assertThat ( "Position Response is null" , setPTResponse , is ( notNullValue ( ) ) ) ; assertThat ( setPTResponse . getSensorId ( ) , is ( "sensor-1" ) ) ; Command getPos = new GetPositionCommand ( ) ; GetPositionResponse getPTResponse = ( GetPositionResponse ) asset . executeCommand ( getPos ) ; assertThat ( "Get Position Response is null" , getPTResponse , is ( notNullValue ( ) ) ) ; assertThat ( getPTResponse . getSensorId ( ) , is ( nullValue ( ) ) ) ; assertThat ( getPTResponse . getLocation ( ) . getLongitude ( ) . getValue ( ) , is ( ( double ) 31 ) ) ; assertThat ( getPTResponse . getLocation ( ) . getLatitude ( ) . getValue ( ) , is ( ( double ) - 15 ) ) ; getPos = new GetPositionCommand ( ) . withSensorId ( "sensor-1" ) ; getPTResponse = ( GetPositionResponse ) asset . executeCommand ( getPos ) ; assertThat ( "Get Position Response is null" , getPTResponse , is ( notNullValue ( ) ) ) ; assertThat ( getPTResponse . getSensorId ( ) , is ( "sensor-1" ) ) ; assertThat ( getPTResponse . getLocation ( ) . getLongitude ( ) . getValue ( ) , is ( ( double ) 41 ) ) ; assertThat ( getPTResponse . getLocation ( ) . getLatitude ( ) . getValue ( ) , is ( ( double ) - 25 ) ) ; }
Tests executing a position command for an asset.
Tests executing a position command for an asset .
//verify override if false as GPS is not available per caps, default is true if caps aren't available // Test execute for value within range // Syncer to listen event that data was persisted //location without sensor ID // Syncer to listen event that data was persisted //location with sensor ID //verify that the value is retrievable when sensor ID is not set //verify that the value is retrievable when sensor ID is set