mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/comms/TestAddCommsDialogHelperImpl.java
@Test
    public void testGetDescription()
    {
        String className = "linklayertest";
        CommsStackCreationModel model = m_SUT.getCommsCreationModel();
        model.setSelectedLinkLayerType(className);
        
        //Test no capabilities
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(null);
        assertThat(m_SUT.getLinkLayerDescription(123), is("No Description Found for " + className));       
        
        //Test invalid capabilities
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn("not a Capabilities object");
        assertThat(m_SUT.getLinkLayerDescription(123), is("Invalid Capabilities Object"));       
        
        //Test correct capabilities
        LinkLayerCapabilities llc = mock(LinkLayerCapabilities.class);
        when(llc.getDescription()).thenReturn("linklayerdesc");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(llc);
        assertThat(m_SUT.getLinkLayerDescription(123), is("linklayerdesc"));
        
        //Test Physical Link
        className = "physlinktest";
        String linkName = "test";
        model.setSelectedPhysicalLink(linkName);
        PhysicalLinkCapabilities plc = mock(PhysicalLinkCapabilities.class);
        when(plc.getDescription()).thenReturn("physlinkdesc");
        when(m_CommsMgr.getPhysicalClazzByName(linkName, 123)).thenReturn(className);
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(plc);
        assertThat(m_SUT.getPhysLinkDescription(123), is("physlinkdesc"));
        
        //test physical type
        model.setForceAdd(true);
        className = "physlinktest2";
        model.setSelectedPhysicalType(PhysicalLinkTypeEnum.SERIAL_PORT);
        PhysicalLinkCapabilities plc2 = mock(PhysicalLinkCapabilities.class);
        when(plc2.getDescription()).thenReturn("physlinkdesc2");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(plc2);
        when(m_CommsLayerTypes.getPhysicalLinkClassByType(123, PhysicalLinkTypeEnum.SERIAL_PORT)).thenReturn(className);
        assertThat(m_SUT.getPhysLinkDescription(123), is("physlinkdesc2"));
    
        //Test Transport Layer
        className = "translayertest";
        model.setSelectedTransportLayerType(className);
        TransportLayerCapabilities tlc = mock(TransportLayerCapabilities.class);
        when(tlc.getDescription()).thenReturn("translayerdesc");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(tlc);
        assertThat(m_SUT.getTransLayerDescription(123), is("translayerdesc"));
        
        //test null layer
        model.setSelectedLinkLayerType(null);
        assertThat(m_SUT.getLinkLayerDescription(123), is("Select a Layer to see Description."));
    }
/**
     * Verify retrieval of Link Layer Capabilities Description.
     */
Verify retrieval of Link Layer Capabilities Description.
Verify retrieval of Link Layer Capabilities Description .
@Test
    public void testGetDescription()
    {
        String className = "linklayertest";
        CommsStackCreationModel model = m_SUT.getCommsCreationModel();
        model.setSelectedLinkLayerType(className);
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(null);
        assertThat(m_SUT.getLinkLayerDescription(123), is("No Description Found for " + className));       
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn("not a Capabilities object");
        assertThat(m_SUT.getLinkLayerDescription(123), is("Invalid Capabilities Object"));       
        LinkLayerCapabilities llc = mock(LinkLayerCapabilities.class);
        when(llc.getDescription()).thenReturn("linklayerdesc");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(llc);
        assertThat(m_SUT.getLinkLayerDescription(123), is("linklayerdesc"));
        className = "physlinktest";
        String linkName = "test";
        model.setSelectedPhysicalLink(linkName);
        PhysicalLinkCapabilities plc = mock(PhysicalLinkCapabilities.class);
        when(plc.getDescription()).thenReturn("physlinkdesc");
        when(m_CommsMgr.getPhysicalClazzByName(linkName, 123)).thenReturn(className);
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(plc);
        assertThat(m_SUT.getPhysLinkDescription(123), is("physlinkdesc"));
        model.setForceAdd(true);
        className = "physlinktest2";
        model.setSelectedPhysicalType(PhysicalLinkTypeEnum.SERIAL_PORT);
        PhysicalLinkCapabilities plc2 = mock(PhysicalLinkCapabilities.class);
        when(plc2.getDescription()).thenReturn("physlinkdesc2");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(plc2);
        when(m_CommsLayerTypes.getPhysicalLinkClassByType(123, PhysicalLinkTypeEnum.SERIAL_PORT)).thenReturn(className);
        assertThat(m_SUT.getPhysLinkDescription(123), is("physlinkdesc2"));
        className = "translayertest";
        model.setSelectedTransportLayerType(className);
        TransportLayerCapabilities tlc = mock(TransportLayerCapabilities.class);
        when(tlc.getDescription()).thenReturn("translayerdesc");
        when(m_CommsLayerTypes.getCapabilities(123, className)).thenReturn(tlc);
        assertThat(m_SUT.getTransLayerDescription(123), is("translayerdesc"));
        model.setSelectedLinkLayerType(null);
        assertThat(m_SUT.getLinkLayerDescription(123), is("Select a Layer to see Description."));
    }
