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

Tests for styx core observable #198

Merged
merged 4 commits into from
Jul 2, 2018
Merged

Tests for styx core observable #198

merged 4 commits into from
Jul 2, 2018

Conversation

kvosper
Copy link
Contributor

@kvosper kvosper commented Jun 28, 2018

For #196

@kvosper kvosper requested review from mikkokar and dvlato June 28, 2018 15:52
@@ -92,7 +94,7 @@ public StyxCoreObservable(CompletionStage<T> future) {
}

private static <T> CompletableFuture<T> fromSingleObservable(Observable<T> observable) {
final CompletableFuture<T> future = new CompletableFuture<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to remove the final modifier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keeping it in line with our standard coding practices. Excessive finals clutter the codebase, so we avoid them on local variables and method parameters (due to their limited scope).
We only use them on fields because it could be very hard to tract down an unexpected mutation in a large class.
For locals and parameters, we instead aim to keep our methods small and simple enough that any mutations are easily visible (in addition to the other benefits of readable methods).

}

@Test(expectedExceptions = NoSuchElementException.class, expectedExceptionsMessageRegExp = "Sequence contains no elements")
public void throwsExceptionWhenTryingToConvertEmptyToFuture() throws Throwable {
Copy link
Contributor

@mikkokar mikkokar Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth noticing that NoSuchElementException and IllegalArgumentException are now going to be part of our API. Worth documenting this in the StyxObservable interface.

mikkokar
mikkokar previously approved these changes Jul 2, 2018
}

@Test
public void flatMapsWorksWithCustomObservable() throws InterruptedException, ExecutionException, TimeoutException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test exists because of the problem you observed in your TODO:

TODO: Mikko: Dangerous cast.
Because StyxObservable is an interface, nothing prevents plugins from
implementing it and returning a derived object from the transformation
function. This would obviously break the cast.

It proves that the problem described has been fixed.

@mikkokar mikkokar dismissed their stale review July 2, 2018 14:03

Accidentally approved

@kvosper kvosper merged commit a299654 into ExpediaGroup:styx-1.0-dev Jul 2, 2018
@kvosper kvosper deleted the tests-for-StyxCoreObservable branch July 2, 2018 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants