|
@@ -55,6 +55,7 @@ import static org.junit.Assert.assertEquals;
|
55
|
55
|
import static org.mockito.Matchers.any;
|
56
|
56
|
import static org.mockito.Matchers.anyLong;
|
57
|
57
|
import static org.mockito.Matchers.eq;
|
|
58
|
+import static org.mockito.Mockito.doReturn;
|
58
|
59
|
import static org.mockito.Mockito.never;
|
59
|
60
|
import static org.mockito.Mockito.verify;
|
60
|
61
|
import static org.mockito.Mockito.when;
|
|
@@ -67,7 +68,7 @@ public class ConnectionHandlerTest {
|
67
|
68
|
@Mock private WindowModel windowModel;
|
68
|
69
|
@Mock private DMDircMBassador eventBus;
|
69
|
70
|
@Mock private ScheduledExecutorService scheduledExecutorService;
|
70
|
|
- @Mock private ScheduledFuture scheduledFuture;
|
|
71
|
+ @Mock private ScheduledFuture<?> scheduledFuture;
|
71
|
72
|
@Mock private ConnectionManager connectionManager;
|
72
|
73
|
@Mock private Connection connection;
|
73
|
74
|
@Mock private GroupChat groupChat;
|
|
@@ -81,8 +82,9 @@ public class ConnectionHandlerTest {
|
81
|
82
|
|
82
|
83
|
@Before
|
83
|
84
|
public void setUp() throws Exception {
|
84
|
|
- when(scheduledExecutorService.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(),
|
85
|
|
- any())).thenReturn(scheduledFuture);
|
|
85
|
+ doReturn(scheduledFuture).when(
|
|
86
|
+ scheduledExecutorService.scheduleAtFixedRate(
|
|
87
|
+ any(Runnable.class), anyLong(), anyLong(), any()));
|
86
|
88
|
when(windowModel.getEventBus()).thenReturn(eventBus);
|
87
|
89
|
when(connection.getWindowModel()).thenReturn(windowModel);
|
88
|
90
|
when(config.getBinder()).thenReturn(configBinder);
|
|
@@ -108,7 +110,7 @@ public class ConnectionHandlerTest {
|
108
|
110
|
instance.load();
|
109
|
111
|
verify(configBinder).bind(instance, ConnectionHandler.class);
|
110
|
112
|
verify(eventBus).subscribe(instance);
|
111
|
|
- verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
|
|
113
|
+ verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5L), eq(5L),
|
112
|
114
|
eq(TimeUnit.MILLISECONDS));
|
113
|
115
|
}
|
114
|
116
|
|
|
@@ -124,9 +126,9 @@ public class ConnectionHandlerTest {
|
124
|
126
|
public void testHandleWhoInterval() throws Exception {
|
125
|
127
|
instance.handleWhoInterval(10);
|
126
|
128
|
verify(scheduledFuture).cancel(false);
|
127
|
|
- verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
|
|
129
|
+ verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5L), eq(5L),
|
128
|
130
|
eq(TimeUnit.MILLISECONDS));
|
129
|
|
- verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(10l), eq(10l),
|
|
131
|
+ verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(10L), eq(10L),
|
130
|
132
|
eq(TimeUnit.MILLISECONDS));
|
131
|
133
|
}
|
132
|
134
|
|
|
@@ -148,7 +150,7 @@ public class ConnectionHandlerTest {
|
148
|
150
|
|
149
|
151
|
@Test
|
150
|
152
|
public void testHandleAwayEvent_WithReason() throws Exception {
|
151
|
|
- when(channelUserAwayEvent.getReason()).thenReturn(Optional.ofNullable("reason"));
|
|
153
|
+ when(channelUserAwayEvent.getReason()).thenReturn(Optional.of("reason"));
|
152
|
154
|
instance.load();
|
153
|
155
|
instance.handleAwayEvent(channelUserAwayEvent);
|
154
|
156
|
verify(channelUserAwayEvent, never())
|