use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class TestObserverExTest method completeDelegateThrows.
@Test
public void completeDelegateThrows() {
TestObserverEx<Integer> to = new TestObserverEx<>(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
throw new TestException();
}
});
to.onSubscribe(Disposable.empty());
try {
to.onComplete();
throw new RuntimeException("Should have thrown!");
} catch (TestException ex) {
to.assertTerminated();
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class JavadocWording method flowableDocRefersToFlowableTypes.
@Test
public void flowableDocRefersToFlowableTypes() throws Exception {
List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("Flowable"), "Flowable");
assertFalse(list.isEmpty());
StringBuilder e = new StringBuilder();
for (RxMethod m : list) {
int jdx;
if (m.javadoc != null) {
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("onSuccess", jdx);
if (idx >= 0) {
if (!m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource")) {
e.append("java.lang.RuntimeException: Flowable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" Observer", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource") && !m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" SingleObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("SingleSource") && !m.signature.contains("Single")) {
e.append("java.lang.RuntimeException: Flowable doc mentions SingleObserver but not using Single\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" MaybeObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("MaybeSource") && !m.signature.contains("Maybe")) {
e.append("java.lang.RuntimeException: Flowable doc mentions MaybeObserver but not using Maybe\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" Disposable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable") && !m.signature.contains("ObservableSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource") && !m.signature.contains("Completable") && !m.signature.contains("CompletableSource") && !m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Disposable") && !m.signature.contains("void subscribe")) {
CharSequence subSequence = m.javadoc.subSequence(idx - 6, idx + 11);
if (idx < 6 || !subSequence.equals("{@link Disposable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Disposable but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("Observable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("ObservableSource", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource")) {
e.append("java.lang.RuntimeException: Flowable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
checkAtReturnAndSignatureMatch("Flowable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableFlowable", "ParallelFlowable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
aOrAn(e, m, "Flowable");
missingClosingDD(e, m, "Flowable", "io.reactivex.rxjava3.core");
backpressureMentionedWithoutAnnotation(e, m, "Flowable");
}
}
if (e.length() != 0) {
System.out.println(e);
fail(e.toString());
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class JavadocWording method parallelFlowableDocRefersToCorrectTypes.
@Test
public void parallelFlowableDocRefersToCorrectTypes() throws Exception {
List<RxMethod> list = BaseTypeParser.parse(TestHelper.findSource("ParallelFlowable", "io.reactivex.rxjava3.parallel"), "ParallelFlowable");
assertFalse(list.isEmpty());
StringBuilder e = new StringBuilder();
for (RxMethod m : list) {
int jdx;
if (m.javadoc != null) {
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("onSuccess", jdx);
if (idx >= 0) {
if (!m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource")) {
e.append("java.lang.RuntimeException: Flowable doc mentions onSuccess\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" Observer", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource") && !m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observer but not using Observable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" SingleObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("SingleSource") && !m.signature.contains("Single")) {
e.append("java.lang.RuntimeException: Flowable doc mentions SingleObserver but not using Single\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" MaybeObserver", jdx);
if (idx >= 0) {
if (!m.signature.contains("MaybeSource") && !m.signature.contains("Maybe")) {
e.append("java.lang.RuntimeException: Flowable doc mentions MaybeObserver but not using Maybe\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf(" Disposable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable") && !m.signature.contains("ObservableSource") && !m.signature.contains("Single") && !m.signature.contains("SingleSource") && !m.signature.contains("Completable") && !m.signature.contains("CompletableSource") && !m.signature.contains("Maybe") && !m.signature.contains("MaybeSource") && !m.signature.contains("Disposable")) {
CharSequence subSequence = m.javadoc.subSequence(idx - 6, idx + 11);
if (idx < 6 || !subSequence.equals("{@link Disposable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Disposable but not using Flowable\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("Observable", jdx);
if (idx >= 0) {
if (!m.signature.contains("Observable")) {
e.append("java.lang.RuntimeException: Flowable doc mentions Observable but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
jdx = 0;
for (; ; ) {
int idx = m.javadoc.indexOf("ObservableSource", jdx);
if (idx >= 0) {
if (!m.signature.contains("ObservableSource")) {
e.append("java.lang.RuntimeException: Flowable doc mentions ObservableSource but not in the signature\r\n at io.reactivex.rxjava3.core.").append("Flowable.method(Flowable.java:").append(m.javadocLine + lineNumber(m.javadoc, idx) - 1).append(")\r\n\r\n");
}
jdx = idx + 6;
} else {
break;
}
}
checkAtReturnAndSignatureMatch("ParallelFlowable", m, e, "Flowable", "Observable", "Maybe", "Single", "Completable", "ConnectableFlowable", "ParallelFlowable", "Disposable", "Iterable", "Stream", "Future", "CompletionStage");
aOrAn(e, m, "ParallelFlowable");
missingClosingDD(e, m, "ParallelFlowable", "io.reactivex.rxjava3.parallel");
backpressureMentionedWithoutAnnotation(e, m, "ParallelFlowable");
}
}
if (e.length() != 0) {
System.out.println(e);
fail(e.toString());
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class TestObserverExTest method wrappingMock.
@Test
public void wrappingMock() {
Observable<Integer> oi = Observable.fromIterable(Arrays.asList(1, 2));
Observer<Integer> mockSubscriber = TestHelper.mockObserver();
oi.subscribe(new TestObserverEx<>(mockSubscriber));
InOrder inOrder = inOrder(mockSubscriber);
inOrder.verify(mockSubscriber, times(1)).onNext(1);
inOrder.verify(mockSubscriber, times(1)).onNext(2);
inOrder.verify(mockSubscriber, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ExceptionsTest method stackOverflowWouldOccur.
@Test
public void stackOverflowWouldOccur() {
final PublishSubject<Integer> a = PublishSubject.create();
final PublishSubject<Integer> b = PublishSubject.create();
final int MAX_STACK_DEPTH = 800;
final AtomicInteger depth = new AtomicInteger();
a.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer n) {
b.onNext(n + 1);
}
});
b.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
// TODO Auto-generated method stub
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer n) {
if (depth.get() < MAX_STACK_DEPTH) {
depth.set(Thread.currentThread().getStackTrace().length);
a.onNext(n + 1);
}
}
});
a.onNext(1);
assertTrue(depth.get() >= MAX_STACK_DEPTH);
}
Aggregations