mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsLayerTypesMgrImpl.java
@Test
    public void testGetImageTransport() throws ObjectConverterException
    {
        //put comms transport layers in
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.TransportLayer);
        m_CommsHelper.handleEvent(getTypes);
        
        //new handlers
        CapabilitiesResponseHandler handler1 = m_SUT.new CapabilitiesResponseHandler("class.name.one");
       
        //fake capabilities for each layer
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder()
                .setBase(baseCaps)
                .addLinkLayerModalitiesSupported(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .build();        
       
        //response messages to process
        GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.one").
                setTransportCapabilities(caps1).build();
       
        CustomCommsNamespace nameResponse1 = CustomCommsNamespace.newBuilder().
            setData(response1.toByteString()).
            setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
       
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response1.toByteString()).build();  
       
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
            Namespace.CustomComms, 123, nameResponse1);
       
        TransportLayerCapabilities tCaps = mock(TransportLayerCapabilities.class);
        List<LinkLayerTypeEnum> enumList = new ArrayList<LinkLayerTypeEnum>();
        enumList.add(LinkLayerTypeEnum.LINE_OF_SIGHT);
        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(enumList);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(tCaps);
      
        //handle fake response
        handler1.handleResponse(thMessage1, payload1, nameResponse1, response1);
        
        String expectingTransportImg = m_SUT.getImage("class.name.one", systemId1);
        
        assertThat(expectingTransportImg, is("thoseIcons/comms/comms_line_of_sight.png"));

        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(null);
        String expectingGenericImg = m_SUT.getImage("class.name.one", systemId1);
        assertThat(expectingGenericImg, is("thoseIcons/comms/comms_generic.png"));
        
        enumList.clear();
        
        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(enumList);
        expectingGenericImg = "";
        expectingGenericImg = m_SUT.getImage("class.name.one", systemId1);
        assertThat(expectingGenericImg, is("thoseIcons/comms/comms_generic.png"));
    }
/**
     * Verify that an image is properly retrieved when a transport is known.
     */
Verify that an image is properly retrieved when a transport is known.
Verify that an image is properly retrieved when a transport is known .
@Test
    public void testGetImageTransport() throws ObjectConverterException
    {
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.TransportLayer);
        m_CommsHelper.handleEvent(getTypes);
        CapabilitiesResponseHandler handler1 = m_SUT.new CapabilitiesResponseHandler("class.name.one");
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder()
                .setBase(baseCaps)
                .addLinkLayerModalitiesSupported(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .build();        
        GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.one").
                setTransportCapabilities(caps1).build();
        CustomCommsNamespace nameResponse1 = CustomCommsNamespace.newBuilder().
            setData(response1.toByteString()).
            setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response1.toByteString()).build();  
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
            Namespace.CustomComms, 123, nameResponse1);
        TransportLayerCapabilities tCaps = mock(TransportLayerCapabilities.class);
        List<LinkLayerTypeEnum> enumList = new ArrayList<LinkLayerTypeEnum>();
        enumList.add(LinkLayerTypeEnum.LINE_OF_SIGHT);
        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(enumList);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(tCaps);
        handler1.handleResponse(thMessage1, payload1, nameResponse1, response1);
        String expectingTransportImg = m_SUT.getImage("class.name.one", systemId1);
        assertThat(expectingTransportImg, is("thoseIcons/comms/comms_line_of_sight.png"));
        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(null);
        String expectingGenericImg = m_SUT.getImage("class.name.one", systemId1);
        assertThat(expectingGenericImg, is("thoseIcons/comms/comms_generic.png"));
        enumList.clear();
        when(tCaps.getLinkLayerModalitiesSupported()).thenReturn(enumList);
        expectingGenericImg = "";
        expectingGenericImg = m_SUT.getImage("class.name.one", systemId1);
        assertThat(expectingGenericImg, is("thoseIcons/comms/comms_generic.png"));
    }
@ Test public void testGetImageTransport ( ) throws ObjectConverterException { Event getTypes = mockMessageGetCommsTypesResponse ( systemId1 , CommType . TransportLayer ) ; m_CommsHelper . handleEvent ( getTypes ) ; CapabilitiesResponseHandler handler1 = m_SUT . new CapabilitiesResponseHandler ( "class.name.one" ) ; BaseCapabilities baseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; TransportLayerCapabilitiesGen . TransportLayerCapabilities caps1 = TransportLayerCapabilitiesGen . TransportLayerCapabilities . newBuilder ( ) . setBase ( baseCaps ) . addLinkLayerModalitiesSupported ( CustomCommTypesGen . LinkLayerType . Enum . LINE_OF_SIGHT ) . build ( ) ; GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setProductType ( "class.name.one" ) . setTransportCapabilities ( caps1 ) . build ( ) ; CustomCommsNamespace nameResponse1 = CustomCommsNamespace . newBuilder ( ) . setData ( response1 . toByteString ( ) ) . setType ( CustomCommsMessageType . GetCapabilitiesResponse ) . build ( ) ; TerraHarvestPayload payload1 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . CustomComms ) . setNamespaceMessage ( response1 . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . CustomComms , 123 , nameResponse1 ) ; TransportLayerCapabilities tCaps = mock ( TransportLayerCapabilities . class ) ; List < LinkLayerTypeEnum > enumList = new ArrayList < LinkLayerTypeEnum > ( ) ; enumList . add ( LinkLayerTypeEnum . LINE_OF_SIGHT ) ; when ( tCaps . getLinkLayerModalitiesSupported ( ) ) . thenReturn ( enumList ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( tCaps ) ; handler1 . handleResponse ( thMessage1 , payload1 , nameResponse1 , response1 ) ; String expectingTransportImg = m_SUT . getImage ( "class.name.one" , systemId1 ) ; assertThat ( expectingTransportImg , is ( "thoseIcons/comms/comms_line_of_sight.png" ) ) ; when ( tCaps . getLinkLayerModalitiesSupported ( ) ) . thenReturn ( null ) ; String expectingGenericImg = m_SUT . getImage ( "class.name.one" , systemId1 ) ; assertThat ( expectingGenericImg , is ( "thoseIcons/comms/comms_generic.png" ) ) ; enumList . clear ( ) ; when ( tCaps . getLinkLayerModalitiesSupported ( ) ) . thenReturn ( enumList ) ; expectingGenericImg = "" ; expectingGenericImg = m_SUT . getImage ( "class.name.one" , systemId1 ) ; assertThat ( expectingGenericImg , is ( "thoseIcons/comms/comms_generic.png" ) ) ; }
Verify that an image is properly retrieved when a transport is known.
Verify that an image is properly retrieved when a transport is known .
//put comms transport layers in //new handlers //fake capabilities for each layer //response messages to process //handle fake response