when(factory.getConnection(API_KEY, pusherOptions)).thenReturn(connection);
when(factory.getChannelManager()).thenAnswer(new Answer<ChannelManager>() {
@Override
public ChannelManager answer(InvocationOnMock invocation) throws Throwable {
return new ChannelManager(factory);
}
});
when(factory.newPresenceChannel(any(InternalConnection.class), anyString(), any(Authorizer.class))).thenCallRealMethod();
when(factory.newPrivateChannel(any(InternalConnection.class), anyString(), any(Authorizer.class))).thenCallRealMethod();