mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsMgrImpl.java
@Test
    public void testRemoteLayerAdded()
    {
        Event addRemoteLayer = mockEventLayerCreated(systemId1, "physical");
        m_EventHelper.handleEvent(addRemoteLayer);
        
        List<CommsLayerBaseModel> physicals = m_SUT.getPhysicalsAsync(systemId1);
        assertThat(physicals.size(), is(1)); 
        
        //check uuid and pid
        assertThat(physicals.get(0).getUuid(), is(uuid7));
        assertThat(physicals.get(0).getPid(), is(pid7));
        
        addRemoteLayer = mockEventLayerCreated(systemId1, "link");
        m_EventHelper.handleEvent(addRemoteLayer);
        
        List<CommsLayerLinkModelImpl> links = m_SUT.getLinksAsync(systemId1); 
        assertThat(links.size(), is(1)); 
        
        //check uuid and pid
        assertThat(links.get(0).getUuid(), is(uuid7));
        assertThat(links.get(0).getPid(), is(pid7));
        
        verify(m_MessageFactory).createLinkLayerMessage(eq(LinkLayerMessageType.GetStatusRequest), 
                Mockito.any(Message.class));
        verify(m_MessageWrapper, times(4)).queue(eq(systemId1), (ResponseHandler) eq(null));
        verify(m_MessageFactory).createLinkLayerMessage(eq(LinkLayerMessageType.IsActivatedRequest), 
                Mockito.any(Message.class));
        verify(m_MessageWrapper, times(4)).queue(eq(systemId1), (ResponseHandler) eq(null));
        
        addRemoteLayer = mockEventLayerCreated(systemId1, "transport");
        m_EventHelper.handleEvent(addRemoteLayer);
        
        List<CommsLayerBaseModel> transports = m_SUT.getTransportsAsync(systemId1);
        assertThat(transports.size(), is(1)); 
        
        //check uuid and pid
        assertThat(transports.get(0).getUuid(), is(uuid7));
        assertThat(transports.get(0).getPid(), is(pid7));    
        
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
        //verify push event for remotely adding new layer
        verify(m_EventAdmin, times(3)).postEvent(captor.capture());
        assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
    }
/**
     * Verify correct handling of layer added remotely
     */
Verify correct handling of layer added remotely
Verify correct handling of layer added remotely
@Test
    public void testRemoteLayerAdded()
    {
        Event addRemoteLayer = mockEventLayerCreated(systemId1, "physical");
        m_EventHelper.handleEvent(addRemoteLayer);
        List<CommsLayerBaseModel> physicals = m_SUT.getPhysicalsAsync(systemId1);
        assertThat(physicals.size(), is(1)); 
        assertThat(physicals.get(0).getUuid(), is(uuid7));
        assertThat(physicals.get(0).getPid(), is(pid7));
        addRemoteLayer = mockEventLayerCreated(systemId1, "link");
        m_EventHelper.handleEvent(addRemoteLayer);
        List<CommsLayerLinkModelImpl> links = m_SUT.getLinksAsync(systemId1); 
        assertThat(links.size(), is(1)); 
        assertThat(links.get(0).getUuid(), is(uuid7));
        assertThat(links.get(0).getPid(), is(pid7));
        verify(m_MessageFactory).createLinkLayerMessage(eq(LinkLayerMessageType.GetStatusRequest), 
                Mockito.any(Message.class));
        verify(m_MessageWrapper, times(4)).queue(eq(systemId1), (ResponseHandler) eq(null));
        verify(m_MessageFactory).createLinkLayerMessage(eq(LinkLayerMessageType.IsActivatedRequest), 
                Mockito.any(Message.class));
        verify(m_MessageWrapper, times(4)).queue(eq(systemId1), (ResponseHandler) eq(null));
        addRemoteLayer = mockEventLayerCreated(systemId1, "transport");
        m_EventHelper.handleEvent(addRemoteLayer);
        List<CommsLayerBaseModel> transports = m_SUT.getTransportsAsync(systemId1);
        assertThat(transports.size(), is(1)); 
        assertThat(transports.get(0).getUuid(), is(uuid7));
        assertThat(transports.get(0).getPid(), is(pid7));    
        ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(3)).postEvent(captor.capture());
        assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
    }
@ Test public void testRemoteLayerAdded ( ) { Event addRemoteLayer = mockEventLayerCreated ( systemId1 , "physical" ) ; m_EventHelper . handleEvent ( addRemoteLayer ) ; List < CommsLayerBaseModel > physicals = m_SUT . getPhysicalsAsync ( systemId1 ) ; assertThat ( physicals . size ( ) , is ( 1 ) ) ; assertThat ( physicals . get ( 0 ) . getUuid ( ) , is ( uuid7 ) ) ; assertThat ( physicals . get ( 0 ) . getPid ( ) , is ( pid7 ) ) ; addRemoteLayer = mockEventLayerCreated ( systemId1 , "link" ) ; m_EventHelper . handleEvent ( addRemoteLayer ) ; List < CommsLayerLinkModelImpl > links = m_SUT . getLinksAsync ( systemId1 ) ; assertThat ( links . size ( ) , is ( 1 ) ) ; assertThat ( links . get ( 0 ) . getUuid ( ) , is ( uuid7 ) ) ; assertThat ( links . get ( 0 ) . getPid ( ) , is ( pid7 ) ) ; verify ( m_MessageFactory ) . createLinkLayerMessage ( eq ( LinkLayerMessageType . GetStatusRequest ) , Mockito . any ( Message . class ) ) ; verify ( m_MessageWrapper , times ( 4 ) ) . queue ( eq ( systemId1 ) , ( ResponseHandler ) eq ( null ) ) ; verify ( m_MessageFactory ) . createLinkLayerMessage ( eq ( LinkLayerMessageType . IsActivatedRequest ) , Mockito . any ( Message . class ) ) ; verify ( m_MessageWrapper , times ( 4 ) ) . queue ( eq ( systemId1 ) , ( ResponseHandler ) eq ( null ) ) ; addRemoteLayer = mockEventLayerCreated ( systemId1 , "transport" ) ; m_EventHelper . handleEvent ( addRemoteLayer ) ; List < CommsLayerBaseModel > transports = m_SUT . getTransportsAsync ( systemId1 ) ; assertThat ( transports . size ( ) , is ( 1 ) ) ; assertThat ( transports . get ( 0 ) . getUuid ( ) , is ( uuid7 ) ) ; assertThat ( transports . get ( 0 ) . getPid ( ) , is ( pid7 ) ) ; ArgumentCaptor < Event > captor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 3 ) ) . postEvent ( captor . capture ( ) ) ; assertThat ( captor . getValue ( ) . getTopic ( ) , is ( CommsMgr . TOPIC_COMMS_LAYER_UPDATED ) ) ; }
Verify correct handling of layer added remotely
Verify correct handling of layer added remotely
//check uuid and pid //check uuid and pid //check uuid and pid //verify push event for remotely adding new layer