mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testGetPhysicalLink_NoPhysicalLink() 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);
        
        // when link layer's physical link is requested return a mocked physical link
        when(testLayer.getPhysicalLink()).thenReturn(null);
        m_SUT.handleMessage(message, payload, channel);

        //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(response.hasPhysicalLinkUuid(), is(false));
    }
/**
     * Verify returned physical link UUID is null when the link layer does not have a physical link.
     */
Verify returned physical link UUID is null when the link layer does not have a physical link.
Verify returned physical link UUID is null when the link layer does not have a physical link .
@Test
    public void testGetPhysicalLink_NoPhysicalLink() 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);
        when(testLayer.getPhysicalLink()).thenReturn(null);
        m_SUT.handleMessage(message, payload, channel);
        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(response.hasPhysicalLinkUuid(), is(false));
    }
@ Test public void testGetPhysicalLink_NoPhysicalLink ( ) 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 ) ; when ( testLayer . getPhysicalLink ( ) ) . thenReturn ( null ) ; m_SUT . handleMessage ( message , payload , channel ) ; 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 ( response . hasPhysicalLinkUuid ( ) , is ( false ) ) ; }
Verify returned physical link UUID is null when the link layer does not have a physical link.
Verify returned physical link UUID is null when the link layer does not have a physical link .
// build the terra harvest message // mock the channel the message came from // when link layer's physical link is requested return a mocked physical link //capture and verify response