mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestLinkLayerMessageService.java
@Test
    public void testPerformBITRequest() throws CCommException, IOException
    {
        // create request
        PerformBITRequestData request = PerformBITRequestData.newBuilder()
                .setLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.PerformBITRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        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((PerformBITRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        // make sure perform BIT was called on the test link layer
        verify(testLayer).performBit();
        
        ArgumentCaptor<PerformBITResponseData> captor = ArgumentCaptor.forClass(PerformBITResponseData.class);
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.PerformBITResponse), captor.capture());
        verify(m_ResponseWrapper).queue(channel);

        //verify response
        PerformBITResponseData response = captor.getValue();
        assertThat(response.getLinkUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
        assertThat(response.getPerformBitStatus(), is(CustomCommsTypes.LinkStatus.LOST));
    }
/**
     * Test requesting a link layer to perform its BIT.
     * Verify that a response message is sent.
     */
Test requesting a link layer to perform its BIT.
Verify that a response message is sent.
Test requesting a link layer to perform its BIT . Verify that a response message is sent .
@Test
    public void testPerformBITRequest() throws CCommException, IOException
    {
        PerformBITRequestData request = PerformBITRequestData.newBuilder()
                .setLinkUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid))
                .build();
        LinkLayerNamespace llMessage = LinkLayerNamespace.newBuilder()
                .setType(LinkLayerMessageType.PerformBITRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(llMessage);
        TerraHarvestMessage message = createLinkLayerMessage(llMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((PerformBITRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(testLayer).performBit();
        ArgumentCaptor<PerformBITResponseData> captor = ArgumentCaptor.forClass(PerformBITResponseData.class);
        verify(m_MessageFactory).createLinkLayerResponseMessage(eq(message), 
                eq(LinkLayerMessageType.PerformBITResponse), captor.capture());
        verify(m_ResponseWrapper).queue(channel);
        PerformBITResponseData response = captor.getValue();
        assertThat(response.getLinkUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
        assertThat(response.getPerformBitStatus(), is(CustomCommsTypes.LinkStatus.LOST));
    }
@ Test public void testPerformBITRequest ( ) throws CCommException , IOException { PerformBITRequestData request = PerformBITRequestData . newBuilder ( ) . setLinkUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; LinkLayerNamespace llMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . PerformBITRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( llMessage ) ; TerraHarvestMessage message = createLinkLayerMessage ( llMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( PerformBITRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; verify ( testLayer ) . performBit ( ) ; ArgumentCaptor < PerformBITResponseData > captor = ArgumentCaptor . forClass ( PerformBITResponseData . class ) ; verify ( m_MessageFactory ) . createLinkLayerResponseMessage ( eq ( message ) , eq ( LinkLayerMessageType . PerformBITResponse ) , captor . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; PerformBITResponseData response = captor . getValue ( ) ; assertThat ( response . getLinkUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) ) ; assertThat ( response . getPerformBitStatus ( ) , is ( CustomCommsTypes . LinkStatus . LOST ) ) ; }
Test requesting a link layer to perform its BIT.
Test requesting a link layer to perform its BIT .
// create request // mock the channel the message came from // verify the event contains the data message // make sure perform BIT was called on the test link layer //verify response