@Test(timeout = 10000) public void testServiceHasMultipleClientRequests() throws Exception { assertThat(zipClient.hello("Lee")).isEqualTo("Hello, Lee!, and Hello, Lee!"); final Span[] spans = spanReporter.take(6); final String traceId = spans[0].traceId(); assertThat(spans).allMatch(s -> s.traceId().equals(traceId)); }
@Test public void consumeWhileErrorIsSuppressed() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(Flux.just("foo", "bar", "foobar") .map(r -> { if (r.length() > 3) throw new ArrayIndexOutOfBoundsException(); return r;})) .thenConsumeWhile(s -> s.length() <= 3) //doesn't fail by itself... .verifyComplete()) //...so this will fail .satisfies(error -> { assertThat(error) .hasMessageStartingWith("expectation \"expectComplete\" failed") .hasMessageContaining("actual: onError(java.lang.ArrayIndexOutOfBoundsException)"); assertThat(error.getSuppressed()) .hasSize(1) .allMatch(spr -> spr instanceof ArrayIndexOutOfBoundsException); }); }
@Test public void consumeNextErrorIsSuppressed() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(Flux.just("foo") .flatMap(r -> { throw new ArrayIndexOutOfBoundsException();})) .consumeNextWith(v -> assertThat(v).isNotNull()) .verifyError()) .satisfies(error -> { assertThat(error) .hasMessageStartingWith("expectation \"consumeNextWith\" failed") .hasMessageContaining("actual: onError(java.lang.ArrayIndexOutOfBoundsException)"); assertThat(error.getSuppressed()) .hasSize(1) .allMatch(spr -> spr instanceof ArrayIndexOutOfBoundsException); }); }
@Test public void expectNextSequenceErrorIsSuppressed() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(Flux.just("foo") .flatMap(r -> { throw new ArrayIndexOutOfBoundsException();})) .expectNextSequence(Arrays.asList("foo")) .verifyError()) .satisfies(error -> { assertThat(error) .hasMessageStartingWith("expectation \"expectNextSequence\" failed") .hasMessageContaining("actual signal: onError(java.lang.ArrayIndexOutOfBoundsException)"); assertThat(error.getSuppressed()) .hasSize(1) .allMatch(spr -> spr instanceof ArrayIndexOutOfBoundsException); }); }
@Test public void expectNextCountErrorIsSuppressed() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(Flux.just("foo") .flatMap(r -> { throw new ArrayIndexOutOfBoundsException();})) .expectNextCount(1) .verifyError()) .satisfies(error -> { assertThat(error) .hasMessageStartingWith("expectation \"expectNextCount(1)\" failed") .hasMessageContaining("signal: onError(java.lang.ArrayIndexOutOfBoundsException)"); assertThat(error.getSuppressed()) .hasSize(1) .allMatch(spr -> spr instanceof ArrayIndexOutOfBoundsException); }); }
@Test public void expectNextErrorIsSuppressed() { assertThatExceptionOfType(AssertionError.class) .isThrownBy(() -> StepVerifier.create(Flux.just("foo") .flatMap(r -> { throw new ArrayIndexOutOfBoundsException();})) .expectNext("foo") .verifyError()) .satisfies(error -> { assertThat(error) .hasMessageStartingWith("expectation \"expectNext(foo)\" failed") .hasMessageContaining("actual: onError(java.lang.ArrayIndexOutOfBoundsException)"); assertThat(error.getSuppressed()) .hasSize(1) .allMatch(spr -> spr instanceof ArrayIndexOutOfBoundsException); }); }