NetworkService implements NetworkConnectionListener { public void registerPrivateChatReceiverListener(final ReceiverListener listener) { if (privateChatEnabled) { messageDeduplicator.registerPrivateChatReceiverListener(listener); udpReceiver.registerReceiverListener(messageDeduplicator); } } NetworkService(final Controller controller, final Settings settings, final ErrorHandler errorHandler); void connect(); void disconnect(); ConnectionWorker getConnectionWorker(); boolean isConnectionWorkerAlive(); boolean isNetworkUp(); void registerNetworkConnectionListener(final NetworkConnectionListener listener); void registerMainChatMessageReceiverListener(final ReceiverListener listener); void registerPrivateChatReceiverListener(final ReceiverListener listener); boolean sendMessageToAllUsers(final String message); boolean sendMessageToUser(final String message, final User user); void checkNetwork(); @Override void networkWentDown(final boolean silent); @Override void beforeNetworkCameUp(); @Override void networkCameUp(final boolean silent);  }
@Test public void registerPrivateChatReceiverListenerShouldNotFailWhenPrivateChatDisabled() { when(settings.isNoPrivateChat()).thenReturn(true); final NetworkService networkService = new NetworkService(controller, settings, errorHandler); networkService.registerPrivateChatReceiverListener(null); }