@ Test public void testGetDescription ( ) { String className = "linklayertest" ; CommsStackCreationModel model = m_SUT . getCommsCreationModel ( ) ; model . setSelectedLinkLayerType ( className ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( null ) ; assertThat ( m_SUT . getLinkLayerDescription ( 123 ) , is ( "No Description Found for " + className ) ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( "not a Capabilities object" ) ; assertThat ( m_SUT . getLinkLayerDescription ( 123 ) , is ( "Invalid Capabilities Object" ) ) ; LinkLayerCapabilities llc = mock ( LinkLayerCapabilities . class ) ; when ( llc . getDescription ( ) ) . thenReturn ( "linklayerdesc" ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( llc ) ; assertThat ( m_SUT . getLinkLayerDescription ( 123 ) , is ( "linklayerdesc" ) ) ; className = "physlinktest" ; String linkName = "test" ; model . setSelectedPhysicalLink ( linkName ) ; PhysicalLinkCapabilities plc = mock ( PhysicalLinkCapabilities . class ) ; when ( plc . getDescription ( ) ) . thenReturn ( "physlinkdesc" ) ; when ( m_CommsMgr . getPhysicalClazzByName ( linkName , 123 ) ) . thenReturn ( className ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( plc ) ; assertThat ( m_SUT . getPhysLinkDescription ( 123 ) , is ( "physlinkdesc" ) ) ; model . setForceAdd ( true ) ; className = "physlinktest2" ; model . setSelectedPhysicalType ( PhysicalLinkTypeEnum . SERIAL_PORT ) ; PhysicalLinkCapabilities plc2 = mock ( PhysicalLinkCapabilities . class ) ; when ( plc2 . getDescription ( ) ) . thenReturn ( "physlinkdesc2" ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( plc2 ) ; when ( m_CommsLayerTypes . getPhysicalLinkClassByType ( 123 , PhysicalLinkTypeEnum . SERIAL_PORT ) ) . thenReturn ( className ) ; assertThat ( m_SUT . getPhysLinkDescription ( 123 ) , is ( "physlinkdesc2" ) ) ; className = "translayertest" ; model . setSelectedTransportLayerType ( className ) ; TransportLayerCapabilities tlc = mock ( TransportLayerCapabilities . class ) ; when ( tlc . getDescription ( ) ) . thenReturn ( "translayerdesc" ) ; when ( m_CommsLayerTypes . getCapabilities ( 123 , className ) ) . thenReturn ( tlc ) ; assertThat ( m_SUT . getTransLayerDescription ( 123 ) , is ( "translayerdesc" ) ) ; model . setSelectedLinkLayerType ( null ) ; assertThat ( m_SUT . getLinkLayerDescription ( 123 ) , is ( "Select a Layer to see Description." ) ) ; }
Verify retrieval of Link Layer Capabilities Description.
Verify retrieval of Link Layer Capabilities Description .
//Test no capabilities //Test invalid capabilities //Test correct capabilities //Test Physical Link //test physical type //Test Transport Layer //test null layer