ExpressPaymentPresenter extends BasePresenter<ExpressPayment.View> implements ExpressPayment.Actions, AmountDescriptorView.OnClickListener { @Override public void onHeaderClicked() { final CheckoutPreference checkoutPreference = paymentSettingRepository.getCheckoutPreference(); final DynamicDialogConfiguration dynamicDialogConfiguration = paymentSettingRepository.getAdvancedConfiguration().getDynamicDialogConfiguration(); final DynamicDialogCreator.CheckoutData checkoutData = new DynamicDialogCreator.CheckoutData(checkoutPreference, Collections.singletonList(new PaymentData())); if (dynamicDialogConfiguration.hasCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER)) { getView().showDynamicDialog( dynamicDialogConfiguration.getCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER), checkoutData); } } ExpressPaymentPresenter(@NonNull final PaymentSettingRepository paymentSettingRepository,
        @NonNull final DisabledPaymentMethodRepository disabledPaymentMethodRepository,
        @NonNull final PayerCostSelectionRepository payerCostSelectionRepository,
        @NonNull final DiscountRepository discountRepository,
        @NonNull final AmountRepository amountRepository,
        @NonNull final InitRepository initRepository,
        @NonNull final AmountConfigurationRepository amountConfigurationRepository,
        @NonNull final ChargeRepository chargeRepository,
        @NonNull final ESCManagerBehaviour escManagerBehaviour,
        @NonNull final PaymentMethodDrawableItemMapper paymentMethodDrawableItemMapper,
        @NonNull final ExperimentsRepository experimentsRepository,
        @NonNull final PayerComplianceRepository payerComplianceRepository,
        @NonNull final TrackingRepository trackingRepository,
        @NonNull final PaymentMethodDescriptorMapper paymentMethodDescriptorMapper,
        @NonNull final CustomTextsRepository customTextsRepository); @Override void loadViewModel(); @Override void attachView(final ExpressPayment.View view); @Override void recoverFromBundle(@NonNull final Bundle bundle); @NonNull @Override Bundle storeInBundle(@NonNull final Bundle bundle); @Override void onFreshStart(); @Override void cancel(); @Override void onBack(); @Override void onInstallmentsRowPressed(); @Override void onInstallmentSelectionCanceled(); @Override void onSliderOptionSelected(final int paymentMethodIndex); @Override void onPayerCostSelected(final PayerCost payerCostSelected); void onDisabledDescriptorViewClick(); @Override void onDiscountAmountDescriptorClicked(@NonNull final DiscountConfigurationModel discountModel); @Override void onChargesAmountDescriptorClicked(@NonNull final DynamicDialogCreator dynamicDialogCreator); @Override void onSplitChanged(final boolean isChecked); @Override void onHeaderClicked(); @Override void onPostPaymentAction(@NonNull final PostPaymentAction postPaymentAction); @Override void onOtherPaymentMethodClicked(); @Override @SuppressLint("WrongConstant") void handlePrePaymentAction(@NonNull final PayButton.OnReadyForPaymentCallback callback); @Override void handleGenericDialogAction(@NonNull @ActionType final String type); @Override void handleDeepLink(); @Override void onCardFormResult();  }
@Test public void whenElementDescriptorViewClickedAndHasCreatorThenShowDynamicDialog() { final DynamicDialogCreator dynamicDialogCreatorMock = mock(DynamicDialogCreator.class); when(dynamicDialogConfiguration.hasCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER)) .thenReturn(true); when(dynamicDialogConfiguration.getCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER)) .thenReturn(dynamicDialogCreatorMock); expressPaymentPresenter.onHeaderClicked(); verify(dynamicDialogConfiguration) .hasCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER); verify(dynamicDialogConfiguration) .getCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER); verify(view).showDynamicDialog(eq(dynamicDialogCreatorMock), any(DynamicDialogCreator.CheckoutData.class)); verifyNoMoreInteractions(view); verifyNoMoreInteractions(dynamicDialogConfiguration); }
@Test public void whenElementDescriptorViewClickedAndHasNotCreatorThenDoNotShowDynamicDialog() { expressPaymentPresenter.onHeaderClicked(); verify(dynamicDialogConfiguration) .hasCreatorFor(DynamicDialogConfiguration.DialogLocation.TAP_ONE_TAP_HEADER); verifyNoMoreInteractions(view); verifyNoMoreInteractions(dynamicDialogConfiguration); }