mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testHandleExecuteCommandResponse()
    {
        //make some assets
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        
        //this should render two assets for the system id
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        
        //verify assets added
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        
        List<AssetModel> assetModels = m_SUT.getAssetsForControllerAsync(systemId1);
        
        AssetModel testModel = null;
        
        for (AssetModel assetModel : assetModels)
        {
            if (assetModel.getUuid().equals(uuid1))
            {
                testModel = assetModel;
                break;
            }
        }
        
        // verify location info empty at first
        assertThat(testModel.getLocation().getLatitude(), is(nullValue()));
        assertThat(testModel.getLocation().getLongitude(), is(nullValue()));
        assertThat(testModel.getLocation().getAltitude(), is(nullValue()));
        assertThat(testModel.getLocation().getBank(), is(nullValue()));
        assertThat(testModel.getLocation().getHeading(), is(nullValue()));
        assertThat(testModel.getLocation().getElevation(), is(nullValue()));
        
        double expectedLongitude = -35.0;
        double expectedHeading = 90.0;
        
        //get position command
        Event getPositionCommand = mockExecuteGetPositionCommandResponse(systemId1, expectedLongitude, 
                1, 2, 3, 4, expectedHeading);
        
        m_AssetHelper.handleEvent(getPositionCommand);
        
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(AssetModel.EVENT_PROP_UUID, testModel.getUuid().toString());
        Event assetLocationUpdated = new Event(AssetMgr.TOPIC_ASSET_LOCATION_UPDATED, props);
        
        // just check one field from each type to ensure coord and orientation objects are passed properly
        assertThat(Double.valueOf(testModel.getLocation().getLongitude().toString()), is(expectedLongitude));
        assertThat(Double.valueOf(testModel.getLocation().getHeading().toString()), is(expectedHeading));
        
        //verify EventAdmin posted that the location was updated
        verify(m_EventAdmin).postEvent(assetLocationUpdated);
    }
/**
     * Test the handling of an execute command response event.
     * Verify that an asset location updated event is posted to the event admin.
     */
Test the handling of an execute command response event.
Verify that an asset location updated event is posted to the event admin.
Test the handling of an execute command response event . Verify that an asset location updated event is posted to the event admin .
@Test
    public void testHandleExecuteCommandResponse()
    {
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        List<AssetModel> assetModels = m_SUT.getAssetsForControllerAsync(systemId1);
        AssetModel testModel = null;
        for (AssetModel assetModel : assetModels)
        {
            if (assetModel.getUuid().equals(uuid1))
            {
                testModel = assetModel;
                break;
            }
        }
        assertThat(testModel.getLocation().getLatitude(), is(nullValue()));
        assertThat(testModel.getLocation().getLongitude(), is(nullValue()));
        assertThat(testModel.getLocation().getAltitude(), is(nullValue()));
        assertThat(testModel.getLocation().getBank(), is(nullValue()));
        assertThat(testModel.getLocation().getHeading(), is(nullValue()));
        assertThat(testModel.getLocation().getElevation(), is(nullValue()));
        double expectedLongitude = -35.0;
        double expectedHeading = 90.0;
        Event getPositionCommand = mockExecuteGetPositionCommandResponse(systemId1, expectedLongitude, 
                1, 2, 3, 4, expectedHeading);
        m_AssetHelper.handleEvent(getPositionCommand);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(AssetModel.EVENT_PROP_UUID, testModel.getUuid().toString());
        Event assetLocationUpdated = new Event(AssetMgr.TOPIC_ASSET_LOCATION_UPDATED, props);
        assertThat(Double.valueOf(testModel.getLocation().getLongitude().toString()), is(expectedLongitude));
        assertThat(Double.valueOf(testModel.getLocation().getHeading().toString()), is(expectedHeading));
        verify(m_EventAdmin).postEvent(assetLocationUpdated);
    }
@ Test public void testHandleExecuteCommandResponse ( ) { Event getAssetsReponse = mockGetAssetsResponse ( systemId1 ) ; m_AssetDirHelper . handleEvent ( getAssetsReponse ) ; assertThat ( m_SUT . getAssetsForControllerAsync ( systemId1 ) . size ( ) , is ( 2 ) ) ; List < AssetModel > assetModels = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; AssetModel testModel = null ; for ( AssetModel assetModel : assetModels ) { if ( assetModel . getUuid ( ) . equals ( uuid1 ) ) { testModel = assetModel ; break ; } } assertThat ( testModel . getLocation ( ) . getLatitude ( ) , is ( nullValue ( ) ) ) ; assertThat ( testModel . getLocation ( ) . getLongitude ( ) , is ( nullValue ( ) ) ) ; assertThat ( testModel . getLocation ( ) . getAltitude ( ) , is ( nullValue ( ) ) ) ; assertThat ( testModel . getLocation ( ) . getBank ( ) , is ( nullValue ( ) ) ) ; assertThat ( testModel . getLocation ( ) . getHeading ( ) , is ( nullValue ( ) ) ) ; assertThat ( testModel . getLocation ( ) . getElevation ( ) , is ( nullValue ( ) ) ) ; double expectedLongitude = - 35.0 ; double expectedHeading = 90.0 ; Event getPositionCommand = mockExecuteGetPositionCommandResponse ( systemId1 , expectedLongitude , 1 , 2 , 3 , 4 , expectedHeading ) ; m_AssetHelper . handleEvent ( getPositionCommand ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( AssetModel . EVENT_PROP_UUID , testModel . getUuid ( ) . toString ( ) ) ; Event assetLocationUpdated = new Event ( AssetMgr . TOPIC_ASSET_LOCATION_UPDATED , props ) ; assertThat ( Double . valueOf ( testModel . getLocation ( ) . getLongitude ( ) . toString ( ) ) , is ( expectedLongitude ) ) ; assertThat ( Double . valueOf ( testModel . getLocation ( ) . getHeading ( ) . toString ( ) ) , is ( expectedHeading ) ) ; verify ( m_EventAdmin ) . postEvent ( assetLocationUpdated ) ; }
Test the handling of an execute command response event.
Test the handling of an execute command response event .
//make some assets //this should render two assets for the system id //verify assets added // verify location info empty at first //get position command // just check one field from each type to ensure coord and orientation objects are passed properly //verify EventAdmin posted that the location was updated