mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetMessageService.java
@Test
    public void testGetAssetNameResponse() throws IOException
    {
        GetNameResponseData response = GetNameResponseData.newBuilder().
                setAssetName("name").
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        AssetNamespace assetDirMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.GetNameResponse).
                setData(response.toByteString()).build();
        TerraHarvestMessage message = createMessage(assetDirMessage);

        //mock remote channel
        RemoteChannel channel = mock(RemoteChannel.class);

        //handle message
        m_SUT.handleMessage(message, createPayload(assetDirMessage), channel);
        
        //capture event
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        
        //verify
        assertThat((AssetNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE),
                is(assetDirMessage));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetMessageType.GetNameResponse.toString()));
        assertThat((GetNameResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
/**
     * Test get name for asset response.
     * Verify that expected event is posted.
     */
Test get name for asset response.
Verify that expected event is posted.
Test get name for asset response . Verify that expected event is posted .
@Test
    public void testGetAssetNameResponse() throws IOException
    {
        GetNameResponseData response = GetNameResponseData.newBuilder().
                setAssetName("name").
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        AssetNamespace assetDirMessage = AssetNamespace.newBuilder().
                setType(AssetMessageType.GetNameResponse).
                setData(response.toByteString()).build();
        TerraHarvestMessage message = createMessage(assetDirMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, createPayload(assetDirMessage), channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((AssetNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE),
                is(assetDirMessage));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetMessageType.GetNameResponse.toString()));
        assertThat((GetNameResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
@ Test public void testGetAssetNameResponse ( ) throws IOException { GetNameResponseData response = GetNameResponseData . newBuilder ( ) . setAssetName ( "name" ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; AssetNamespace assetDirMessage = AssetNamespace . newBuilder ( ) . setType ( AssetMessageType . GetNameResponse ) . setData ( response . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , createPayload ( assetDirMessage ) , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( AssetNamespace ) event . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( assetDirMessage ) ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( AssetMessageType . GetNameResponse . toString ( ) ) ) ; assertThat ( ( GetNameResponseData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( response ) ) ; }
Test get name for asset response.
Test get name for asset response .
//mock remote channel //handle message //capture event //verify