Search in sources :

Example 1 with WARNING

use of org.assertj.core.error.future.Warning.WARNING in project assertj-core by joel-costigliola.

the class CompletableFutureAssert_isCompletedWithValueMatching_Test method should_fail_if_completable_future_has_failed.

@Test
public void should_fail_if_completable_future_has_failed() {
    // GIVEN
    CompletableFuture<String> future = new CompletableFuture<>();
    future.completeExceptionally(new RuntimeException());
    // WHEN
    Throwable throwable = catchThrowable(() -> assertThat(future).isCompletedWithValueMatching(result -> result.equals("done")));
    // THEN
    assertThat(throwable).isInstanceOf(AssertionError.class).hasMessageStartingWith(format("%nExpecting%n  <CompletableFuture[Failed: java.lang.RuntimeException]%n")).hasMessageContaining("Caused by: java.lang.RuntimeException").hasMessageEndingWith(format("to be completed.%n%s", WARNING));
}
Also used : AssertionsForClassTypes.catchThrowable(org.assertj.core.api.AssertionsForClassTypes.catchThrowable) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ShouldBeCompleted.shouldBeCompleted(org.assertj.core.error.future.ShouldBeCompleted.shouldBeCompleted) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test) WARNING(org.assertj.core.error.future.Warning.WARNING) String.format(java.lang.String.format) BaseTest(org.assertj.core.api.BaseTest) CompletableFuture(java.util.concurrent.CompletableFuture) AssertionsForClassTypes.catchThrowable(org.assertj.core.api.AssertionsForClassTypes.catchThrowable) Test(org.junit.Test) BaseTest(org.assertj.core.api.BaseTest)

Aggregations

String.format (java.lang.String.format)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AssertionsForClassTypes.catchThrowable (org.assertj.core.api.AssertionsForClassTypes.catchThrowable)1 BaseTest (org.assertj.core.api.BaseTest)1 ShouldBeCompleted.shouldBeCompleted (org.assertj.core.error.future.ShouldBeCompleted.shouldBeCompleted)1 WARNING (org.assertj.core.error.future.Warning.WARNING)1 FailureMessages.actualIsNull (org.assertj.core.util.FailureMessages.actualIsNull)1 Test (org.junit.Test)1