mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testIsAvailableExceptions() throws CCommException, IOException
    {
        // 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);
        
        //----Test Custom Comms Exception----
        doThrow(new CCommException(FormatProblem.BUFFER_OVERFLOW)).when(m_AddressManagerService).getOrCreateAddress(
                "woof");
        
        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
        verify(m_MessageFactory).createBaseErrorMessage(eq(message), 
                eq(ErrorCode.CCOMM_ERROR), Mockito.anyString());
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Verify event posted for request message even after an exception is thrown, verify event property key in the 
     * posted event is the correct request for the message that was sent, as well as verify that the error response 
     * message sent has the correct error code and correct arguments.
     */
Verify event posted for request message even after an exception is thrown, verify event property key in the
posted event is the correct request for the message that was sent, as well as verify that the error response
message sent has the correct error code and correct arguments.
Verify event posted for request message even after an exception is thrown verify event property key in the posted event is the correct request for the message that was sent as well as verify that the error response message sent has the correct error code and correct arguments .
@Test
    public void testIsAvailableExceptions() throws CCommException, IOException
    {
        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);
        doThrow(new CCommException(FormatProblem.BUFFER_OVERFLOW)).when(m_AddressManagerService).getOrCreateAddress(
                "woof");
        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));
        verify(m_MessageFactory).createBaseErrorMessage(eq(message), 
                eq(ErrorCode.CCOMM_ERROR), Mockito.anyString());
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testIsAvailableExceptions ( ) throws CCommException , IOException { 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 ) ; doThrow ( new CCommException ( FormatProblem . BUFFER_OVERFLOW ) ) . when ( m_AddressManagerService ) . getOrCreateAddress ( "woof" ) ; 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 ) ) ; verify ( m_MessageFactory ) . createBaseErrorMessage ( eq ( message ) , eq ( ErrorCode . CCOMM_ERROR ) , Mockito . anyString ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Verify event posted for request message even after an exception is thrown, verify event property key in the
 posted event is the correct request for the message that was sent, as well as verify that the error response
 message sent has the correct error code and correct arguments.
Verify event posted for request message even after an exception is thrown verify event property key in the posted event is the correct request for the message that was sent as well as verify that the error response message sent has the correct error code and correct arguments .
// build the terra harvest message // mock the channel the message came from //----Test Custom Comms Exception---- // verify the event contains the data message //capture and verify response