mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestPhysicalLinkMessageService.java
@Test
    public void testIsPhysicalLinkInUse() throws IOException, CCommException
    {
        IsInUseRequestData request = IsInUseRequestData.newBuilder()
                .setPhysicalLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        
        PhysicalLinkNamespace ccommMessage = PhysicalLinkNamespace.newBuilder()
                .setType(PhysicalLinkMessageType.IsInUseRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestPayload payload = createPayload(ccommMessage);
        TerraHarvestMessage message = createPhysicalLinkMessage(ccommMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        PhysicalLink plink = mock(PhysicalLink.class);
        when(m_CustomCommsService.requestPhysicalLink(testUuid)).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((IsInUseRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        //capture and verify response
        ArgumentCaptor<IsInUseResponseData> messageCaptor = ArgumentCaptor.forClass(
                IsInUseResponseData.class);  
        
        verify(m_MessageFactory).createPhysicalLinkResponseMessage(eq(message), 
                eq(PhysicalLinkMessageType.IsInUseResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        IsInUseResponseData response = messageCaptor.getValue();
 
        assertThat(response.getIsInUse(), is(notNullValue()));
        assertThat(response.getIsInUse(), is(false));
    }
/**
     * Verify that the core service is requested to see if a physical link is in use, 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 that the core service is requested to see if a physical link is in use, 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 that the core service is requested to see if a physical link is in use 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 testIsPhysicalLinkInUse() throws IOException, CCommException
    {
        IsInUseRequestData request = IsInUseRequestData.newBuilder()
                .setPhysicalLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        PhysicalLinkNamespace ccommMessage = PhysicalLinkNamespace.newBuilder()
                .setType(PhysicalLinkMessageType.IsInUseRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(ccommMessage);
        TerraHarvestMessage message = createPhysicalLinkMessage(ccommMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        PhysicalLink plink = mock(PhysicalLink.class);
        when(m_CustomCommsService.requestPhysicalLink(testUuid)).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((IsInUseRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<IsInUseResponseData> messageCaptor = ArgumentCaptor.forClass(
                IsInUseResponseData.class);  
        verify(m_MessageFactory).createPhysicalLinkResponseMessage(eq(message), 
                eq(PhysicalLinkMessageType.IsInUseResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        IsInUseResponseData response = messageCaptor.getValue();
        assertThat(response.getIsInUse(), is(notNullValue()));
        assertThat(response.getIsInUse(), is(false));
    }
@ Test public void testIsPhysicalLinkInUse ( ) throws IOException , CCommException { IsInUseRequestData request = IsInUseRequestData . newBuilder ( ) . setPhysicalLinkUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; PhysicalLinkNamespace ccommMessage = PhysicalLinkNamespace . newBuilder ( ) . setType ( PhysicalLinkMessageType . IsInUseRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( ccommMessage ) ; TerraHarvestMessage message = createPhysicalLinkMessage ( ccommMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; PhysicalLink plink = mock ( PhysicalLink . class ) ; when ( m_CustomCommsService . requestPhysicalLink ( testUuid ) ) . 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 ( ( IsInUseRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < IsInUseResponseData > messageCaptor = ArgumentCaptor . forClass ( IsInUseResponseData . class ) ; verify ( m_MessageFactory ) . createPhysicalLinkResponseMessage ( eq ( message ) , eq ( PhysicalLinkMessageType . IsInUseResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; IsInUseResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getIsInUse ( ) , is ( notNullValue ( ) ) ) ; assertThat ( response . getIsInUse ( ) , is ( false ) ) ; }
Verify that the core service is requested to see if a physical link is in use, 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 that the core service is requested to see if a physical link is in use 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 // verify the event contains the data message //capture and verify response