Skip to content

Commit

Permalink
Fix unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Holmes committed Jan 19, 2015
1 parent 399748c commit eb1d322
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void checkWho() {
connectionManager.getConnections().forEach(connection ->
connection.getGroupChatManager().getChannels().forEach(channel -> {
if (channel.getWindowModel().getConfigManager().getOptionBool(domain, "sendwho")) {
channel.requestUsersInfo();}}));
channel.requestUsersInfo();
}}));
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class ChannelWhoManagerTest {
public void setUp() throws Exception {
when(connectionManager.getConnections()).thenReturn(Lists.newArrayList(connection));
when(connectionHandlerFactory.get(connection)).thenReturn(connectionHandler);
instance = new ChannelWhoManager(connectionHandlerFactory, connectionManager, eventBus);
instance = new ChannelWhoManager("domain", connectionHandlerFactory, connectionManager,
eventBus);
instance.load();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public class ConnectionHandlerTest {

@Before
public void setUp() throws Exception {
when(scheduledExecutorService.schedule(any(Runnable.class), anyLong(), any()))
.thenReturn(scheduledFuture);
when(scheduledExecutorService.scheduleAtFixedRate(any(Runnable.class), anyLong(), anyLong(),
any())).thenReturn(scheduledFuture);
when(windowModel.getEventBus()).thenReturn(eventBus);
when(connection.getWindowModel()).thenReturn(windowModel);
when(config.getBinder()).thenReturn(configBinder);
Expand All @@ -107,7 +107,7 @@ public void testLoad() throws Exception {
instance.load();
verify(configBinder).bind(instance, ConnectionHandler.class);
verify(eventBus).subscribe(instance);
verify(scheduledExecutorService).schedule(any(Runnable.class), eq(5l),
verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
eq(TimeUnit.MILLISECONDS));
}

Expand All @@ -122,26 +122,26 @@ public void testUnload() throws Exception {
@Test
public void testHandleWhoInterval() throws Exception {
instance.handleWhoInterval(10);
verify(scheduledFuture).cancel(true);
verify(scheduledExecutorService).schedule(any(Runnable.class), eq(5l),
verify(scheduledFuture).cancel(false);
verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(5l), eq(5l),
eq(TimeUnit.MILLISECONDS));
verify(scheduledExecutorService).schedule(any(Runnable.class), eq(10l),
verify(scheduledExecutorService).scheduleAtFixedRate(any(Runnable.class), eq(10l), eq(10l),
eq(TimeUnit.MILLISECONDS));
}

@Test
public void testCheckWho_True() throws Exception {
when(config.getOptionBool("domain", "sendWho")).thenReturn(true);
when(config.getOptionBool("domain", "sendwho")).thenReturn(true);
instance.checkWho();
verify(config).getOptionBool("domain", "sendWho");
verify(config).getOptionBool("domain", "sendwho");
verify(groupChat).requestUsersInfo();
}

@Test
public void testCheckWho_False() throws Exception {
when(config.getOptionBool("domain", "sendWho")).thenReturn(false);
when(config.getOptionBool("domain", "sendwho")).thenReturn(false);
instance.checkWho();
verify(config).getOptionBool("domain", "sendWho");
verify(config).getOptionBool("domain", "sendwho");
verify(groupChat, never()).requestUsersInfo();
}

Expand Down

0 comments on commit eb1d322

Please sign in to comment.