mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testIsAvailable() throws IOException, CCommException
    {
        // build the terra harvest message
        IsAvailableRequestData request = IsAvailableRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .setAddress("woof")
                .build();
        
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.IsAvailableRequest)
                .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 address
        Address testAddress = mock(Address.class);
        when(m_AddressManagerService.getOrCreateAddress("woof")).thenReturn(testAddress);
        when(testLayer.isAvailable(testAddress)).thenReturn(true);
        
        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((IsAvailableRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        //capture and verify response
        ArgumentCaptor<IsAvailableResponseData> messageCaptor = ArgumentCaptor.forClass(
                IsAvailableResponseData.class);  
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.IsAvailableResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        IsAvailableResponseData response = messageCaptor.getValue();
 
        assertThat(response.getAvailable(), is(true));
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(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 testIsAvailable() throws IOException, CCommException
    {
        IsAvailableRequestData request = IsAvailableRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .setAddress("woof")
                .build();
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.IsAvailableRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        Address testAddress = mock(Address.class);
        when(m_AddressManagerService.getOrCreateAddress("woof")).thenReturn(testAddress);
        when(testLayer.isAvailable(testAddress)).thenReturn(true);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((IsAvailableRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<IsAvailableResponseData> messageCaptor = ArgumentCaptor.forClass(
                IsAvailableResponseData.class);  
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.IsAvailableResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        IsAvailableResponseData response = messageCaptor.getValue();
        assertThat(response.getAvailable(), is(true));
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
    }
@ Test public void testIsAvailable ( ) throws IOException , CCommException { IsAvailableRequestData request = IsAvailableRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . setAddress ( "woof" ) . build ( ) ; LinkLayerNamespace llMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . IsAvailableRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( llMessage ) ; TerraHarvestMessage message = createLinkLayerMessage ( llMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Address testAddress = mock ( Address . class ) ; when ( m_AddressManagerService . getOrCreateAddress ( "woof" ) ) . thenReturn ( testAddress ) ; when ( testLayer . isAvailable ( testAddress ) ) . thenReturn ( true ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( IsAvailableRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < IsAvailableResponseData > messageCaptor = ArgumentCaptor . forClass ( IsAvailableResponseData . class ) ; verify ( m_MessageFactory ) . createLinkLayerResponseMessage ( eq ( message ) , eq ( LinkLayerMessageType . IsAvailableResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; IsAvailableResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getAvailable ( ) , is ( true ) ) ; assertThat ( response . getUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( 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 address // verify the event contains the data message //capture and verify response