mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestControllerHistoryMgr.java
@Test
    public void testChannelEventHelperNewChannel()
    {
        final Collection<PersistentData> emptyCollection = new HashSet<>();
        when(m_DataStore.query(eq(ControllerHistory.class), Mockito.anyString())).thenReturn(emptyCollection);
        
        final RemoteChannel remoteChannel = mock(RemoteChannel.class, 
                withSettings().extraInterfaces(SocketChannel.class));
        final String hostname = "12.11.10.9";
        when(((SocketChannel)remoteChannel).getHost()).thenReturn(hostname);
        when(((SocketChannel)remoteChannel).getPort()).thenReturn(5001);
        
        final Map<String, Object> props = new HashMap<String, Object>();
        props.put(RemoteConstants.EVENT_PROP_SYS_ID, 100);
        props.put(RemoteConstants.EVENT_PROP_CHANNEL, remoteChannel);
        final Event remoteChannelAddedEvent = new Event(RemoteChannelLookup.TOPIC_CHANNEL_UPDATED, props);
        
        m_ChannelEventHelper.handleEvent(remoteChannelAddedEvent);
        
        final ArgumentCaptor<ControllerHistory> persistentCaptor = ArgumentCaptor.forClass(ControllerHistory.class);
        verify(m_DataStore).persist(eq(ControllerHistory.class), Mockito.any(UUID.class), Mockito.anyString(), 
                persistentCaptor.capture());
        final ControllerHistory addedController = persistentCaptor.getValue();
        assertThat(addedController.getControllerId(), is(100));
        assertThat(addedController.getHostName(), is(hostname));
        assertThat(addedController.getPort(), is(5001));
    }
/**
     * Tests the channel event helper and verifies that the controller information is persisted as a controller history
     * object.
     */
Tests the channel event helper and verifies that the controller information is persisted as a controller history
object.
Tests the channel event helper and verifies that the controller information is persisted as a controller history object .
@Test
    public void testChannelEventHelperNewChannel()
    {
        final Collection<PersistentData> emptyCollection = new HashSet<>();
        when(m_DataStore.query(eq(ControllerHistory.class), Mockito.anyString())).thenReturn(emptyCollection);
        final RemoteChannel remoteChannel = mock(RemoteChannel.class, 
                withSettings().extraInterfaces(SocketChannel.class));
        final String hostname = "12.11.10.9";
        when(((SocketChannel)remoteChannel).getHost()).thenReturn(hostname);
        when(((SocketChannel)remoteChannel).getPort()).thenReturn(5001);
        final Map<String, Object> props = new HashMap<String, Object>();
        props.put(RemoteConstants.EVENT_PROP_SYS_ID, 100);
        props.put(RemoteConstants.EVENT_PROP_CHANNEL, remoteChannel);
        final Event remoteChannelAddedEvent = new Event(RemoteChannelLookup.TOPIC_CHANNEL_UPDATED, props);
        m_ChannelEventHelper.handleEvent(remoteChannelAddedEvent);
        final ArgumentCaptor<ControllerHistory> persistentCaptor = ArgumentCaptor.forClass(ControllerHistory.class);
        verify(m_DataStore).persist(eq(ControllerHistory.class), Mockito.any(UUID.class), Mockito.anyString(), 
                persistentCaptor.capture());
        final ControllerHistory addedController = persistentCaptor.getValue();
        assertThat(addedController.getControllerId(), is(100));
        assertThat(addedController.getHostName(), is(hostname));
        assertThat(addedController.getPort(), is(5001));
    }
@ Test public void testChannelEventHelperNewChannel ( ) { final Collection < PersistentData > emptyCollection = new HashSet < > ( ) ; when ( m_DataStore . query ( eq ( ControllerHistory . class ) , Mockito . anyString ( ) ) ) . thenReturn ( emptyCollection ) ; final RemoteChannel remoteChannel = mock ( RemoteChannel . class , withSettings ( ) . extraInterfaces ( SocketChannel . class ) ) ; final String hostname = "12.11.10.9" ; when ( ( ( SocketChannel ) remoteChannel ) . getHost ( ) ) . thenReturn ( hostname ) ; when ( ( ( SocketChannel ) remoteChannel ) . getPort ( ) ) . thenReturn ( 5001 ) ; final Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( RemoteConstants . EVENT_PROP_SYS_ID , 100 ) ; props . put ( RemoteConstants . EVENT_PROP_CHANNEL , remoteChannel ) ; final Event remoteChannelAddedEvent = new Event ( RemoteChannelLookup . TOPIC_CHANNEL_UPDATED , props ) ; m_ChannelEventHelper . handleEvent ( remoteChannelAddedEvent ) ; final ArgumentCaptor < ControllerHistory > persistentCaptor = ArgumentCaptor . forClass ( ControllerHistory . class ) ; verify ( m_DataStore ) . persist ( eq ( ControllerHistory . class ) , Mockito . any ( UUID . class ) , Mockito . anyString ( ) , persistentCaptor . capture ( ) ) ; final ControllerHistory addedController = persistentCaptor . getValue ( ) ; assertThat ( addedController . getControllerId ( ) , is ( 100 ) ) ; assertThat ( addedController . getHostName ( ) , is ( hostname ) ) ; assertThat ( addedController . getPort ( ) , is ( 5001 ) ) ; }
Tests the channel event helper and verifies that the controller information is persisted as a controller history
 object.
Tests the channel event helper and verifies that the controller information is persisted as a controller history object .