Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance testing utilities #494

Merged
merged 7 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void testOnSubscribe() {
})
.subscribe().withSubscriber(AssertSubscriber.create(20));

subscriber.await()
subscriber.awaitCompletion()
.assertItems(0L, 1L, 2L, 3L, 4L);

}
Expand All @@ -270,7 +270,7 @@ public void testSelectWhere() {
})
.subscribe().withSubscriber(AssertSubscriber.create(20));

subscriber.await()
subscriber.awaitCompletion()
.assertItems(0L, 2L, 4L);

}
Expand All @@ -289,8 +289,7 @@ public void testScan() {
.select().first(10)
.subscribe().withSubscriber(AssertSubscriber.create(10));

subscriber.await()
.assertCompleted()
subscriber.awaitCompletion()
.assertItems(0, 1, 3, 6, 10, 15, 21, 28, 36, 45);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public void test() {
// end::code[]
AssertSubscriber<String> subscriber = AssertSubscriber.create(Long.MAX_VALUE);
multi.subscribe().withSubscriber(subscriber)
.await()
.assertCompleted();
.awaitCompletion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void test() {
// end::code[]
AssertSubscriber<String> subscriber = AssertSubscriber.create(Long.MAX_VALUE);
multi.subscribe().withSubscriber(subscriber)
.await()
.awaitCompletion()
.run(() -> assertThat(subscriber.getItems()).hasSize(1000));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ public Uni<T> call(Function<Throwable, Uni<?>> action) {
//noinspection unchecked
return (Uni<T>) uni
.onItem().failWith(ignored -> failure)
.onFailure().apply(subFailure -> new CompositeException(failure, subFailure));
.onFailure().transform(subFailure -> {
if (subFailure != failure) {
return new CompositeException(failure, subFailure);
} else {
return subFailure;
}
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@ public boolean isCancelled() {
public String toString() {
return "MultiOnCancellationSpy{} " + super.toString();
}

public void assertCancelled() {
if (!isCancelled()) {
throw new AssertionError("Expected downstream cancellation, but it did not happen");
}
}

public void assertNotCancelled() {
if (isCancelled()) {
throw new AssertionError("Did not expect to receive a downstream cancellation");
}
}
}
Loading