mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestTransportLayerMessageService.java
@Test
    public void testIsAvailable() throws CCommException, IOException
    {
        IsAvailableRequestData request = IsAvailableRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .setAddress("finn")
                .build();
        
        TransportLayerNamespace transportMessage = TransportLayerNamespace.newBuilder()
                .setType(TransportLayerMessageType.IsAvailableRequest)
                .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 address
        Address testAddress = mock(Address.class);
        when(m_AddressManagerService.getOrCreateAddress("finn")).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).createTransportLayerResponseMessage(eq(message), 
                eq(TransportLayerMessageType.IsAvailableResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        IsAvailableResponseData response = messageCaptor.getValue();
 
        assertThat(response.getIsAvailable(), is(true));
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
    }
/**
     * Verify a link layer can see if an address is available and returns the correct value, 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 a link layer can see if an address is available and returns the correct value, 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 a link layer can see if an address is available and returns the correct value 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 CCommException, IOException
    {
        IsAvailableRequestData request = IsAvailableRequestData.newBuilder()
                .setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .setAddress("finn")
                .build();
        TransportLayerNamespace transportMessage = TransportLayerNamespace.newBuilder()
                .setType(TransportLayerMessageType.IsAvailableRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestMessage message = createTransportLayerMessage(transportMessage);
        TerraHarvestPayload payload = createPayload(transportMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        Address testAddress = mock(Address.class);
        when(m_AddressManagerService.getOrCreateAddress("finn")).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).createTransportLayerResponseMessage(eq(message), 
                eq(TransportLayerMessageType.IsAvailableResponse), messageCaptor.capture());
        verify(m_ResponseWrapper).queue(channel);
        IsAvailableResponseData response = messageCaptor.getValue();
        assertThat(response.getIsAvailable(), is(true));
        assertThat(response.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
    }
@ Test public void testIsAvailable ( ) throws CCommException , IOException { IsAvailableRequestData request = IsAvailableRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . setAddress ( "finn" ) . build ( ) ; TransportLayerNamespace transportMessage = TransportLayerNamespace . newBuilder ( ) . setType ( TransportLayerMessageType . IsAvailableRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createTransportLayerMessage ( transportMessage ) ; TerraHarvestPayload payload = createPayload ( transportMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Address testAddress = mock ( Address . class ) ; when ( m_AddressManagerService . getOrCreateAddress ( "finn" ) ) . 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 ) . createTransportLayerResponseMessage ( eq ( message ) , eq ( TransportLayerMessageType . IsAvailableResponse ) , messageCaptor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; IsAvailableResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . getIsAvailable ( ) , is ( true ) ) ; assertThat ( response . getUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) ) ; }
Verify a link layer can see if an address is available and returns the correct value, 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 a link layer can see if an address is available and returns the correct value 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 address // verify the event contains the data message //capture and verify response