mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsLayerTypesMgrImpl.java
@Test
    public void testCapabilitiesHandler() throws ObjectConverterException
    {
        //new handlers
        CapabilitiesResponseHandler handler1 = m_SUT.new CapabilitiesResponseHandler("class.name.one");
        CapabilitiesResponseHandler handler2 = m_SUT.new CapabilitiesResponseHandler("class.name.two");
        CapabilitiesResponseHandler handler3 = m_SUT.new CapabilitiesResponseHandler("class.name.three");
        
        //fake capabilities for each layer
        BaseCapabilities transBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder()
                .setBase(transBaseCaps)
                .build();  
        
        BaseCapabilities linkBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        LinkLayerCapabilitiesGen.LinkLayerCapabilities caps2 = 
                LinkLayerCapabilitiesGen.LinkLayerCapabilities.newBuilder()
                .setBase(linkBaseCaps)
                .setStaticMtu(false)
                .setPhysicalLinkRequired(true)
                .addPhysicalLinksSupported(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .setPerformBITSupported(false)
                .setSupportsAddressing(false)
                .setModality(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .build();   
                
        BaseCapabilities physBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities caps3 = 
                PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities.newBuilder()
                .setBase(physBaseCaps)
                .setLinkType(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .build();
        
        //response messages to process
        GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.one").
                setTransportCapabilities(caps1).build();
        GetCapabilitiesResponseData response2 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.Linklayer).setProductType("class.name.two").
                setLinkCapabilities(caps2).build();
        GetCapabilitiesResponseData response3 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.PhysicalLink).setProductType("class.name.three").
                setPhysicalCapabilities(caps3).build();

        CustomCommsNamespace nameResponse1 = CustomCommsNamespace.newBuilder().
            setData(response1.toByteString()).
            setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        CustomCommsNamespace nameResponse2 = CustomCommsNamespace.newBuilder().
                setData(response2.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        CustomCommsNamespace nameResponse3 = CustomCommsNamespace.newBuilder().
                setData(response3.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();

        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response1.toByteString()).build();  
        TerraHarvestPayload payload2 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response2.toByteString()).build(); 
        TerraHarvestPayload payload3 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response3.toByteString()).build(); 
            
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
            Namespace.CustomComms, 123, nameResponse1);
        TerraHarvestMessage thMessage2 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse2);
        TerraHarvestMessage thMessage3 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse3);
        
        when(m_Converter.convertToJaxb(caps1)).thenReturn(new TransportLayerCapabilities());
        when(m_Converter.convertToJaxb(caps2)).thenReturn(new LinkLayerCapabilities());
        when(m_Converter.convertToJaxb(caps3)).thenReturn(new PhysicalLinkCapabilities());
        
        //handle fake response
        handler1.handleResponse(thMessage1, payload1, nameResponse1, response1);
        handler2.handleResponse(thMessage2, payload2, nameResponse2, response2);
        handler3.handleResponse(thMessage3, payload3, nameResponse3, response3);
        
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.one"), is(notNullValue()));
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.two"), is(notNullValue()));
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.three"), is(notNullValue()));    
        
        assertThat(m_SUT.getCapabilities(8675309, "jennyJenny"), is(nullValue()));
    }
/**
     * Verify capabilities handler handles get capabilities correctly. 
     */
