### Question:
BaseApiClient { @NonNull public Single<List<Device>> getDevices() { if (!isProcessingServiceInstalled(context)) { return Single.error(NO_FPS_EXCEPTION); } final ChannelClient deviceMessenger = getMessengerClient(INFO_PROVIDER_SERVICE_COMPONENT); AppMessage appMessage = new AppMessage(DEVICE_INFO_REQUEST, getInternalData()); return deviceMessenger .sendMessage(appMessage.toJson()) .map(Device::fromJson) .toList() .doFinally(deviceMessenger::closeConnection) .onErrorResumeNext(throwable -> Single.error(createFlowException(throwable))); } protected  BaseApiClient(String apiVersion, Context context); @NonNull Completable initiateRequest(final Request request); Completable sendEvent(final FlowEvent flowEvent); @NonNull Observable<Response> queryResponses(@NonNull ResponseQuery responseQuery); @NonNull Single<List<Device>> getDevices(); @NonNull Observable<FlowEvent> subscribeToSystemEvents(); static boolean isProcessingServiceInstalled(Context context); @NonNull static String getProcessingServiceVersion(Context context); static final String FLOW_PROCESSING_SERVICE; }### Answer:
@Test public void getDevicesShouldSendCorrectMessage() throws Exception { pretendServiceIsInstalled(BaseApiClient.FLOW_PROCESSING_SERVICE_COMPONENT); apiBase.getDevices().test(); AppMessage appMessage = callSendAndCaptureMessage(); assertThat(appMessage).isNotNull(); verify(messengerClient).closeConnection(); }
@Test public void getDevicesShouldErrorIfNoFps() throws Exception { TestObserver<List<Device>> testObserver = apiBase.getDevices().test(); assertThat(testObserver.assertError(BaseApiClient.NO_FPS_EXCEPTION)); }