mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/asset/TestAssetDirectoryMessageService.java
@Test
    public void testGetScannableAssetTypesResponse() throws IOException
    {
        GetScannableAssetTypesResponseData data = GetScannableAssetTypesResponseData.newBuilder().
                addScannableAssetType(AssetProxy.class.getName()).build();
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse).
                setData(data.toByteString()).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, payload, channel);
        
        //capture and verify event has been posted locally
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse.toString()));
        assertThat((GetScannableAssetTypesResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(data));
    }
/**
     * Verify event posted with scannable asset types response is received.
     */
Verify event posted with scannable asset types response is received.
Verify event posted with scannable asset types response is received .
@Test
    public void testGetScannableAssetTypesResponse() throws IOException
    {
        GetScannableAssetTypesResponseData data = GetScannableAssetTypesResponseData.newBuilder().
                addScannableAssetType(AssetProxy.class.getName()).build();
        AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace.newBuilder().
                setType(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse).
                setData(data.toByteString()).build();
        TerraHarvestPayload payload = createPayload(assetDirMessage);
        TerraHarvestMessage message = createMessage(assetDirMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(AssetDirectoryServiceMessageType.GetScannableAssetTypesResponse.toString()));
        assertThat((GetScannableAssetTypesResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(data));
    }
@ Test public void testGetScannableAssetTypesResponse ( ) throws IOException { GetScannableAssetTypesResponseData data = GetScannableAssetTypesResponseData . newBuilder ( ) . addScannableAssetType ( AssetProxy . class . getName ( ) ) . build ( ) ; AssetDirectoryServiceNamespace assetDirMessage = AssetDirectoryServiceNamespace . newBuilder ( ) . setType ( AssetDirectoryServiceMessageType . GetScannableAssetTypesResponse ) . setData ( data . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( assetDirMessage ) ; TerraHarvestMessage message = createMessage ( assetDirMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( AssetDirectoryServiceMessageType . GetScannableAssetTypesResponse . toString ( ) ) ) ; assertThat ( ( GetScannableAssetTypesResponseData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( data ) ) ; }
Verify event posted with scannable asset types response is received.
Verify event posted with scannable asset types response is received .
// mock the channel the message came from // replay //capture and verify event has been posted locally