### Question:
ObservableWebSocketClient extends ObservableMessengerClient { @Override public Observable<String> sendMessage(final String message) { if (!super.isConnected()) { return connectAndSendMessage(message); } else { if (responseEmitter == null || responseEmitter.hasComplete()) { responseEmitter = PublishSubject.create(); } if (okWebSocketClient != null && okWebSocketClient.isConnected()) { okWebSocketClient.updateCallbackEmitter(responseEmitter); okWebSocketClient.sendMessage(message); } else { super.sendMessage(message); } return responseEmitter; } } ObservableWebSocketClient(Context context, ComponentName serviceComponentName); @Override Completable connect(); @Override boolean isConnected(); @Override Observable<String> sendMessage(final String message); @Override void closeConnection();  }### Answer:
@Test public void willSendMessageViaWebsocket() throws RemoteException { setupMockBoundMessengerService(); createObservableSendDataAndSubscribe("hellooooo"); sendConnectionParamsFromServer(); setWebSocketConnectedState(true); observableWebSocketClient.sendMessage("This is ground control to Major Tom").test(); verify(observableWebSocketClient.okWebSocketClient).sendMessage("This is ground control to Major Tom"); }
@Test public void willFallbackToMessengerIfNotConnected() throws RemoteException { setupMockBoundMessengerService(); createObservableSendDataAndSubscribe("connect with me"); sendConnectionParamsFromServer(); setWebSocketConnectedState(false); observableWebSocketClient.sendMessage("Stop messaging me").test(); verify(observableWebSocketClient.okWebSocketClient, times(0)).sendMessage(anyString()); verifyMessagesSentToServerViaMessenger(2); }