Skip to content

Commit e24a23b

Browse files
Restore Broken OperationJoinsTest
- confirmed the assertions, leaving broken until can be fixed (not sure what’s wrong)
1 parent 6a1c8f0 commit e24a23b

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

rxjava-core/src/test/java/rx/operators/OperationJoinsTest.java

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Before;
2424
import org.junit.Ignore;
2525
import org.junit.Test;
26+
import org.mockito.InOrder;
2627
import org.mockito.Mock;
2728
import org.mockito.MockitoAnnotations;
2829

@@ -361,12 +362,6 @@ public void whenThrowNonEmpty() {
361362
verify(observer, never()).onCompleted();
362363
}
363364

364-
/**
365-
* Disabled for now as I am not sure what this should assert to and it is non-deterministic.
366-
*
367-
* Where is the non-determinism coming from since there is no concurrency in this test?
368-
*/
369-
@Ignore
370365
@Test
371366
public void whenComplicated() {
372367
PublishSubject<Integer> xs = PublishSubject.create();
@@ -379,53 +374,41 @@ public void whenComplicated() {
379374
ys.toObservable().and(zs.toObservable()).then(sub2) // 4-7=-3, 5-8=-3, 6-9=-3
380375
);
381376

382-
// 5, 7, 9, 7, 16, 27, -3, -3, -3
383-
384-
// order they join is ...
385-
// 7, 16, 5, -3, 27, 7, -3, 9, -3
386-
387-
// 7, 16, 7, -4
388-
389377
TestObserver<Integer> to = new TestObserver<Integer>(observer);
390378
m.subscribe(to);
391379

392-
xs.onNext(1); // t == 210
380+
xs.onNext(1); // t == 210, xs[1], ys[], zs[]
393381

394-
xs.onNext(2); // t == 220
395-
zs.onNext(7); // t == 220
382+
xs.onNext(2); // t == 220, xs[1, 2], ys[], zs[]
383+
zs.onNext(7); // t == 220, xs[1, 2], ys[], zs[7] triggers x and z; emit 1 * 7, remains xs[2], ys[], zs[]
396384

397-
xs.onNext(3); // t == 230
398-
zs.onNext(8); // t == 230
385+
xs.onNext(3); // t == 230, xs[2,3], ys[], zs[]
386+
zs.onNext(8); // t == 230, xs[2,3], ys[], zs[8] triggers x and z, emit 2 * 8, remains xs[3], ys[], zs[]
399387

400-
ys.onNext(4); // t == 240
401-
zs.onNext(9); // t == 240
402-
xs.onCompleted(); // t == 240
388+
ys.onNext(4); // t == 240, xs[], ys[4], zs[] triggers x and y, emit 3 + 4, remains xs[], ys[], zs[]
389+
zs.onNext(9); // t == 240, xs[], ys[], zs[9]
390+
xs.onCompleted(); // t == 240, completed 1
403391

404-
ys.onNext(5); // t == 250
392+
ys.onNext(5); // t == 250, xs[], ys[5], zs[9], triggers ys and zs, emits 5 - 9, remains xs[], ys[], zs[]
405393

406-
ys.onNext(6); // t == 260
394+
ys.onNext(6); // t == 260, xs[], ys[6], zs[]
407395

408-
ys.onCompleted(); // t == 270
396+
ys.onCompleted(); // t == 270, completed 2
409397

410-
zs.onCompleted(); // t == 300
398+
zs.onCompleted(); // t == 300, completed 3, triggers when() oncompleted
411399

412400
System.out.println("Events: " + to.getOnNextEvents());
413401

414-
to.assertReceivedOnNext(Arrays.asList(7, 16, 5, -3, 27, 7, -3, 9, -3));
402+
to.assertReceivedOnNext(Arrays.asList(7, 16, 7, -4));
415403
to.assertTerminalEvent();
416404

417-
// TODO validate the following
418-
/**
419-
* The following assertions existed and passed in 0.16. How did it ever pass?
420-
* What is this supposed to do if not [7, 16, 5, -3, 27, 7, -3, 9, -3] ?
421-
*/
422-
// InOrder inOrder = inOrder(observer);
423-
//
424-
// inOrder.verify(observer, times(1)).onNext(1 * 7);
425-
// inOrder.verify(observer, times(1)).onNext(2 * 8);
426-
// inOrder.verify(observer, times(1)).onNext(3 + 4);
427-
// inOrder.verify(observer, times(1)).onNext(5 - 9);
428-
// inOrder.verify(observer, times(1)).onCompleted();
429-
// verify(observer, never()).onError(any(Throwable.class));
405+
InOrder inOrder = inOrder(observer);
406+
407+
inOrder.verify(observer, times(1)).onNext(1 * 7);
408+
inOrder.verify(observer, times(1)).onNext(2 * 8);
409+
inOrder.verify(observer, times(1)).onNext(3 + 4);
410+
inOrder.verify(observer, times(1)).onNext(5 - 9);
411+
inOrder.verify(observer, times(1)).onCompleted();
412+
verify(observer, never()).onError(any(Throwable.class));
430413
}
431414
}

0 commit comments

Comments
 (0)