### Question:
PaymentClientImpl extends BaseApiClient implements PaymentClient { @Override @NonNull public Completable initiatePayment(final Payment payment) { if (!isProcessingServiceInstalled(context)) { return Completable.error(NO_FPS_EXCEPTION); } final ChannelClient transactionMessenger = getMessengerClient(FLOW_PROCESSING_SERVICE_COMPONENT); AppMessage appMessage = createAppMessageForPayment(payment, ResponseMechanisms.RESPONSE_SERVICE); return transactionMessenger .sendMessage(appMessage.toJson()) .singleOrError() .ignoreElement() .doFinally(transactionMessenger::closeConnection) .onErrorResumeNext(throwable -> Completable.error(createFlowException(throwable))); } protected  PaymentClientImpl(Context context); @NonNull @Override Single<PaymentSettings> getPaymentSettings(); @Override @NonNull Completable initiatePayment(final Payment payment); @Override @NonNull Observable<PaymentResponse> queryPaymentResponses(@NonNull ResponseQuery paymentResponseQuery);  }### Answer:
@Test public void initiatePaymentShouldSendPaymentViaRequestCorrectly() { pretendFpsIsInstalled(); Payment payment = new PaymentBuilder().withPaymentFlow("blarp").withAmounts(new Amounts(1000, "GBP")).build(); String uuid = payment.getId(); paymentClient.initiatePayment(payment).test(); AppMessage sentAppMessage = callSendAndCaptureMessage(); Request request = Request.fromJson(sentAppMessage.getMessageData()); Payment sentPayment = request.getRequestData().getValue(AppMessageTypes.PAYMENT_MESSAGE, Payment.class); assertThat(sentPayment).isEqualTo(payment); verify(messengerClient).closeConnection(); }
@Test public void initiatePaymentShouldErrorIfNoFps() { Payment payment = new PaymentBuilder().withPaymentFlow("blarp").withAmounts(new Amounts(1000, "GBP")).build(); TestObserver<Void> test = paymentClient.initiatePayment(payment).test(); assertThat(test.errors().get(0)).isInstanceOf(FlowException.class); }