### Question:
CompletableResultCode { public static CompletableResultCode ofAll(final Collection<CompletableResultCode> codes) { final CompletableResultCode result = new CompletableResultCode(); final AtomicInteger pending = new AtomicInteger(codes.size()); final AtomicBoolean failed = new AtomicBoolean(); for (final CompletableResultCode code : codes) { code.whenComplete( new Runnable() { @Override public void run() { if (!code.isSuccess()) { failed.set(true); } if (pending.decrementAndGet() == 0) { if (failed.get()) { result.fail(); } else { result.succeed(); } } } }); } return result; } CompletableResultCode(); static CompletableResultCode ofSuccess(); static CompletableResultCode ofFailure(); static CompletableResultCode ofAll(final Collection<CompletableResultCode> codes); CompletableResultCode succeed(); CompletableResultCode fail(); boolean isSuccess(); CompletableResultCode whenComplete(Runnable action); boolean isDone(); CompletableResultCode join(long timeout, TimeUnit unit);  }### Answer:
@Test void ofAll() { CompletableResultCode result1 = new CompletableResultCode(); CompletableResultCode result2 = new CompletableResultCode(); CompletableResultCode result3 = new CompletableResultCode(); CompletableResultCode all = CompletableResultCode.ofAll(Arrays.asList(result1, result2, result3)); assertThat(all.isDone()).isFalse(); result1.succeed(); assertThat(all.isDone()).isFalse(); result2.succeed(); assertThat(all.isDone()).isFalse(); result3.succeed(); assertThat(all.isDone()).isTrue(); assertThat(all.isSuccess()).isTrue(); }