|
15 | 15 | */ |
16 | 16 | package rx.internal.operators; |
17 | 17 |
|
| 18 | +import static org.junit.Assert.assertEquals; |
18 | 19 | import static org.mockito.Matchers.any; |
| 20 | +import static org.mockito.Matchers.notNull; |
| 21 | +import static org.mockito.Mockito.inOrder; |
| 22 | +import static org.mockito.Mockito.mock; |
| 23 | +import static org.mockito.Mockito.never; |
| 24 | +import static org.mockito.Mockito.spy; |
| 25 | +import static org.mockito.Mockito.times; |
| 26 | +import static org.mockito.Mockito.verify; |
| 27 | +import static org.mockito.Mockito.verifyNoMoreInteractions; |
| 28 | +import static org.mockito.Mockito.when; |
19 | 29 |
|
20 | 30 | import java.util.concurrent.TimeUnit; |
21 | 31 | import java.util.concurrent.atomic.AtomicInteger; |
22 | | -import static org.junit.Assert.assertEquals; |
23 | | -import static org.mockito.Matchers.notNull; |
24 | | -import static org.mockito.Mockito.*; |
25 | 32 |
|
26 | 33 | import org.junit.Test; |
27 | 34 | import org.mockito.InOrder; |
28 | 35 |
|
29 | | - |
30 | 36 | import rx.Observable; |
31 | 37 | import rx.Observer; |
32 | 38 | import rx.Scheduler; |
@@ -523,14 +529,15 @@ public void call() { |
523 | 529 | /** |
524 | 530 | * test the basic expectation of OperatorMulticast via replay |
525 | 531 | */ |
| 532 | + @SuppressWarnings("unchecked") |
526 | 533 | @Test |
527 | 534 | public void testIssue2191_UnsubscribeSource() { |
528 | 535 | // setup mocks |
529 | | - Action1 sourceNext = mock(Action1.class); |
| 536 | + Action1<Integer> sourceNext = mock(Action1.class); |
530 | 537 | Action0 sourceCompleted = mock(Action0.class); |
531 | 538 | Action0 sourceUnsubscribed = mock(Action0.class); |
532 | | - Observer spiedSubscriberBeforeConnect = mock(Observer.class); |
533 | | - Observer spiedSubscriberAfterConnect = mock(Observer.class); |
| 539 | + Observer<Integer> spiedSubscriberBeforeConnect = mock(Observer.class); |
| 540 | + Observer<Integer> spiedSubscriberAfterConnect = mock(Observer.class); |
534 | 541 |
|
535 | 542 | // Observable under test |
536 | 543 | Observable<Integer> source = Observable.just(1,2); |
@@ -570,17 +577,18 @@ public void testIssue2191_UnsubscribeSource() { |
570 | 577 | * |
571 | 578 | * @throws Exception |
572 | 579 | */ |
| 580 | + @SuppressWarnings("unchecked") |
573 | 581 | @Test |
574 | 582 | public void testIssue2191_SchedulerUnsubscribe() throws Exception { |
575 | 583 | // setup mocks |
576 | | - Action1 sourceNext = mock(Action1.class); |
| 584 | + Action1<Integer> sourceNext = mock(Action1.class); |
577 | 585 | Action0 sourceCompleted = mock(Action0.class); |
578 | 586 | Action0 sourceUnsubscribed = mock(Action0.class); |
579 | 587 | final Scheduler mockScheduler = mock(Scheduler.class); |
580 | 588 | final Subscription mockSubscription = mock(Subscription.class); |
581 | 589 | Worker spiedWorker = workerSpy(mockSubscription); |
582 | | - Observer mockObserverBeforeConnect = mock(Observer.class); |
583 | | - Observer mockObserverAfterConnect = mock(Observer.class); |
| 590 | + Observer<Integer> mockObserverBeforeConnect = mock(Observer.class); |
| 591 | + Observer<Integer> mockObserverAfterConnect = mock(Observer.class); |
584 | 592 |
|
585 | 593 | when(mockScheduler.createWorker()).thenReturn(spiedWorker); |
586 | 594 |
|
@@ -626,18 +634,19 @@ public void testIssue2191_SchedulerUnsubscribe() throws Exception { |
626 | 634 | * |
627 | 635 | * @throws Exception |
628 | 636 | */ |
| 637 | + @SuppressWarnings("unchecked") |
629 | 638 | @Test |
630 | 639 | public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception { |
631 | 640 | // setup mocks |
632 | | - Action1 sourceNext = mock(Action1.class); |
| 641 | + Action1<Integer> sourceNext = mock(Action1.class); |
633 | 642 | Action0 sourceCompleted = mock(Action0.class); |
634 | | - Action1 sourceError = mock(Action1.class); |
| 643 | + Action1<Throwable> sourceError = mock(Action1.class); |
635 | 644 | Action0 sourceUnsubscribed = mock(Action0.class); |
636 | 645 | final Scheduler mockScheduler = mock(Scheduler.class); |
637 | 646 | final Subscription mockSubscription = mock(Subscription.class); |
638 | 647 | Worker spiedWorker = workerSpy(mockSubscription); |
639 | | - Observer mockObserverBeforeConnect = mock(Observer.class); |
640 | | - Observer mockObserverAfterConnect = mock(Observer.class); |
| 648 | + Observer<Integer> mockObserverBeforeConnect = mock(Observer.class); |
| 649 | + Observer<Integer> mockObserverAfterConnect = mock(Observer.class); |
641 | 650 |
|
642 | 651 | when(mockScheduler.createWorker()).thenReturn(spiedWorker); |
643 | 652 |
|
@@ -682,14 +691,14 @@ public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception { |
682 | 691 | verifyNoMoreInteractions(mockObserverAfterConnect); |
683 | 692 | } |
684 | 693 |
|
685 | | - private static void verifyObserverMock(Observer mock, int numSubscriptions, int numItemsExpected) { |
686 | | - verify(mock, times(numItemsExpected)).onNext(notNull()); |
| 694 | + private static void verifyObserverMock(Observer<Integer> mock, int numSubscriptions, int numItemsExpected) { |
| 695 | + verify(mock, times(numItemsExpected)).onNext((Integer) notNull()); |
687 | 696 | verify(mock, times(numSubscriptions)).onCompleted(); |
688 | 697 | verifyNoMoreInteractions(mock); |
689 | 698 | } |
690 | 699 |
|
691 | | - private static void verifyObserver(Observer mock, int numSubscriptions, int numItemsExpected, Throwable error) { |
692 | | - verify(mock, times(numItemsExpected)).onNext(notNull()); |
| 700 | + private static void verifyObserver(Observer<Integer> mock, int numSubscriptions, int numItemsExpected, Throwable error) { |
| 701 | + verify(mock, times(numItemsExpected)).onNext((Integer) notNull()); |
693 | 702 | verify(mock, times(numSubscriptions)).onError(error); |
694 | 703 | verifyNoMoreInteractions(mock); |
695 | 704 | } |
|
0 commit comments