mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsLayerTypesMgrImpl.java
@Test
    public void testGetImageLinkLayer() throws ObjectConverterException
    {
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.Linklayer);
        m_CommsHelper.handleEvent(getTypes);
        
        CapabilitiesResponseHandler capsHandler = m_SUT.new CapabilitiesResponseHandler("class.name.two");
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        LinkLayerCapabilitiesGen.LinkLayerCapabilities caps = 
                LinkLayerCapabilitiesGen.LinkLayerCapabilities.newBuilder()
                .setBase(baseCaps)
                .setStaticMtu(false)
                .setPhysicalLinkRequired(true)
                .addPhysicalLinksSupported(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .setPerformBITSupported(false)
                .setModality(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .setSupportsAddressing(false)
                .build();
        
        GetCapabilitiesResponseData response = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.Linklayer).setProductType("class.name.two").
                setLinkCapabilities(caps).build();
        CustomCommsNamespace nameResponse = CustomCommsNamespace.newBuilder().
                setData(response.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
                setNamespaceMessage(response.toByteString()).build(); 
        
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse);
        
        LinkLayerCapabilities lCaps = mock(LinkLayerCapabilities.class);
        when(lCaps.getModality()).thenReturn(LinkLayerTypeEnum.LINE_OF_SIGHT);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(lCaps);
        
        capsHandler.handleResponse(thMessage, payload, nameResponse, response);
        
        String expectingLinkImg = m_SUT.getImage("class.name.two", systemId1);
        assertThat(expectingLinkImg, is("thoseIcons/comms/comms_line_of_sight.png"));
        
        when(lCaps.getModality()).thenReturn(null);
        String expectingGeneric = m_SUT.getImage("class.name.two", systemId1);
        assertThat(expectingGeneric, is("thoseIcons/comms/comms_generic.png"));
    }
/**
     * Verify that an image is properly retrieved when a link layer is known. 
     */
Verify that an image is properly retrieved when a link layer is known.
Verify that an image is properly retrieved when a link layer is known .
@Test
    public void testGetImageLinkLayer() throws ObjectConverterException
    {
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.Linklayer);
        m_CommsHelper.handleEvent(getTypes);
        CapabilitiesResponseHandler capsHandler = m_SUT.new CapabilitiesResponseHandler("class.name.two");
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        LinkLayerCapabilitiesGen.LinkLayerCapabilities caps = 
                LinkLayerCapabilitiesGen.LinkLayerCapabilities.newBuilder()
                .setBase(baseCaps)
                .setStaticMtu(false)
                .setPhysicalLinkRequired(true)
                .addPhysicalLinksSupported(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .setPerformBITSupported(false)
                .setModality(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .setSupportsAddressing(false)
                .build();
        GetCapabilitiesResponseData response = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.Linklayer).setProductType("class.name.two").
                setLinkCapabilities(caps).build();
        CustomCommsNamespace nameResponse = CustomCommsNamespace.newBuilder().
                setData(response.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
                setNamespaceMessage(response.toByteString()).build(); 
        TerraHarvestMessage thMessage = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse);
        LinkLayerCapabilities lCaps = mock(LinkLayerCapabilities.class);
        when(lCaps.getModality()).thenReturn(LinkLayerTypeEnum.LINE_OF_SIGHT);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(lCaps);
        capsHandler.handleResponse(thMessage, payload, nameResponse, response);
        String expectingLinkImg = m_SUT.getImage("class.name.two", systemId1);
        assertThat(expectingLinkImg, is("thoseIcons/comms/comms_line_of_sight.png"));
        when(lCaps.getModality()).thenReturn(null);
        String expectingGeneric = m_SUT.getImage("class.name.two", systemId1);
        assertThat(expectingGeneric, is("thoseIcons/comms/comms_generic.png"));
    }
@ Test public void testGetImageLinkLayer ( ) throws ObjectConverterException { Event getTypes = mockMessageGetCommsTypesResponse ( systemId1 , CommType . Linklayer ) ; m_CommsHelper . handleEvent ( getTypes ) ; CapabilitiesResponseHandler capsHandler = m_SUT . new CapabilitiesResponseHandler ( "class.name.two" ) ; BaseCapabilities baseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; LinkLayerCapabilitiesGen . LinkLayerCapabilities caps = LinkLayerCapabilitiesGen . LinkLayerCapabilities . newBuilder ( ) . setBase ( baseCaps ) . setStaticMtu ( false ) . setPhysicalLinkRequired ( true ) . addPhysicalLinksSupported ( CustomCommTypesGen . PhysicalLinkType . Enum . SERIAL_PORT ) . setPerformBITSupported ( false ) . setModality ( CustomCommTypesGen . LinkLayerType . Enum . LINE_OF_SIGHT ) . setSupportsAddressing ( false ) . build ( ) ; GetCapabilitiesResponseData response = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . Linklayer ) . setProductType ( "class.name.two" ) . setLinkCapabilities ( caps ) . build ( ) ; CustomCommsNamespace nameResponse = CustomCommsNamespace . newBuilder ( ) . setData ( response . toByteString ( ) ) . setType ( CustomCommsMessageType . GetCapabilitiesResponse ) . build ( ) ; TerraHarvestPayload payload = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . CustomComms ) . setNamespaceMessage ( response . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . CustomComms , 123 , nameResponse ) ; LinkLayerCapabilities lCaps = mock ( LinkLayerCapabilities . class ) ; when ( lCaps . getModality ( ) ) . thenReturn ( LinkLayerTypeEnum . LINE_OF_SIGHT ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( lCaps ) ; capsHandler . handleResponse ( thMessage , payload , nameResponse , response ) ; String expectingLinkImg = m_SUT . getImage ( "class.name.two" , systemId1 ) ; assertThat ( expectingLinkImg , is ( "thoseIcons/comms/comms_line_of_sight.png" ) ) ; when ( lCaps . getModality ( ) ) . thenReturn ( null ) ; String expectingGeneric = m_SUT . getImage ( "class.name.two" , systemId1 ) ; assertThat ( expectingGeneric , is ( "thoseIcons/comms/comms_generic.png" ) ) ; }
Verify that an image is properly retrieved when a link layer is known.
Verify that an image is properly retrieved when a link layer is known .