static void removeAllFromManagers(Iterable<DoFnLifecycleManager> managers) throws Exception {
    Collection<Exception> thrown = new ArrayList<>();
    for (DoFnLifecycleManager manager : managers) {
      thrown.addAll(manager.removeAll());
    }
    if (!thrown.isEmpty()) {
      Exception overallException = new Exception("Exceptions thrown while tearing down DoFns");
      for (Exception e : thrown) {
        overallException.addSuppressed(e);
      }
      throw overallException;
    }
  }
@Test
  public void whenManagersSucceedSucceeds() throws Exception {
    PipelineOptions options = PipelineOptionsFactory.create();
    DoFnLifecycleManager first = DoFnLifecycleManager.of(new EmptyFn(), options);
    DoFnLifecycleManager second = DoFnLifecycleManager.of(new EmptyFn(), options);
    DoFnLifecycleManager third = DoFnLifecycleManager.of(new EmptyFn(), options);
    first.get();
    second.get();
    third.get();

    DoFnLifecycleManagers.removeAllFromManagers(ImmutableList.of(first, second, third));
  }