Verify capabilities handler handles get capabilities correctly.
Verify capabilities handler handles get capabilities correctly .
@Test
    public void testCapabilitiesHandler() throws ObjectConverterException
    {
        CapabilitiesResponseHandler handler1 = m_SUT.new CapabilitiesResponseHandler("class.name.one");
        CapabilitiesResponseHandler handler2 = m_SUT.new CapabilitiesResponseHandler("class.name.two");
        CapabilitiesResponseHandler handler3 = m_SUT.new CapabilitiesResponseHandler("class.name.three");
        BaseCapabilities transBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder()
                .setBase(transBaseCaps)
                .build();  
        BaseCapabilities linkBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        LinkLayerCapabilitiesGen.LinkLayerCapabilities caps2 = 
                LinkLayerCapabilitiesGen.LinkLayerCapabilities.newBuilder()
                .setBase(linkBaseCaps)
                .setStaticMtu(false)
                .setPhysicalLinkRequired(true)
                .addPhysicalLinksSupported(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .setPerformBITSupported(false)
                .setSupportsAddressing(false)
                .setModality(CustomCommTypesGen.LinkLayerType.Enum.LINE_OF_SIGHT)
                .build();   
        BaseCapabilities physBaseCaps = BaseCapabilities.newBuilder()
                .setDescription("fancy description")
                .setProductName("fancyName")
                .build();
        PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities caps3 = 
                PhysicalLinkCapabilitiesGen.PhysicalLinkCapabilities.newBuilder()
                .setBase(physBaseCaps)
                .setLinkType(CustomCommTypesGen.PhysicalLinkType.Enum.SERIAL_PORT)
                .build();
        GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.one").
                setTransportCapabilities(caps1).build();
        GetCapabilitiesResponseData response2 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.Linklayer).setProductType("class.name.two").
                setLinkCapabilities(caps2).build();
        GetCapabilitiesResponseData response3 = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.PhysicalLink).setProductType("class.name.three").
                setPhysicalCapabilities(caps3).build();
        CustomCommsNamespace nameResponse1 = CustomCommsNamespace.newBuilder().
            setData(response1.toByteString()).
            setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        CustomCommsNamespace nameResponse2 = CustomCommsNamespace.newBuilder().
                setData(response2.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        CustomCommsNamespace nameResponse3 = CustomCommsNamespace.newBuilder().
                setData(response3.toByteString()).
                setType(CustomCommsMessageType.GetCapabilitiesResponse).build();
        TerraHarvestPayload payload1 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response1.toByteString()).build();  
        TerraHarvestPayload payload2 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response2.toByteString()).build(); 
        TerraHarvestPayload payload3 = TerraHarvestPayload.newBuilder().setNamespace(Namespace.CustomComms).
            setNamespaceMessage(response3.toByteString()).build(); 
        TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
            Namespace.CustomComms, 123, nameResponse1);
        TerraHarvestMessage thMessage2 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse2);
        TerraHarvestMessage thMessage3 = TerraHarvestMessageHelper.createTerraHarvestMessage(systemId1, 0,
                Namespace.CustomComms, 123, nameResponse3);
        when(m_Converter.convertToJaxb(caps1)).thenReturn(new TransportLayerCapabilities());
        when(m_Converter.convertToJaxb(caps2)).thenReturn(new LinkLayerCapabilities());
        when(m_Converter.convertToJaxb(caps3)).thenReturn(new PhysicalLinkCapabilities());
        handler1.handleResponse(thMessage1, payload1, nameResponse1, response1);
        handler2.handleResponse(thMessage2, payload2, nameResponse2, response2);
        handler3.handleResponse(thMessage3, payload3, nameResponse3, response3);
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.one"), is(notNullValue()));
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.two"), is(notNullValue()));
        assertThat(m_SUT.getCapabilities(systemId1, "class.name.three"), is(notNullValue()));    
        assertThat(m_SUT.getCapabilities(8675309, "jennyJenny"), is(nullValue()));
    }
