-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Implement as() #5729
2.x: Implement as() #5729
Conversation
Let me know if you want to add more tests. Some usages of |
I'm not sure I understand the remaining CI errors, as the parameters have the NonNull annotation |
@Experimental | ||
@CheckReturnValue | ||
@SchedulerSupport(SchedulerSupport.NONE) | ||
public final <R> R as(@NonNull CompletableConverter<? extends R> converter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @Experimental
and @since 2.1.7 - experimental
to all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* value fluently. | ||
* | ||
* @param <R> the output type | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @since 2.1.7 - experimental
to these as well.
Some style checks failed: https://travis-ci.org/ReactiveX/RxJava/builds/302962901#L974 Please add Please add a unit test that has a converter class which combines all interfaces and is applied to the 6 types of sources. |
Could you explain what the style checks fix is? I didn't quite understand the message in the log |
ParallelFlowable - 8adb583 Started on more converter tests in |
You have to extend the defaultValues.put(ObservableConverter.class, new ObservableConverter() {
@Override public Object apply(Observable o) { return o; }
}); |
As for these, you are using the wrong generic types.
I overlooked the test using |
The wildcard definition in those compile errors and the wrong |
Posted a patch for your PR. |
as(): Fix tests and update validator
Codecov Report
@@ Coverage Diff @@
## 2.x #5729 +/- ##
============================================
+ Coverage 96.24% 96.29% +0.04%
- Complexity 5823 5831 +8
============================================
Files 634 634
Lines 41609 41615 +6
Branches 5761 5761
============================================
+ Hits 40047 40073 +26
+ Misses 626 615 -11
+ Partials 936 927 -9
Continue to review full report at Codecov.
|
* @throws Exception on error | ||
*/ | ||
@NonNull | ||
R apply(@NonNull Completable upstream) throws Exception; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transformer variants don't define any throws Exception
. I'd think we can live without them in these interfaces as well and thus no need to try-catch
apply in the base classes' as()
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, would this be a candidate for |
2.2.0 is a bit in the future as I'd like to have #5319 finished before it. An experimental component can be promoted to stable regardless. |
Cool 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the copy right for the new files contain 2016 or 2017?
@@ -560,6 +560,46 @@ public void checkParallelFlowable() { | |||
|
|||
defaultValues.put(ParallelFailureHandling.class, ParallelFailureHandling.ERROR); | |||
|
|||
@SuppressWarnings("rawtypes") | |||
class MixedConverters implements FlowableConverter, ObservableConverter, SingleConverter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this to IdentityConverters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about it since this is just a stub for a test
} | ||
}); | ||
|
||
flow.blockingForEach(new Consumer<Object>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not assertion is this wanted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferring to @akarnokd on this as I was matching the analogous to()
test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change these into proper assertions such as .test().assertResult()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would I assert for these since there's no value? Or just rewrite the rest in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there is the onComplete
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is but completable.normal
doesn't complete. I wasn't sure if you wanted me to change it to just use Completable.complete()
or something similar since the original test didn't seem to be testing completion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normal.completable
does complete otherwise blockingForEach
would block indefinitely and the test would have failed a long a go. A .test().assertResult(/* no values */)
should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, I missed that line 🙄
Done in e0d793f
public Object apply(Flowable<Object> onSubscribe) { | ||
onSubscribe.subscribe(subscriber); | ||
subscriber.assertNoErrors(); | ||
subscriber.assertComplete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not this run through without asserting if the Converter is never called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True... I could add something after this to assert that subscriber
is complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about an AtomicBoolean that you set to true once it's called and you fail the test when it's set to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got a better one - 5c3bdf3
Observable.just(value).as(new ObservableConverter<Object, Object>() { | ||
@Override | ||
public Object apply(Observable<Object> onSubscribe) { | ||
onSubscribe.subscribe(subscriber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! |
This implement
as()
support as discussed in #5654I took the opportunity to try to standardize the docs and tests for it (which vary a little bit across implementations of
to()
)Related: #5654