use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method applyToEither.
@Test
public void applyToEither() {
CompletableFuture<Object> eitherFuture = future1.applyToEither(future2, value -> {
assertTrue(future1.isDone() || future2.isDone());
return expectedResult;
});
boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
assertTrueEventually(() -> {
assertTrue(eitherFuture.isDone());
});
if (exceptionalCompletion && eitherFuture.isCompletedExceptionally()) {
expected.expect(CompletionException.class);
expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
eitherFuture.join();
}
// non-exceptional completion
assertSame(expectedResult, eitherFuture.join());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method thenAcceptBothAsync_withExecutor.
@Test
public void thenAcceptBothAsync_withExecutor() {
CompletableFuture<Void> combinedFuture = future1.thenAcceptBothAsync(future2, (v1, v2) -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
assertNull(v1);
assertNull(v2);
}, countingExecutor);
boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
assertTrueEventually(() -> {
assertTrue(combinedFuture.isDone());
});
if (exceptionalCompletion) {
expected.expect(CompletionException.class);
expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
combinedFuture.join();
}
// non-exceptional completion
assertNull(combinedFuture.join());
assertEquals(1, countingExecutor.counter.get());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method runAfterBothAsync_withExecutor.
@Test
public void runAfterBothAsync_withExecutor() {
CompletableFuture<Void> combinedFuture = future1.runAfterBothAsync(future2, () -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
}, countingExecutor);
boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
assertTrueEventually(() -> {
assertTrue(combinedFuture.isDone());
});
if (exceptionalCompletion) {
expected.expect(CompletionException.class);
expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
combinedFuture.join();
}
// non-exceptional completion
assertNull(combinedFuture.join());
assertEquals(1, countingExecutor.counter.get());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method acceptEitherAsync.
@Test
public void acceptEitherAsync() {
CompletableFuture<Void> eitherFuture = future1.acceptEitherAsync(future2, value -> {
assertTrue(future1.isDone() || future2.isDone());
});
boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
assertTrueEventually(() -> {
assertTrue(eitherFuture.isDone());
});
if (exceptionalCompletion && eitherFuture.isCompletedExceptionally()) {
expected.expect(CompletionException.class);
expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
eitherFuture.join();
}
// non-exceptional completion
assertNull(eitherFuture.join());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method runAfterBothAsync.
@Test
public void runAfterBothAsync() {
CompletableFuture<Void> combinedFuture = future1.runAfterBothAsync(future2, () -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
});
boolean exceptionalCompletion = invocation1.throwsException || invocation2.throwsException;
assertTrueEventually(() -> {
assertTrue(combinedFuture.isDone());
});
if (exceptionalCompletion) {
expected.expect(CompletionException.class);
expected.expectCause(new RootCauseMatcher(ExpectedRuntimeException.class));
combinedFuture.join();
}
// non-exceptional completion
assertNull(combinedFuture.join());
}
Aggregations