PaymentServiceHandlerWrapper implements PaymentServiceHandler { @Override public void onPaymentError(@NonNull final MercadoPagoError error) { if (handleEsc(error)) { onRecoverPaymentEscInvalid(paymentRepository.createRecoveryForInvalidESC()); } else { addAndProcess(new ErrorMessage(error)); } } PaymentServiceHandlerWrapper(
        @NonNull final PaymentRepository paymentRepository,
        @NonNull final DisabledPaymentMethodRepository disabledPaymentMethodRepository,
        @NonNull final EscPaymentManager escPaymentManager,
        @NonNull final InstructionsRepository instructionsRepository,
        @NonNull final CongratsRepository congratsRepository,
        @NonNull final UserSelectionRepository userSelectionRepository); PaymentServiceEventHandler getObservableEvents(); void createTransactionLiveData(); void setHandler(@Nullable final PaymentServiceHandler handler); void detach(@Nullable final PaymentServiceHandler handler); @Override void onCvvRequired(@NonNull final Card card, @NonNull final Reason reason); @Override void onVisualPayment(); @Override void onRecoverPaymentEscInvalid(final PaymentRecovery recovery); @Override void onPaymentFinished(@NonNull final IPaymentDescriptor payment); @Override void onPostPayment(@NonNull final PaymentModel paymentModel); @Override void onPaymentError(@NonNull final MercadoPagoError error); void processMessages();  }
@Test public void whenPaymentFinishedWithErrorVerifyEscManaged() { final MercadoPagoError error = mock(MercadoPagoError.class); paymentServiceHandlerWrapper.onPaymentError(error); verify(escPaymentManager).manageEscForError(error, paymentRepository.getPaymentDataList()); verify(paymentRepository, times(2)).getPaymentDataList(); verify(wrapped).onPaymentError(error); noMoreInteractions(); }