### Question:
StorageContainerChannelManager implements AutoCloseable { public StorageContainerChannel getOrCreate(long scId) { StorageContainerChannel scChannel = scChannels.get(scId); if (null == scChannel) { StorageContainerChannel newChannel = factory.createStorageContainerChannel(scId); StorageContainerChannel oldChannel = scChannels.putIfAbsent(scId, newChannel); if (null == oldChannel) { scChannel = newChannel; } else { scChannel = oldChannel; } } return scChannel; } StorageContainerChannelManager(StorageServerChannelManager channelManager,
                                          LocationClient locationClient,
                                          OrderedScheduler scheduler); @VisibleForTesting  StorageContainerChannelManager(StorageContainerChannelFactory factory); StorageContainerChannel getOrCreate(long scId); StorageContainerChannel remove(long scId); @Override void close();  }### Answer:
@Test public void testGetOrCreate() { StorageContainerChannel channel1 = mock(StorageContainerChannel.class); StorageContainerChannel channel2 = mock(StorageContainerChannel.class); StorageContainerChannel channel3 = mock(StorageContainerChannel.class); StorageContainerChannelFactory factory = mock(StorageContainerChannelFactory.class); StorageContainerChannelManager manager = new StorageContainerChannelManager(factory); when(factory.createStorageContainerChannel(anyLong())) .thenReturn(channel1) .thenReturn(channel2) .thenReturn(channel3); assertNull(manager.remove(1L)); assertEquals(channel1, manager.getOrCreate(1L)); verify(factory, times(1)).createStorageContainerChannel(eq(1L)); assertEquals(channel1, manager.getOrCreate(1L)); verify(factory, times(1)).createStorageContainerChannel(eq(1L)); assertEquals(channel1, manager.remove(1L)); }