mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestTransportLayerMessageService.java
@Test
    public void testGetLinkLayer() throws IOException
    {
        GetLinkLayerRequestData request = GetLinkLayerRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        
        TransportLayerNamespace transportMessage = TransportLayerNamespace.newBuilder()
                .setType(TransportLayerMessageType.GetLinkLayerRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestMessage message = createTransportLayerMessage(transportMessage);
        TerraHarvestPayload payload = createPayload(transportMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // mock the link layer
        LinkLayer testLink = mock(LinkLayer.class);
        
        UUID linkUuid = UUID.randomUUID();
        when(testLink.getUuid()).thenReturn(linkUuid);
        when(testLayer.getLinkLayer()).thenReturn(testLink);
        
        m_SUT.handleMessage(message, payload, channel);
        
        // verify the event contains the data message
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        
        assertThat((GetLinkLayerRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        //capture and verify response
        ArgumentCaptor<GetLinkLayerResponseData> messageCaptor = ArgumentCaptor.forClass(
                GetLinkLayerResponseData.class);  
        verify(m_MessageFactory).createTransportLayerResponseMessage(eq(message), 
                eq(TransportLayerMessageType.GetLinkLayerResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetLinkLayerResponseData response = messageCaptor.getValue();
 
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(linkUuid)));
    }
/**
     * Verify we can get the UUID of the link layer associated with a transport layer, verify event posted for 
     * request message, verify event property key in the posted event is the correct request for the message that 
     * was sent, also capture argument values for the response message and make sure that the data sent is correct.
     */
Verify we can get the UUID of the link layer associated with a transport layer, verify event posted for
request message, verify event property key in the posted event is the correct request for the message that
was sent, also capture argument values for the response message and make sure that the data sent is correct.
Verify we can get the UUID of the link layer associated with a transport layer verify event posted for request message verify event property key in the posted event is the correct request for the message that was sent also capture argument values for the response message and make sure that the data sent is correct .
@Test
    public void testGetLinkLayer() throws IOException
    {
        GetLinkLayerRequestData request = GetLinkLayerRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        TransportLayerNamespace transportMessage = TransportLayerNamespace.newBuilder()
                .setType(TransportLayerMessageType.GetLinkLayerRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestMessage message = createTransportLayerMessage(transportMessage);
        TerraHarvestPayload payload = createPayload(transportMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        LinkLayer testLink = mock(LinkLayer.class);
        UUID linkUuid = UUID.randomUUID();
        when(testLink.getUuid()).thenReturn(linkUuid);
        when(testLayer.getLinkLayer()).thenReturn(testLink);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((GetLinkLayerRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<GetLinkLayerResponseData> messageCaptor = ArgumentCaptor.forClass(
                GetLinkLayerResponseData.class);  
        verify(m_MessageFactory).createTransportLayerResponseMessage(eq(message), 
                eq(TransportLayerMessageType.GetLinkLayerResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetLinkLayerResponseData response = messageCaptor.getValue();
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(linkUuid)));
    }
@ Test public void testGetLinkLayer ( ) throws IOException { GetLinkLayerRequestData request = GetLinkLayerRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; TransportLayerNamespace transportMessage = TransportLayerNamespace . newBuilder ( ) . setType ( TransportLayerMessageType . GetLinkLayerRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createTransportLayerMessage ( transportMessage ) ; TerraHarvestPayload payload = createPayload ( transportMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; LinkLayer testLink = mock ( LinkLayer . class ) ; UUID linkUuid = UUID . randomUUID ( ) ; when ( testLink . getUuid ( ) ) . thenReturn ( linkUuid ) ; when ( testLayer . getLinkLayer ( ) ) . thenReturn ( testLink ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( GetLinkLayerRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < GetLinkLayerResponseData > messageCaptor = ArgumentCaptor . forClass ( GetLinkLayerResponseData . class ) ; verify ( m_MessageFactory ) . createTransportLayerResponseMessage ( eq ( message ) , eq ( TransportLayerMessageType . GetLinkLayerResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetLinkLayerResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( linkUuid ) ) ) ; }
Verify we can get the UUID of the link layer associated with a transport layer, verify event posted for
 request message, verify event property key in the posted event is the correct request for the message that
 was sent, also capture argument values for the response message and make sure that the data sent is correct.
Verify we can get the UUID of the link layer associated with a transport layer verify event posted for request message verify event property key in the posted event is the correct request for the message that was sent also capture argument values for the response message and make sure that the data sent is correct .
// mock the channel the message came from // mock the link layer // verify the event contains the data message //capture and verify response