use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method thenAcceptBoth.
@Test
public void thenAcceptBoth() {
CompletableFuture<Void> combinedFuture = future1.thenAcceptBoth(future2, (v1, v2) -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
assertNull(v1);
assertNull(v2);
});
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());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method applyToEitherAsync.
@Test
public void applyToEitherAsync() {
CompletableFuture<Object> eitherFuture = future1.applyToEitherAsync(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 thenCombineAsync.
@Test
public void thenCombineAsync() {
CompletableFuture<Integer> combinedFuture = future1.thenCombineAsync(future2, (v1, v2) -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
assertNull(v1);
assertNull(v2);
return 1;
});
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
assertEquals(1, (int) combinedFuture.join());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method thenCombineAsync_withExecutor.
@Test
public void thenCombineAsync_withExecutor() {
CompletableFuture<Integer> combinedFuture = future1.thenCombineAsync(future2, (v1, v2) -> {
assertTrue(future1.isDone());
assertTrue(future2.isDone());
assertNull(v1);
assertNull(v2);
return 1;
}, 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
assertEquals(1, (int) combinedFuture.join());
assertEquals(1, countingExecutor.counter.get());
}
use of com.hazelcast.internal.util.RootCauseMatcher in project hazelcast by hazelcast.
the class BiCompletionStageTest method runAfterEitherAsync.
@Test
public void runAfterEitherAsync() {
CompletableFuture<Void> eitherFuture = future1.runAfterEitherAsync(future2, () -> {
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());
}
Aggregations