mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testPersistenceRemoval() throws PersistenceFailedException, InvalidProtocolBufferException, 
        IllegalArgumentException, ValidationFailedException
    {
        int systemId = 300;
        
        // mock out persistent data store with nothing in it yet
        Collection<PersistentData> channelDataList = new ArrayList<PersistentData>();
        when(m_PersistentDataStore.query(RemoteChannelLookupImpl.class, new Integer(systemId).toString()))
            .thenReturn(channelDataList);
        
        // mock channel that will be created
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        
        // sync channel to see if it is persisted
        SocketChannel channel = m_SUT.syncClientSocketChannel("host", 100, systemId);
        
        // mock so that data is now in the store
        PersistentData channelData = mock(PersistentData.class);
        channelDataList.add(channelData);
        
        // remove channel make sure it is updated
        m_SUT.removeChannel(channel);
        
        // construct the expected model object that will be created based on the current list
        SystemChannels expectedChannels = SystemChannels.newBuilder().setSysId(systemId).build();
        
        // verify channel data is merged with existing data
        ArgumentCaptor<byte[]> byteCapture = ArgumentCaptor.forClass(byte[].class);
        verify(channelData).setEntity(byteCapture.capture());
        SystemChannels actualChannels = SystemChannels.parseFrom(byteCapture.getValue());
        assertThat(expectedChannels, is(actualChannels));
        
        verify(m_PersistentDataStore).merge(channelData);
    }
/**
     * Verify removing a channel will update persisted value.
     * 
     * Verify persisted value contains an empty channel set.
     */
Verify removing a channel will update persisted value.

Verify persisted value contains an empty channel set.
Verify removing a channel will update persisted value . Verify persisted value contains an empty channel set .
@Test
    public void testPersistenceRemoval() throws PersistenceFailedException, InvalidProtocolBufferException, 
        IllegalArgumentException, ValidationFailedException
    {
        int systemId = 300;
        Collection<PersistentData> channelDataList = new ArrayList<PersistentData>();
        when(m_PersistentDataStore.query(RemoteChannelLookupImpl.class, new Integer(systemId).toString()))
            .thenReturn(channelDataList);
        stubSocketChannel(m_ClientSocketChannel, "host", 100, false);
        SocketChannel channel = m_SUT.syncClientSocketChannel("host", 100, systemId);
        PersistentData channelData = mock(PersistentData.class);
        channelDataList.add(channelData);
        m_SUT.removeChannel(channel);
        SystemChannels expectedChannels = SystemChannels.newBuilder().setSysId(systemId).build();
        ArgumentCaptor<byte[]> byteCapture = ArgumentCaptor.forClass(byte[].class);
        verify(channelData).setEntity(byteCapture.capture());
        SystemChannels actualChannels = SystemChannels.parseFrom(byteCapture.getValue());
        assertThat(expectedChannels, is(actualChannels));
        verify(m_PersistentDataStore).merge(channelData);
    }
@ Test public void testPersistenceRemoval ( ) throws PersistenceFailedException , InvalidProtocolBufferException , IllegalArgumentException , ValidationFailedException { int systemId = 300 ; Collection < PersistentData > channelDataList = new ArrayList < PersistentData > ( ) ; when ( m_PersistentDataStore . query ( RemoteChannelLookupImpl . class , new Integer ( systemId ) . toString ( ) ) ) . thenReturn ( channelDataList ) ; stubSocketChannel ( m_ClientSocketChannel , "host" , 100 , false ) ; SocketChannel channel = m_SUT . syncClientSocketChannel ( "host" , 100 , systemId ) ; PersistentData channelData = mock ( PersistentData . class ) ; channelDataList . add ( channelData ) ; m_SUT . removeChannel ( channel ) ; SystemChannels expectedChannels = SystemChannels . newBuilder ( ) . setSysId ( systemId ) . build ( ) ; ArgumentCaptor < byte [ ] > byteCapture = ArgumentCaptor . forClass ( byte [ ] . class ) ; verify ( channelData ) . setEntity ( byteCapture . capture ( ) ) ; SystemChannels actualChannels = SystemChannels . parseFrom ( byteCapture . getValue ( ) ) ; assertThat ( expectedChannels , is ( actualChannels ) ) ; verify ( m_PersistentDataStore ) . merge ( channelData ) ; }
Verify removing a channel will update persisted value.
Verify removing a channel will update persisted value .
// mock out persistent data store with nothing in it yet // mock channel that will be created // sync channel to see if it is persisted // mock so that data is now in the store // remove channel make sure it is updated // construct the expected model object that will be created based on the current list // verify channel data is merged with existing data