Explorar el Código

Fix unit tests.

pull/377/head
Greg Holmes hace 9 años
padre
commit
eb1d322dca

+ 2
- 1
channelwho/src/com/dmdirc/addons/channelwho/ConnectionHandler.java Ver fichero

90
         connectionManager.getConnections().forEach(connection ->
90
         connectionManager.getConnections().forEach(connection ->
91
                 connection.getGroupChatManager().getChannels().forEach(channel -> {
91
                 connection.getGroupChatManager().getChannels().forEach(channel -> {
92
                     if (channel.getWindowModel().getConfigManager().getOptionBool(domain, "sendwho")) {
92
                     if (channel.getWindowModel().getConfigManager().getOptionBool(domain, "sendwho")) {
93
-                        channel.requestUsersInfo();}}));
93
+                        channel.requestUsersInfo();
94
+                    }}));
94
     }
95
     }
95
 
96
 
96
     @VisibleForTesting
97
     @VisibleForTesting

+ 2
- 1
channelwho/test/com/dmdirc/addons/channelwho/ChannelWhoManagerTest.java Ver fichero

56
     public void setUp() throws Exception {
56
     public void setUp() throws Exception {
57
         when(connectionManager.getConnections()).thenReturn(Lists.newArrayList(connection));
57
         when(connectionManager.getConnections()).thenReturn(Lists.newArrayList(connection));
58
         when(connectionHandlerFactory.get(connection)).thenReturn(connectionHandler);
58
         when(connectionHandlerFactory.get(connection)).thenReturn(connectionHandler);
59
-        instance = new ChannelWhoManager(connectionHandlerFactory, connectionManager, eventBus);
59
+        instance = new ChannelWhoManager("domain", connectionHandlerFactory, connectionManager,
60
+                eventBus);
60
         instance.load();
61
         instance.load();
61
     }
62
     }
62
 
63
 

+ 10
- 10
channelwho/test/com/dmdirc/addons/channelwho/ConnectionHandlerTest.java Ver fichero

81
 
81
 
82
     @Before
82
     @Before
83
     public void setUp() throws Exception {
83
     public void setUp() throws Exception {
84
-        when(scheduledExecutorService.schedule(any(Runnable.class), anyLong(), any()))
85
-                .thenReturn(scheduledFuture);
84
+        when(scheduledExecutorService.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(),
85
+                any())).thenReturn(scheduledFuture);
86
         when(windowModel.getEventBus()).thenReturn(eventBus);
86
         when(windowModel.getEventBus()).thenReturn(eventBus);
87
         when(connection.getWindowModel()).thenReturn(windowModel);
87
         when(connection.getWindowModel()).thenReturn(windowModel);
88
         when(config.getBinder()).thenReturn(configBinder);
88
         when(config.getBinder()).thenReturn(configBinder);
107
         instance.load();
107
         instance.load();
108
         verify(configBinder).bind(instance, ConnectionHandler.class);
108
         verify(configBinder).bind(instance, ConnectionHandler.class);
109
         verify(eventBus).subscribe(instance);
109
         verify(eventBus).subscribe(instance);
110
-        verify(scheduledExecutorService).schedule(any(Runnable.class), eq(5l),
110
+        verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
111
                 eq(TimeUnit.MILLISECONDS));
111
                 eq(TimeUnit.MILLISECONDS));
112
     }
112
     }
113
 
113
 
122
     @Test
122
     @Test
123
     public void testHandleWhoInterval() throws Exception {
123
     public void testHandleWhoInterval() throws Exception {
124
         instance.handleWhoInterval(10);
124
         instance.handleWhoInterval(10);
125
-        verify(scheduledFuture).cancel(true);
126
-        verify(scheduledExecutorService).schedule(any(Runnable.class), eq(5l),
125
+        verify(scheduledFuture).cancel(false);
126
+        verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
127
                 eq(TimeUnit.MILLISECONDS));
127
                 eq(TimeUnit.MILLISECONDS));
128
-        verify(scheduledExecutorService).schedule(any(Runnable.class), eq(10l),
128
+        verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(10l), eq(10l),
129
                 eq(TimeUnit.MILLISECONDS));
129
                 eq(TimeUnit.MILLISECONDS));
130
     }
130
     }
131
 
131
 
132
     @Test
132
     @Test
133
     public void testCheckWho_True() throws Exception {
133
     public void testCheckWho_True() throws Exception {
134
-        when(config.getOptionBool("domain", "sendWho")).thenReturn(true);
134
+        when(config.getOptionBool("domain", "sendwho")).thenReturn(true);
135
         instance.checkWho();
135
         instance.checkWho();
136
-        verify(config).getOptionBool("domain", "sendWho");
136
+        verify(config).getOptionBool("domain", "sendwho");
137
         verify(groupChat).requestUsersInfo();
137
         verify(groupChat).requestUsersInfo();
138
     }
138
     }
139
 
139
 
140
     @Test
140
     @Test
141
     public void testCheckWho_False() throws Exception {
141
     public void testCheckWho_False() throws Exception {
142
-        when(config.getOptionBool("domain", "sendWho")).thenReturn(false);
142
+        when(config.getOptionBool("domain", "sendwho")).thenReturn(false);
143
         instance.checkWho();
143
         instance.checkWho();
144
-        verify(config).getOptionBool("domain", "sendWho");
144
+        verify(config).getOptionBool("domain", "sendwho");
145
         verify(groupChat, never()).requestUsersInfo();
145
         verify(groupChat, never()).requestUsersInfo();
146
     }
146
     }
147
 
147
 

Loading…
Cancelar
Guardar