mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testGetPhysicalLink() throws IOException
    {
        // build the terra harvest message
        GetPhysicalLinkRequestData request = GetPhysicalLinkRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.GetPhysicalLinkRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // mock a physical link
        PhysicalLink plink = mock(PhysicalLink.class);
        when(plink.getUuid()).thenReturn(testUuid);
        
        // when link layer's physical link is requested return a mocked physical link
        when(testLayer.getPhysicalLink()).thenReturn(plink);
        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((GetPhysicalLinkRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        //capture and verify response
        ArgumentCaptor<GetPhysicalLinkResponseData> messageCaptor = ArgumentCaptor.forClass(
                GetPhysicalLinkResponseData.class);  
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.GetPhysicalLinkResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetPhysicalLinkResponseData response = messageCaptor.getValue();
 
        assertThat(SharedMessageUtils.convertProtoUUIDtoUUID(response.getPhysicalLinkUuid()), is(testUuid));
    }
/**
     * 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 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 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 testGetPhysicalLink() throws IOException
    {
        GetPhysicalLinkRequestData request = GetPhysicalLinkRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.GetPhysicalLinkRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        PhysicalLink plink = mock(PhysicalLink.class);
        when(plink.getUuid()).thenReturn(testUuid);
        when(testLayer.getPhysicalLink()).thenReturn(plink);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((GetPhysicalLinkRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<GetPhysicalLinkResponseData> messageCaptor = ArgumentCaptor.forClass(
                GetPhysicalLinkResponseData.class);  
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.GetPhysicalLinkResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetPhysicalLinkResponseData response = messageCaptor.getValue();
        assertThat(SharedMessageUtils.convertProtoUUIDtoUUID(response.getPhysicalLinkUuid()), is(testUuid));
    }
@ Test public void testGetPhysicalLink ( ) throws IOException { GetPhysicalLinkRequestData request = GetPhysicalLinkRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; LinkLayerNamespace llMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . GetPhysicalLinkRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( llMessage ) ; TerraHarvestMessage message = createLinkLayerMessage ( llMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; PhysicalLink plink = mock ( PhysicalLink . class ) ; when ( plink . getUuid ( ) ) . thenReturn ( testUuid ) ; when ( testLayer . getPhysicalLink ( ) ) . thenReturn ( plink ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( GetPhysicalLinkRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < GetPhysicalLinkResponseData > messageCaptor = ArgumentCaptor . forClass ( GetPhysicalLinkResponseData . class ) ; verify ( m_MessageFactory ) . createLinkLayerResponseMessage ( eq ( message ) , eq ( LinkLayerMessageType . GetPhysicalLinkResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetPhysicalLinkResponseData response = messageCaptor . getValue ( ) ; assertThat ( SharedMessageUtils . convertProtoUUIDtoUUID ( response . getPhysicalLinkUuid ( ) ) , is ( testUuid ) ) ; }
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 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 .
// build the terra harvest message // mock the channel the message came from // mock a physical link // when link layer's physical link is requested return a mocked physical link // verify the event contains the data message //capture and verify response