mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testSyncTransportChannelPersist()
    {
        //Mock the needed transport channels.
        TransportChannel persistedChannel = mock(TransportChannel.class);
        TransportChannel nonPersistedChannel = mock(TransportChannel.class);
        TransportChannel alwaysPersistedChannel = mock(TransportChannel.class);
        
        when(m_TransportChannelInstance.getInstance()).thenReturn(persistedChannel, nonPersistedChannel, 
                alwaysPersistedChannel);
        
        stubTransportChannel(persistedChannel, "tl-1", "tl:1.2.3", "tl:1.2.4");
        stubTransportChannel(nonPersistedChannel, "t2-1", "t2:1.2.5", "t2:1.2.6");
        stubTransportChannel(alwaysPersistedChannel, "t3-1", "t3:1.2.7", "t3:1.2.8");
        
        //Define remote system IDs
        Integer systemId1 = 75;
        Integer systemId2 = 150;
        Integer systemId3 = 225;
        
        //Sync the transport channels
        TransportChannel returned1 = m_SUT.syncTransportChannel("t1-1", "t1:1.2.3", "t1:1.2.4", systemId1, true);
        TransportChannel returned2 = m_SUT.syncTransportChannel("t2-1", "t2:1.2.5", "t2:1.2.6", systemId2, false);
        TransportChannel returned3 = m_SUT.syncTransportChannel("t3-1", "t3:1.2.7", "t3:1.2.8", systemId3);
        
        //Verify that the appropriate channels are returned by the sync methods.
        assertThat(returned1, is(persistedChannel));
        assertThat(returned2, is(nonPersistedChannel));
        assertThat(returned3, is(alwaysPersistedChannel));
        
        //Verify that all channels are added to the remote lookup regardless of whether or not they should be persisted.
        assertThat((TransportChannel)m_SUT.getChannel(systemId1), is(persistedChannel));
        assertThat((TransportChannel)m_SUT.getChannel(systemId2), is(nonPersistedChannel));
        assertThat((TransportChannel)m_SUT.getChannel(systemId3), is(alwaysPersistedChannel));
        
        //Verify that only transport channels with system ID 1 and 3 are persisted.
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId1.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId2.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId3.toString()), Mockito.any(byte[].class));
    }
/**
     * Verify that the syncTransportChannel methods persist the channel when appropriate.
     */
Verify that the syncTransportChannel methods persist the channel when appropriate.
Verify that the syncTransportChannel methods persist the channel when appropriate .
@Test
    public void testSyncTransportChannelPersist()
    {
        TransportChannel persistedChannel = mock(TransportChannel.class);
        TransportChannel nonPersistedChannel = mock(TransportChannel.class);
        TransportChannel alwaysPersistedChannel = mock(TransportChannel.class);
        when(m_TransportChannelInstance.getInstance()).thenReturn(persistedChannel, nonPersistedChannel, 
                alwaysPersistedChannel);
        stubTransportChannel(persistedChannel, "tl-1", "tl:1.2.3", "tl:1.2.4");
        stubTransportChannel(nonPersistedChannel, "t2-1", "t2:1.2.5", "t2:1.2.6");
        stubTransportChannel(alwaysPersistedChannel, "t3-1", "t3:1.2.7", "t3:1.2.8");
        Integer systemId1 = 75;
        Integer systemId2 = 150;
        Integer systemId3 = 225;
        TransportChannel returned1 = m_SUT.syncTransportChannel("t1-1", "t1:1.2.3", "t1:1.2.4", systemId1, true);
        TransportChannel returned2 = m_SUT.syncTransportChannel("t2-1", "t2:1.2.5", "t2:1.2.6", systemId2, false);
        TransportChannel returned3 = m_SUT.syncTransportChannel("t3-1", "t3:1.2.7", "t3:1.2.8", systemId3);
        assertThat(returned1, is(persistedChannel));
        assertThat(returned2, is(nonPersistedChannel));
        assertThat(returned3, is(alwaysPersistedChannel));
        assertThat((TransportChannel)m_SUT.getChannel(systemId1), is(persistedChannel));
        assertThat((TransportChannel)m_SUT.getChannel(systemId2), is(nonPersistedChannel));
        assertThat((TransportChannel)m_SUT.getChannel(systemId3), is(alwaysPersistedChannel));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId1.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId2.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId3.toString()), Mockito.any(byte[].class));
    }
@ Test public void testSyncTransportChannelPersist ( ) { TransportChannel persistedChannel = mock ( TransportChannel . class ) ; TransportChannel nonPersistedChannel = mock ( TransportChannel . class ) ; TransportChannel alwaysPersistedChannel = mock ( TransportChannel . class ) ; when ( m_TransportChannelInstance . getInstance ( ) ) . thenReturn ( persistedChannel , nonPersistedChannel , alwaysPersistedChannel ) ; stubTransportChannel ( persistedChannel , "tl-1" , "tl:1.2.3" , "tl:1.2.4" ) ; stubTransportChannel ( nonPersistedChannel , "t2-1" , "t2:1.2.5" , "t2:1.2.6" ) ; stubTransportChannel ( alwaysPersistedChannel , "t3-1" , "t3:1.2.7" , "t3:1.2.8" ) ; Integer systemId1 = 75 ; Integer systemId2 = 150 ; Integer systemId3 = 225 ; TransportChannel returned1 = m_SUT . syncTransportChannel ( "t1-1" , "t1:1.2.3" , "t1:1.2.4" , systemId1 , true ) ; TransportChannel returned2 = m_SUT . syncTransportChannel ( "t2-1" , "t2:1.2.5" , "t2:1.2.6" , systemId2 , false ) ; TransportChannel returned3 = m_SUT . syncTransportChannel ( "t3-1" , "t3:1.2.7" , "t3:1.2.8" , systemId3 ) ; assertThat ( returned1 , is ( persistedChannel ) ) ; assertThat ( returned2 , is ( nonPersistedChannel ) ) ; assertThat ( returned3 , is ( alwaysPersistedChannel ) ) ; assertThat ( ( TransportChannel ) m_SUT . getChannel ( systemId1 ) , is ( persistedChannel ) ) ; assertThat ( ( TransportChannel ) m_SUT . getChannel ( systemId2 ) , is ( nonPersistedChannel ) ) ; assertThat ( ( TransportChannel ) m_SUT . getChannel ( systemId3 ) , is ( alwaysPersistedChannel ) ) ; verify ( m_PersistentDataStore ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId1 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; verify ( m_PersistentDataStore , never ( ) ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId2 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; verify ( m_PersistentDataStore ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId3 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; }
Verify that the syncTransportChannel methods persist the channel when appropriate.
Verify that the syncTransportChannel methods persist the channel when appropriate .
//Mock the needed transport channels. //Define remote system IDs //Sync the transport channels //Verify that the appropriate channels are returned by the sync methods. //Verify that all channels are added to the remote lookup regardless of whether or not they should be persisted. //Verify that only transport channels with system ID 1 and 3 are persisted.