mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestCommsMgrImpl.java
@Test
    public void testHandleGetStatusResponse()
    {
        // Mini test setup
        m_SUT.getPhysicalsAsync(systemId1);
        m_SUT.getLinksAsync(systemId1);
        m_SUT.getTransportsAsync(systemId1);
        Event transport = mockGetLayersResponse(systemId1, "transport");
        Event link = mockGetLayersResponse(systemId1, "link");
        Event physical = mockGetLayersResponse(systemId1, "physical");
        
        m_EventHelperComms.handleEvent(transport);    
        m_EventHelperComms.handleEvent(link);
        m_EventHelperComms.handleEvent(physical);

        //mock status event after set up
        Event event = mockGetStatusResponse(systemId1, CustomCommsTypes.LinkStatus.OK);
        m_EventHelperLink.handleEvent(event);
        
        List<CommsLayerLinkModelImpl> links = m_SUT.getLinksAsync(systemId1);
        assertThat(links.get(0).getStatusString(), is("OK"));   
        
        event = mockGetStatusResponse(systemId1, CustomCommsTypes.LinkStatus.LOST);
        m_EventHelperLink.handleEvent(event);
        
        links = m_SUT.getLinksAsync(systemId1);
        assertThat(links.get(0).getStatusString(), is("LOST")); 
        
        //test null case
        event = mockGetStatusResponse(systemId1, null);
        try
        {
            m_EventHelperLink.handleEvent(event);
            ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
            //verify push event for local link status response
            verify(m_EventAdmin, times(6)).postEvent(captor.capture());
            assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
        }
        catch(Exception e)
        {
            fail("Unexpected exception caught: " + e.getMessage());
        }        
    }
/**
     * Test proper handling of GetStatus request for link layer namespace.
     * Verify that appropriate link layer from the comms stack is set with the correct status.
     */
Test proper handling of GetStatus request for link layer namespace.
Verify that appropriate link layer from the comms stack is set with the correct status.
Test proper handling of GetStatus request for link layer namespace . Verify that appropriate link layer from the comms stack is set with the correct status .
@Test
    public void testHandleGetStatusResponse()
    {
        m_SUT.getPhysicalsAsync(systemId1);
        m_SUT.getLinksAsync(systemId1);
        m_SUT.getTransportsAsync(systemId1);
        Event transport = mockGetLayersResponse(systemId1, "transport");
        Event link = mockGetLayersResponse(systemId1, "link");
        Event physical = mockGetLayersResponse(systemId1, "physical");
        m_EventHelperComms.handleEvent(transport);    
        m_EventHelperComms.handleEvent(link);
        m_EventHelperComms.handleEvent(physical);
        Event event = mockGetStatusResponse(systemId1, CustomCommsTypes.LinkStatus.OK);
        m_EventHelperLink.handleEvent(event);
        List<CommsLayerLinkModelImpl> links = m_SUT.getLinksAsync(systemId1);
        assertThat(links.get(0).getStatusString(), is("OK"));   
        event = mockGetStatusResponse(systemId1, CustomCommsTypes.LinkStatus.LOST);
        m_EventHelperLink.handleEvent(event);
        links = m_SUT.getLinksAsync(systemId1);
        assertThat(links.get(0).getStatusString(), is("LOST")); 
        event = mockGetStatusResponse(systemId1, null);
        try
        {
            m_EventHelperLink.handleEvent(event);
            ArgumentCaptor<Event> captor = ArgumentCaptor.forClass(Event.class);
            verify(m_EventAdmin, times(6)).postEvent(captor.capture());
            assertThat(captor.getValue().getTopic(), is(CommsMgr.TOPIC_COMMS_LAYER_UPDATED));
        }
        catch(Exception e)
        {
            fail("Unexpected exception caught: " + e.getMessage());
        }        
    }
@ Test public void testHandleGetStatusResponse ( ) { m_SUT . getPhysicalsAsync ( systemId1 ) ; m_SUT . getLinksAsync ( systemId1 ) ; m_SUT . getTransportsAsync ( systemId1 ) ; Event transport = mockGetLayersResponse ( systemId1 , "transport" ) ; Event link = mockGetLayersResponse ( systemId1 , "link" ) ; Event physical = mockGetLayersResponse ( systemId1 , "physical" ) ; m_EventHelperComms . handleEvent ( transport ) ; m_EventHelperComms . handleEvent ( link ) ; m_EventHelperComms . handleEvent ( physical ) ; Event event = mockGetStatusResponse ( systemId1 , CustomCommsTypes . LinkStatus . OK ) ; m_EventHelperLink . handleEvent ( event ) ; List < CommsLayerLinkModelImpl > links = m_SUT . getLinksAsync ( systemId1 ) ; assertThat ( links . get ( 0 ) . getStatusString ( ) , is ( "OK" ) ) ; event = mockGetStatusResponse ( systemId1 , CustomCommsTypes . LinkStatus . LOST ) ; m_EventHelperLink . handleEvent ( event ) ; links = m_SUT . getLinksAsync ( systemId1 ) ; assertThat ( links . get ( 0 ) . getStatusString ( ) , is ( "LOST" ) ) ; event = mockGetStatusResponse ( systemId1 , null ) ; try { m_EventHelperLink . handleEvent ( event ) ; ArgumentCaptor < Event > captor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 6 ) ) . postEvent ( captor . capture ( ) ) ; assertThat ( captor . getValue ( ) . getTopic ( ) , is ( CommsMgr . TOPIC_COMMS_LAYER_UPDATED ) ) ; } catch ( Exception e ) { fail ( "Unexpected exception caught: " + e . getMessage ( ) ) ; } }
Test proper handling of GetStatus request for link layer namespace.
Test proper handling of GetStatus request for link layer namespace .
// Mini test setup //mock status event after set up //test null case //verify push event for local link status response