@ Test public void testCapabilitiesHandler ( ) throws ObjectConverterException { CapabilitiesResponseHandler handler1 = m_SUT . new CapabilitiesResponseHandler ( "class.name.one" ) ; CapabilitiesResponseHandler handler2 = m_SUT . new CapabilitiesResponseHandler ( "class.name.two" ) ; CapabilitiesResponseHandler handler3 = m_SUT . new CapabilitiesResponseHandler ( "class.name.three" ) ; BaseCapabilities transBaseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; TransportLayerCapabilitiesGen . TransportLayerCapabilities caps1 = TransportLayerCapabilitiesGen . TransportLayerCapabilities . newBuilder ( ) . setBase ( transBaseCaps ) . build ( ) ; BaseCapabilities linkBaseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; LinkLayerCapabilitiesGen . LinkLayerCapabilities caps2 = LinkLayerCapabilitiesGen . LinkLayerCapabilities . newBuilder ( ) . setBase ( linkBaseCaps ) . setStaticMtu ( false ) . setPhysicalLinkRequired ( true ) . addPhysicalLinksSupported ( CustomCommTypesGen . PhysicalLinkType . Enum . SERIAL_PORT ) . setPerformBITSupported ( false ) . setSupportsAddressing ( false ) . setModality ( CustomCommTypesGen . LinkLayerType . Enum . LINE_OF_SIGHT ) . build ( ) ; BaseCapabilities physBaseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; PhysicalLinkCapabilitiesGen . PhysicalLinkCapabilities caps3 = PhysicalLinkCapabilitiesGen . PhysicalLinkCapabilities . newBuilder ( ) . setBase ( physBaseCaps ) . setLinkType ( CustomCommTypesGen . PhysicalLinkType . Enum . SERIAL_PORT ) . build ( ) ; GetCapabilitiesResponseData response1 = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setProductType ( "class.name.one" ) . setTransportCapabilities ( caps1 ) . build ( ) ; GetCapabilitiesResponseData response2 = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . Linklayer ) . setProductType ( "class.name.two" ) . setLinkCapabilities ( caps2 ) . build ( ) ; GetCapabilitiesResponseData response3 = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . PhysicalLink ) . setProductType ( "class.name.three" ) . setPhysicalCapabilities ( caps3 ) . build ( ) ; CustomCommsNamespace nameResponse1 = CustomCommsNamespace . newBuilder ( ) . setData ( response1 . toByteString ( ) ) . setType ( CustomCommsMessageType . GetCapabilitiesResponse ) . build ( ) ; CustomCommsNamespace nameResponse2 = CustomCommsNamespace . newBuilder ( ) . setData ( response2 . toByteString ( ) ) . setType ( CustomCommsMessageType . GetCapabilitiesResponse ) . build ( ) ; CustomCommsNamespace nameResponse3 = CustomCommsNamespace . newBuilder ( ) . setData ( response3 . toByteString ( ) ) . setType ( CustomCommsMessageType . GetCapabilitiesResponse ) . build ( ) ; TerraHarvestPayload payload1 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . CustomComms ) . setNamespaceMessage ( response1 . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload2 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . CustomComms ) . setNamespaceMessage ( response2 . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload3 = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . CustomComms ) . setNamespaceMessage ( response3 . toByteString ( ) ) . build ( ) ; TerraHarvestMessage thMessage1 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . CustomComms , 123 , nameResponse1 ) ; TerraHarvestMessage thMessage2 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . CustomComms , 123 , nameResponse2 ) ; TerraHarvestMessage thMessage3 = TerraHarvestMessageHelper . createTerraHarvestMessage ( systemId1 , 0 , Namespace . CustomComms , 123 , nameResponse3 ) ; when ( m_Converter . convertToJaxb ( caps1 ) ) . thenReturn ( new TransportLayerCapabilities ( ) ) ; when ( m_Converter . convertToJaxb ( caps2 ) ) . thenReturn ( new LinkLayerCapabilities ( ) ) ; when ( m_Converter . convertToJaxb ( caps3 ) ) . thenReturn ( new PhysicalLinkCapabilities ( ) ) ; handler1 . handleResponse ( thMessage1 , payload1 , nameResponse1 , response1 ) ; handler2 . handleResponse ( thMessage2 , payload2 , nameResponse2 , response2 ) ; handler3 . handleResponse ( thMessage3 , payload3 , nameResponse3 , response3 ) ; assertThat ( m_SUT . getCapabilities ( systemId1 , "class.name.one" ) , is ( notNullValue ( ) ) ) ; assertThat ( m_SUT . getCapabilities ( systemId1 , "class.name.two" ) , is ( notNullValue ( ) ) ) ; assertThat ( m_SUT . getCapabilities ( systemId1 , "class.name.three" ) , is ( notNullValue ( ) ) ) ; assertThat ( m_SUT . getCapabilities ( 8675309 , "jennyJenny" ) , is ( nullValue ( ) ) ) ; }
Verify capabilities handler handles get capabilities correctly.
Verify capabilities handler handles get capabilities correctly .
//new handlers //fake capabilities for each layer //response messages to process //handle fake response