@Override
  public synchronized boolean isTerminated() {
    if (!shutdownStarted) {
      return false;
    }
    for (ManagedChannel channel : usedChannels) {
      if (!channel.isTerminated()) return false;
    }
    for (ManagedChannel channel : channelCache) {
      if (!channel.isTerminated()) return false;
    }
    return true;
  }
@Test
  public void testIsTerminated() throws Exception {
    ManagedChannel mockChannel = mock(ManagedChannel.class);
    when(channelSupplier.get()).thenReturn(mockChannel);

    IsolationChannel isolationChannel = IsolationChannel.create(channelSupplier);

    when(mockChannel.shutdown()).thenReturn(mockChannel);
    when(mockChannel.isTerminated()).thenReturn(false, true);

    isolationChannel.shutdown();
    assertFalse(isolationChannel.isTerminated());
    assertTrue(isolationChannel.isTerminated());

    verify(channelSupplier, times(1)).get();
    verify(mockChannel, times(1)).shutdown();
    verify(mockChannel, times(2)).isTerminated();
  }