mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public final void testGetPhysicalLinkCapabilities() throws UnmarshalException, ObjectConverterException, IOException
    {  
        CustomCommsNamespace physicalLinkMessage = 
                this.createGetCapsRequestMessage(CommType.PhysicalLink, PhysicalLink.class.getName());
        TerraHarvestPayload payload = createPayload(physicalLinkMessage);
        TerraHarvestMessage message = createCustomCommsMessage(physicalLinkMessage);
        
        Message capsGen = PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities.newBuilder().
                setBase(BaseCapabilitiesGen.BaseCapabilities.newBuilder().
                    setManufacturer("Super Cool Physical Links Inc").
                    setDescription("The best physical link.").
                    setProductName("CoolPhysicalLink")).
                setLinkType(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT).build();
        
        //mock necessary objects/actions
        PhysicalLinkCapabilities capabilities = mock(PhysicalLinkCapabilities.class);
        when(m_PhysicalLinkFactory.getPhysicalLinkCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).thenReturn(capsGen);
        
        //mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // reply
        m_SUT.handleMessage(message, payload, channel);
        
        //capture and verify event has been posted locally
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((GetCapabilitiesRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(GetCapabilitiesRequestData.newBuilder().
                        setCommType(CommType.PhysicalLink).setProductType(PhysicalLink.class.getName()).build()));
        
        //capture and verify response
        ArgumentCaptor<GetCapabilitiesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetCapabilitiesResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message),
                eq(CustomCommsMessageType.GetCapabilitiesResponse), messageCaptor.capture());
        
        GetCapabilitiesResponseData response = messageCaptor.getValue();
        
        //ensure all necessary fields are set
        assertThat(response.hasPhysicalCapabilities(), is(true));
        assertThat(response.getPhysicalCapabilities(), is(capsGen));
        assertThat(response.getProductType(), is(PhysicalLink.class.getName()));
        m_SUT.deactivate();
    }
/**
     * Test the get capabilities request/response message system for physical link.
     * Specifically, the following behaviors are tested:
     *     Verify incoming request message is posted to the event admin.
     *     Verify capabilities are gotten from the appropriate physical factory.
     *     Verify response (containing correct data) is sent after completing request.
     */
Test the get capabilities request/response message system for physical link.
Specifically, the following behaviors are tested:
Verify incoming request message is posted to the event admin.
Verify capabilities are gotten from the appropriate physical factory.
Verify response (containing correct data) is sent after completing request.
Test the get capabilities request / response message system for physical link . Specifically the following behaviors are tested : Verify incoming request message is posted to the event admin . Verify capabilities are gotten from the appropriate physical factory . Verify response ( containing correct data ) is sent after completing request .
@Test
    public final void testGetPhysicalLinkCapabilities() throws UnmarshalException, ObjectConverterException, IOException
    {  
        CustomCommsNamespace physicalLinkMessage = 
                this.createGetCapsRequestMessage(CommType.PhysicalLink, PhysicalLink.class.getName());
        TerraHarvestPayload payload = createPayload(physicalLinkMessage);
        TerraHarvestMessage message = createCustomCommsMessage(physicalLinkMessage);
        Message capsGen = PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities.newBuilder().
                setBase(BaseCapabilitiesGen.BaseCapabilities.newBuilder().
                    setManufacturer("Super Cool Physical Links Inc").
                    setDescription("The best physical link.").
                    setProductName("CoolPhysicalLink")).
                setLinkType(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT).build();
        PhysicalLinkCapabilities capabilities = mock(PhysicalLinkCapabilities.class);
        when(m_PhysicalLinkFactory.getPhysicalLinkCapabilities()).thenReturn(capabilities);
        when(m_Converter.convertToProto(capabilities)).thenReturn(capsGen);
        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((GetCapabilitiesRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(GetCapabilitiesRequestData.newBuilder().
                        setCommType(CommType.PhysicalLink).setProductType(PhysicalLink.class.getName()).build()));
        ArgumentCaptor<GetCapabilitiesResponseData> messageCaptor = ArgumentCaptor.
                forClass(GetCapabilitiesResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message),
                eq(CustomCommsMessageType.GetCapabilitiesResponse), messageCaptor.capture());
        GetCapabilitiesResponseData response = messageCaptor.getValue();
        assertThat(response.hasPhysicalCapabilities(), is(true));
        assertThat(response.getPhysicalCapabilities(), is(capsGen));
        assertThat(response.getProductType(), is(PhysicalLink.class.getName()));
        m_SUT.deactivate();
    }
@ Test public final void testGetPhysicalLinkCapabilities ( ) throws UnmarshalException , ObjectConverterException , IOException { CustomCommsNamespace physicalLinkMessage = this . createGetCapsRequestMessage ( CommType . PhysicalLink , PhysicalLink . class . getName ( ) ) ; TerraHarvestPayload payload = createPayload ( physicalLinkMessage ) ; TerraHarvestMessage message = createCustomCommsMessage ( physicalLinkMessage ) ; Message capsGen = PhysicalLinkCapabilitiesGen . PhysicalLinkCapabilities . newBuilder ( ) . setBase ( BaseCapabilitiesGen . BaseCapabilities . newBuilder ( ) . setManufacturer ( "Super Cool Physical Links Inc" ) . setDescription ( "The best physical link." ) . setProductName ( "CoolPhysicalLink" ) ) . setLinkType ( CustomCommTypesGen . PhysicalLinkType . Enum . SERIAL_PORT ) . build ( ) ; PhysicalLinkCapabilities capabilities = mock ( PhysicalLinkCapabilities . class ) ; when ( m_PhysicalLinkFactory . getPhysicalLinkCapabilities ( ) ) . thenReturn ( capabilities ) ; when ( m_Converter . convertToProto ( capabilities ) ) . thenReturn ( capsGen ) ; 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 ( ( GetCapabilitiesRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( GetCapabilitiesRequestData . newBuilder ( ) . setCommType ( CommType . PhysicalLink ) . setProductType ( PhysicalLink . class . getName ( ) ) . build ( ) ) ) ; ArgumentCaptor < GetCapabilitiesResponseData > messageCaptor = ArgumentCaptor . forClass ( GetCapabilitiesResponseData . class ) ; verify ( m_MessageFactory ) . createCustomCommsResponseMessage ( eq ( message ) , eq ( CustomCommsMessageType . GetCapabilitiesResponse ) , messageCaptor . capture ( ) ) ; GetCapabilitiesResponseData response = messageCaptor . getValue ( ) ; assertThat ( response . hasPhysicalCapabilities ( ) , is ( true ) ) ; assertThat ( response . getPhysicalCapabilities ( ) , is ( capsGen ) ) ; assertThat ( response . getProductType ( ) , is ( PhysicalLink . class . getName ( ) ) ) ; m_SUT . deactivate ( ) ; }
Test the get capabilities request/response message system for physical link.
Test the get capabilities request / response message system for physical link .
//mock necessary objects/actions //mock the channel the message came from // reply //capture and verify event has been posted locally //capture and verify response //ensure all necessary fields are set