mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsLayerTypesMgrImpl.java
@Test
    public void testUpdateCommsTypes() throws ObjectConverterException
    {   
        //load assets for system id
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.TransportLayer);

        //this should render two asset types for the system id
        m_CommsHelper.handleEvent(getTypes);

        List<String> transportTypes = m_SUT.getTransportLayerTypes(systemId1);
        //verify
        assertThat(transportTypes.size(), is(3));

        //verify the FQCNs were found
        assertThat(transportTypes, hasItem("class.name.one"));
        assertThat(transportTypes, hasItem("class.name.two"));
        assertThat(transportTypes, hasItem("class.name.three"));
        
        //fake capabilities for type class.name.three in transport layer
        CapabilitiesResponseHandler handler = m_SUT.new CapabilitiesResponseHandler("class.name.three");
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder().
                setDescription("fancy description").setProductName("fancyName").build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder().setBase(baseCaps).build();
        GetCapabilitiesResponseData response = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.three").
                setTransportCapabilities(caps1).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);        
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(new TransportLayerCapabilities());
        handler.handleResponse(thMessage, payload, nameResponse, response);
        
        //mock new layer types
        getTypes = mockMessageGetCommsTypesUpdateResponse(systemId1, CommType.TransportLayer);
        m_CommsHelper.handleEvent(getTypes);
        
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
        //verify push event
        verify(m_EventAdmin, times(2)).postEvent(captor.capture());
        assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
        assertThat(captor.getValue().getPropertyNames().length, is(1));
        assertThat(captor.getValue().getPropertyNames()[0], is("event.topics"));
        
        transportTypes = m_SUT.getTransportLayerTypes(systemId1);
       
        //verify
        assertThat(transportTypes.size(), is(3));

        //verify the FQCNs were found
        assertThat(transportTypes, hasItem("class.name.one"));
        assertThat(transportTypes, hasItem("class.name.two"));
        assertThat(transportTypes, hasItem("class.name.phil"));
    }
/**
     * Verify comms layer types are properly updated and saved. 
     */
Verify comms layer types are properly updated and saved.
Verify comms layer types are properly updated and saved .
@Test
    public void testUpdateCommsTypes() throws ObjectConverterException
    {   
        Event getTypes = mockMessageGetCommsTypesResponse(systemId1, CommType.TransportLayer);
        m_CommsHelper.handleEvent(getTypes);
        List<String> transportTypes = m_SUT.getTransportLayerTypes(systemId1);
        assertThat(transportTypes.size(), is(3));
         the FQCNs were found
        assertThat(transportTypes, hasItem("class.name.one"));
        assertThat(transportTypes, hasItem("class.name.two"));
        assertThat(transportTypes, hasItem("class.name.three"));
        CapabilitiesResponseHandler handler = m_SUT.new CapabilitiesResponseHandler("class.name.three");
        BaseCapabilities baseCaps = BaseCapabilities.newBuilder().
                setDescription("fancy description").setProductName("fancyName").build();
        TransportLayerCapabilitiesGen.TransportLayerCapabilities caps1 = 
                TransportLayerCapabilitiesGen.TransportLayerCapabilities.newBuilder().setBase(baseCaps).build();
        GetCapabilitiesResponseData response = GetCapabilitiesResponseData.newBuilder().
                setCommType(CommType.TransportLayer).setProductType("class.name.three").
                setTransportCapabilities(caps1).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);        
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(new TransportLayerCapabilities());
        handler.handleResponse(thMessage, payload, nameResponse, response);
        getTypes = mockMessageGetCommsTypesUpdateResponse(systemId1, CommType.TransportLayer);
        m_CommsHelper.handleEvent(getTypes);
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
         push event
        verify(m_EventAdmin, times(2)).postEvent(captor.capture());
        assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
        assertThat(captor.getValue().getPropertyNames().length, is(1));
        assertThat(captor.getValue().getPropertyNames()[0], is("event.topics"));
        transportTypes = m_SUT.getTransportLayerTypes(systemId1);
        assertThat(transportTypes.size(), is(3));
         the FQCNs were found
        assertThat(transportTypes, hasItem("class.name.one"));
        assertThat(transportTypes, hasItem("class.name.two"));
        assertThat(transportTypes, hasItem("class.name.phil"));
    }
@ Test public void testUpdateCommsTypes ( ) throws ObjectConverterException { Event getTypes = mockMessageGetCommsTypesResponse ( systemId1 , CommType . TransportLayer ) ; m_CommsHelper . handleEvent ( getTypes ) ; List < String > transportTypes = m_SUT . getTransportLayerTypes ( systemId1 ) ; assertThat ( transportTypes . size ( ) , is ( 3 ) ) ; assertThat ( transportTypes , hasItem ( "class.name.one" ) ) ; assertThat ( transportTypes , hasItem ( "class.name.two" ) ) ; assertThat ( transportTypes , hasItem ( "class.name.three" ) ) ; CapabilitiesResponseHandler handler = m_SUT . new CapabilitiesResponseHandler ( "class.name.three" ) ; BaseCapabilities baseCaps = BaseCapabilities . newBuilder ( ) . setDescription ( "fancy description" ) . setProductName ( "fancyName" ) . build ( ) ; TransportLayerCapabilitiesGen . TransportLayerCapabilities caps1 = TransportLayerCapabilitiesGen . TransportLayerCapabilities . newBuilder ( ) . setBase ( baseCaps ) . build ( ) ; GetCapabilitiesResponseData response = GetCapabilitiesResponseData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setProductType ( "class.name.three" ) . setTransportCapabilities ( caps1 ) . 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 ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( new TransportLayerCapabilities ( ) ) ; handler . handleResponse ( thMessage , payload , nameResponse , response ) ; getTypes = mockMessageGetCommsTypesUpdateResponse ( systemId1 , CommType . TransportLayer ) ; m_CommsHelper . handleEvent ( getTypes ) ; ArgumentCaptor < Event > captor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 2 ) ) . postEvent ( captor . capture ( ) ) ; assertThat ( captor . getValue ( ) . getTopic ( ) , is ( CommsMgr . TOPIC_COMMS_LAYER_UPDATED ) ) ; assertThat ( captor . getValue ( ) . getPropertyNames ( ) . length , is ( 1 ) ) ; assertThat ( captor . getValue ( ) . getPropertyNames ( ) [ 0 ] , is ( "event.topics" ) ) ; transportTypes = m_SUT . getTransportLayerTypes ( systemId1 ) ; assertThat ( transportTypes . size ( ) , is ( 3 ) ) ; assertThat ( transportTypes , hasItem ( "class.name.one" ) ) ; assertThat ( transportTypes , hasItem ( "class.name.two" ) ) ; assertThat ( transportTypes , hasItem ( "class.name.phil" ) ) ; }
Verify comms layer types are properly updated and saved.
Verify comms layer types are properly updated and saved .
//load assets for system id //this should render two asset types for the system id //verify //verify the FQCNs were found //fake capabilities for type class.name.three in transport layer //mock new layer types //verify push event //verify //verify the FQCNs were found