mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/channel/TestChannelGuiDialogHelper.java
@Test
    public void testValidateTransportDoesNotExist()
    {
        UIComponent component = mock(UIComponent.class);
        
        UIInput local = mock(UIInput.class);
        UIInput remote = mock(UIInput.class);
        
        when(local.getId()).thenReturn("localAddress");
        when(remote.getId()).thenReturn("remoteAddress");
        
        when(local.getLocalValue()).thenReturn("4000");
        when(remote.getLocalValue()).thenReturn("4000");
        
        when(component.findComponent("localAddress")).thenReturn(local);
        when(component.findComponent("remoteAddress")).thenReturn(remote);
        
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        when(event.getComponent()).thenReturn(component);
        
        when(m_RemoteChannelLookup.checkChannelTransportExists("4000", "4000")).thenReturn(false);
        m_SUT.validateTransportDoesNotExist(event);
        
        verify(m_GrowlUtil, times(0)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), 
                eq("Socket Exists"), Mockito.anyString());
        verify(m_FacesUtil, times(0)).getFacesContext();
        verify(m_FacesContext, times(0)).renderResponse();
        
        //test with a matching transport 
        when(m_RemoteChannelLookup.checkChannelTransportExists("4000", "4000")).thenReturn(true);
        m_SUT.validateTransportDoesNotExist(event);
        
        verify(m_GrowlUtil, times(1)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Transport Exists"), 
                eq("A transport with local address 4000 and remote address 4000 already exists."));
        verify(m_FacesUtil, times(1)).getFacesContext();
        verify(m_FacesContext, times(1)).renderResponse();
    }
/**
     * Verify that a duplicate transport can be found.
     */
Verify that a duplicate transport can be found.
Verify that a duplicate transport can be found .
@Test
    public void testValidateTransportDoesNotExist()
    {
        UIComponent component = mock(UIComponent.class);
        UIInput local = mock(UIInput.class);
        UIInput remote = mock(UIInput.class);
        when(local.getId()).thenReturn("localAddress");
        when(remote.getId()).thenReturn("remoteAddress");
        when(local.getLocalValue()).thenReturn("4000");
        when(remote.getLocalValue()).thenReturn("4000");
        when(component.findComponent("localAddress")).thenReturn(local);
        when(component.findComponent("remoteAddress")).thenReturn(remote);
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        when(event.getComponent()).thenReturn(component);
        when(m_RemoteChannelLookup.checkChannelTransportExists("4000", "4000")).thenReturn(false);
        m_SUT.validateTransportDoesNotExist(event);
        verify(m_GrowlUtil, times(0)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), 
                eq("Socket Exists"), Mockito.anyString());
        verify(m_FacesUtil, times(0)).getFacesContext();
        verify(m_FacesContext, times(0)).renderResponse();
        when(m_RemoteChannelLookup.checkChannelTransportExists("4000", "4000")).thenReturn(true);
        m_SUT.validateTransportDoesNotExist(event);
        verify(m_GrowlUtil, times(1)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Transport Exists"), 
                eq("A transport with local address 4000 and remote address 4000 already exists."));
        verify(m_FacesUtil, times(1)).getFacesContext();
        verify(m_FacesContext, times(1)).renderResponse();
    }
@ Test public void testValidateTransportDoesNotExist ( ) { UIComponent component = mock ( UIComponent . class ) ; UIInput local = mock ( UIInput . class ) ; UIInput remote = mock ( UIInput . class ) ; when ( local . getId ( ) ) . thenReturn ( "localAddress" ) ; when ( remote . getId ( ) ) . thenReturn ( "remoteAddress" ) ; when ( local . getLocalValue ( ) ) . thenReturn ( "4000" ) ; when ( remote . getLocalValue ( ) ) . thenReturn ( "4000" ) ; when ( component . findComponent ( "localAddress" ) ) . thenReturn ( local ) ; when ( component . findComponent ( "remoteAddress" ) ) . thenReturn ( remote ) ; ComponentSystemEvent event = mock ( ComponentSystemEvent . class ) ; when ( event . getComponent ( ) ) . thenReturn ( component ) ; when ( m_RemoteChannelLookup . checkChannelTransportExists ( "4000" , "4000" ) ) . thenReturn ( false ) ; m_SUT . validateTransportDoesNotExist ( event ) ; verify ( m_GrowlUtil , times ( 0 ) ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Socket Exists" ) , Mockito . anyString ( ) ) ; verify ( m_FacesUtil , times ( 0 ) ) . getFacesContext ( ) ; verify ( m_FacesContext , times ( 0 ) ) . renderResponse ( ) ; when ( m_RemoteChannelLookup . checkChannelTransportExists ( "4000" , "4000" ) ) . thenReturn ( true ) ; m_SUT . validateTransportDoesNotExist ( event ) ; verify ( m_GrowlUtil , times ( 1 ) ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Transport Exists" ) , eq ( "A transport with local address 4000 and remote address 4000 already exists." ) ) ; verify ( m_FacesUtil , times ( 1 ) ) . getFacesContext ( ) ; verify ( m_FacesContext , times ( 1 ) ) . renderResponse ( ) ; }
Verify that a duplicate transport can be found.
Verify that a duplicate transport can be found .
//test with a matching transport 