diff --git a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodTest.java b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodTest.java index 29106e351..3a7b10713 100644 --- a/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodTest.java +++ b/transfermethodui/src/androidTest/java/com/hyperwallet/android/ui/transfermethod/SelectTransferMethodTest.java @@ -126,7 +126,7 @@ public void testSelectTransferMethod_verifyCountrySelectionList() { onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.country_selection_toolbar)))).check( matches(withText(R.string.mobileCountryRegion))); onView(withId(R.id.search_button)).check(doesNotExist()); - onView(withId(R.id.country_selection_list)).check(new RecyclerViewCountAssertion(5)); + onView(withId(R.id.country_selection_list)).check(new RecyclerViewCountAssertion(6)); onView(allOf(withId(R.id.country_name), withText("Canada"))).check(matches(isDisplayed())); onView(allOf(withId(R.id.country_name), withText("Croatia"))).check(matches(isDisplayed())); onView(allOf(withId(R.id.country_name), withText("Mexico"))).check(matches(isDisplayed())); @@ -207,10 +207,12 @@ public void testSelectTransferMethod_verifyTransferMethodsList() { matches(atPosition(0, hasDescendant(withText(R.string.bank_account))))); String bankCardFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, usdDollarSymbol + "2.00", "1-2 Business days"); + .getString(R.string.feeInformation, usdDollarSymbol + "2.00"); + String bankCardProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-2 Business days"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(0, hasDescendant(withText(bankCardFee))))); + matches(atPosition(0, hasDescendant(withText(bankCardFee+bankCardProcessingTime))))); onView(withId(R.id.select_transfer_method_types_list)).check( matches(atPosition(1, hasDescendant(withText(R.string.bank_card_font_icon))))); @@ -218,10 +220,13 @@ public void testSelectTransferMethod_verifyTransferMethodsList() { matches(atPosition(1, hasDescendant(withText(R.string.bank_card))))); String debitCardFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, usdDollarSymbol + "1.75", "IMMEDIATE"); + .getString(R.string.feeInformation, usdDollarSymbol + "1.75"); + + String debitCardProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "IMMEDIATE"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(1, hasDescendant(withText(debitCardFee))))); + matches(atPosition(1, hasDescendant(withText(debitCardFee+debitCardProcessingTime))))); onView(withId(R.id.select_transfer_method_types_list)).check( @@ -233,10 +238,12 @@ public void testSelectTransferMethod_verifyTransferMethodsList() { matches(atPosition(2, hasDescendant(wireAccountViewMatchers)))); String wireTransferFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, usdDollarSymbol + "20.00", "1-3 Business days"); + .getString(R.string.feeInformation, usdDollarSymbol + "20.00"); + String wireTransferProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-3 Business days"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(2, hasDescendant(withText(wireTransferFee))))); + matches(atPosition(2, hasDescendant(withText(wireTransferFee+wireTransferProcessingTime))))); onView(withId(R.id.select_transfer_method_types_list)).check( matches(atPosition(3, hasDescendant(withText(R.string.paypal_account_font_icon))))); @@ -244,10 +251,12 @@ public void testSelectTransferMethod_verifyTransferMethodsList() { matches(atPosition(3, hasDescendant(withText("PayPal"))))); String paypalFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, usdDollarSymbol + "0.25", "IMMEDIATE"); + .getString(R.string.feeInformation, usdDollarSymbol + "0.25"); + String paypalProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "IMMEDIATE"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(3, hasDescendant(withText(paypalFee))))); + matches(atPosition(3, hasDescendant(withText(paypalFee+paypalProcessingTime))))); } @Test @@ -268,7 +277,7 @@ public void testSelectTransferMethod_verifyTransferMethodsListEmptyFee() { onView(withId(R.id.select_transfer_method_types_list)).check( matches(atPosition(0, hasDescendant(withText(R.string.bank_account))))); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(0, hasDescendant(withText("1-2 Business days"))))); + matches(atPosition(0, hasDescendant(withText("No fee \u2022 1-2 Business days"))))); } @Test @@ -318,10 +327,12 @@ public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelection matches(atPosition(0, hasDescendant(withText(R.string.bank_account))))); String bankAccountFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, cdnDollarSymbol + "2.20", "1-2 Business days"); + .getString(R.string.feeInformation, cdnDollarSymbol + "2.20"); + String bankCardProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-2 Business days"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(0, hasDescendant(withText(bankAccountFee))))); + matches(atPosition(0, hasDescendant(withText(bankAccountFee+bankCardProcessingTime))))); onView(withId(R.id.select_transfer_method_types_list)).check( matches(atPosition(1, hasDescendant(withText(R.string.paypal_account_font_icon))))); @@ -329,10 +340,12 @@ public void testSelectTransferMethod_verifyTransferMethodsListUpdatedOnSelection matches(atPosition(1, hasDescendant(withText("PayPal"))))); String paypalFee = InstrumentationRegistry.getInstrumentation().getTargetContext() - .getString(R.string.feeAndProcessingTimeInformation, cdnDollarSymbol + "0.25", "IMMEDIATE"); + .getString(R.string.feeInformation, cdnDollarSymbol + "0.25"); + String paypalProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "IMMEDIATE"); onView(withId(R.id.select_transfer_method_types_list)).check( - matches(atPosition(1, hasDescendant(withText(paypalFee))))); + matches(atPosition(1, hasDescendant(withText(paypalFee+paypalProcessingTime))))); } @Test @@ -445,4 +458,95 @@ public void testSelectTransferMethod_verifyDefaultsToUSWhenUserProfileDoesNotHav onView(withId(R.id.select_transfer_method_country_value)).check(matches(withText("United States"))); onView(withId(R.id.select_transfer_method_currency_value)).check(matches(withText("USD"))); } + + @Test + public void testSelectTransferMethod_verifyNoFeeLabelsDisplayed() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("successful_tmc_keys_response.json")).mock(); + + mActivityTestRule.launchActivity(null); + + onView(withId(R.id.toolbar)).check(matches(isDisplayed())); + onView(withText(R.string.mobileAddTransferMethodHeader)).check(matches(withParent(withId(R.id.toolbar)))); + + onView(withId(R.id.select_transfer_method_country_value)).check(matches(withText("United States"))); + onView(withId(R.id.select_transfer_method_currency_value)).check(matches(withText("USD"))); + onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(4)); + + onView(withId(R.id.select_transfer_method_country_value)).perform(click()); + onView(allOf(withId(R.id.country_name), withText("CHINA"))).perform(click()); + + String bankAccountFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.noFee); + String bankAccountProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-2 Business days"); + + onView(withId(R.id.select_transfer_method_types_list)).check( + matches(atPosition(0, hasDescendant(withText(bankAccountFee+bankAccountProcessingTime))))); + + + String bankCardFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.noFee); + String bankCardProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "IMMEDIATE"); + + onView(withId(R.id.select_transfer_method_types_list)).check( + matches(atPosition(1, hasDescendant(withText(bankCardFee+bankCardProcessingTime))))); + + + + String wireTransferFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.noFee); + String wireTransferProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-3 Business days"); + + onView(withId(R.id.select_transfer_method_types_list)).check( + matches(atPosition(2, hasDescendant(withText(wireTransferFee+wireTransferProcessingTime))))); + + String paypalTransferFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.noFee); + String paypalTransferProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "IMMEDIATE"); + + onView(withId(R.id.select_transfer_method_types_list)).check( + matches(atPosition(3, hasDescendant(withText(paypalTransferFee+paypalTransferProcessingTime))))); + + + } + + @Test + public void testSelectTransferMethod_verifyMixedFeeIsDisplayed() { + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("user_response.json")).mock(); + mMockWebServer.mockResponse().withHttpResponseCode(HTTP_OK).withBody(sResourceManager + .getResourceContent("successful_tmc_keys_mixedfee_response.json")).mock(); + + mActivityTestRule.launchActivity(null); + + onView(withId(R.id.toolbar)).check(matches(isDisplayed())); + onView(withText(R.string.mobileAddTransferMethodHeader)).check(matches(withParent(withId(R.id.toolbar)))); + + onView(withId(R.id.select_transfer_method_country_value)).check(matches(withText("United States"))); + onView(withId(R.id.select_transfer_method_currency_value)).check(matches(withText("USD"))); + onView(withId(R.id.select_transfer_method_types_list)).check(new RecyclerViewCountAssertion(4)); + + onView(withId(R.id.select_transfer_method_country_value)).perform(click()); + onView(allOf(withId(R.id.country_name), withText("CHINA"))).perform(click()); + + String mixedFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.fee_mix_formatter,usdDollarSymbol,"5.00","4.50","4.00","10.00"); + + String venmoTransferFee = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.feeInformation,mixedFee); + + String venmoTransferProcessingTime = InstrumentationRegistry.getInstrumentation().getTargetContext() + .getString(R.string.processingTimeInformation, "1-2 Business days"); + + onView(withId(R.id.select_transfer_method_types_list)).check( + matches(atPosition(4, hasDescendant(withText(venmoTransferFee+venmoTransferProcessingTime))))); + + + } } diff --git a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/AddTransferMethodFragment.java b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/AddTransferMethodFragment.java index dde95a619..e52d53610 100644 --- a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/AddTransferMethodFragment.java +++ b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/AddTransferMethodFragment.java @@ -28,6 +28,7 @@ import static com.hyperwallet.android.model.transfermethod.TransferMethod.TransferMethodTypes.WIRE_ACCOUNT; import static com.hyperwallet.android.ui.common.intent.HyperwalletIntent.EXTRA_TRANSFER_METHOD_ADDED; import static com.hyperwallet.android.ui.transfermethod.TransferMethodLocalBroadcast.TransferMethodLocalBroadcastAction.ACTION_HYPERWALLET_TRANSFER_METHOD_ADDED; +import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.getFormattedFeeAndProcessingTime; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isFeeAvailable; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isProcessingTimeAvailable; @@ -408,22 +409,12 @@ public void showTransactionInformation(@NonNull final List fees, View container = getView().findViewById(R.id.add_transfer_method_static_container); TextView feeAndProcessingTime = getView().findViewById(R.id.add_transfer_method_information); - if (isFeeAvailable(fees) && isProcessingTimeAvailable(processingTime)) { - String formattedFee = FeeFormatter.getFormattedFee(header.getContext(), fees); - feeAndProcessingTime.setVisibility(View.VISIBLE); - feeAndProcessingTime.setText( - feeAndProcessingTime.getContext().getString(R.string.feeAndProcessingTimeInformation, formattedFee, - processingTime.getValue())); - } else if (isFeeAvailable(fees) && !isProcessingTimeAvailable(processingTime)) { - String formattedFee = FeeFormatter.getFormattedFee(header.getContext(), fees); + if (!isFeeAvailable(fees) && !isProcessingTimeAvailable(processingTime)) { + feeAndProcessingTime.setVisibility(View.GONE); + } else { feeAndProcessingTime.setVisibility(View.VISIBLE); feeAndProcessingTime.setText( - feeAndProcessingTime.getContext().getString(R.string.feeInformation, formattedFee)); - } else if (isProcessingTimeAvailable(processingTime) && !isFeeAvailable(fees)) { - feeAndProcessingTime.setVisibility(View.VISIBLE); - feeAndProcessingTime.setText(processingTime.getValue()); - } else { - feeAndProcessingTime.setVisibility(View.GONE); + getFormattedFeeAndProcessingTime(feeAndProcessingTime.getContext(), fees, processingTime)); } if (feeAndProcessingTime.getVisibility() == View.VISIBLE) { diff --git a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/FeeFormatter.java b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/FeeFormatter.java index ad092748d..b97c4ef5d 100644 --- a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/FeeFormatter.java +++ b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/FeeFormatter.java @@ -35,7 +35,7 @@ public class FeeFormatter { public static String getFormattedFee(@NonNull final Context context, @NonNull final List fees) { - String formattedString = context.getResources().getString(R.string.unknown); + String formattedString = context.getResources().getString(R.string.noFee); if (fees.size() == 1) { formattedString = getSingleFormattedFee(context, fees, formattedString); } else { @@ -48,10 +48,13 @@ private static String getSingleFormattedFee(@NonNull Context context, @NonNull L String formattedString) { Fee fee = fees.get(0); if (Fee.FeeRate.FLAT.equals(fee.getFeeRateType())) { + if (!isValidFee(fee.getValue())) { + return formattedString; + } formattedString = context.getResources().getString(R.string.fee_flat_formatter, Currency.getInstance(fee.getCurrency()).getSymbol(Locale.getDefault()), fee.getValue()); } else if (Fee.FeeRate.PERCENT.equals(fee.getFeeRateType())) { - formattedString = getPercentFormattedFee(context, fee); + formattedString = getPercentFormattedFee(context, fee, formattedString); } return formattedString; } @@ -72,18 +75,48 @@ private static String getMixFormattedFee(@NonNull Context context, @NonNull List if (flatFee != null && percentFee != null) { String minimumAmount = percentFee.getMin(); String maximumAmount = percentFee.getMax(); - if (maximumAmount.isEmpty() && minimumAmount.isEmpty()) { + + if (!isValidFee(flatFee.getValue()) && !isValidFee(percentFee.getValue())) { + return formattedString; + } else if (maximumAmount.isEmpty() && minimumAmount.isEmpty() && !isValidFee(percentFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_flat_formatter, + Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue()); + } else if (maximumAmount.isEmpty() && minimumAmount.isEmpty() && !isValidFee(flatFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_percent_no_min_and_max_formatter, + percentFee.getValue()); + } else if (maximumAmount.isEmpty() && minimumAmount.isEmpty()) { formattedString = context.getResources().getString(R.string.fee_mix_no_min_and_max_formatter, Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue(), percentFee.getValue()); + } else if (maximumAmount.isEmpty() && !isValidFee(percentFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_flat_formatter, + Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue()); + } else if (maximumAmount.isEmpty() && !isValidFee(flatFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_percent_only_min_formatter, + percentFee.getValue(), + percentFee.getCurrency(), minimumAmount); } else if (maximumAmount.isEmpty()) { formattedString = context.getResources().getString(R.string.fee_mix_only_min_formatter, Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue(), percentFee.getValue(), minimumAmount); + } else if (minimumAmount.isEmpty() && !isValidFee(percentFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_flat_formatter, + Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue()); + } else if (minimumAmount.isEmpty() && !isValidFee(flatFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_percent_only_max_formatter, + percentFee.getValue(), + percentFee.getCurrency(), maximumAmount); } else if (minimumAmount.isEmpty()) { formattedString = context.getResources().getString(R.string.fee_mix_only_max_formatter, Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue(), percentFee.getValue(), maximumAmount); + } else if (isValidFee(percentFee.getValue()) && !isValidFee(flatFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_percent_formatter, + percentFee.getValue(), + percentFee.getCurrency(), minimumAmount, maximumAmount); + } else if (isValidFee(flatFee.getValue()) && !isValidFee(percentFee.getValue())) { + formattedString = context.getResources().getString(R.string.fee_flat_formatter, + Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), flatFee.getValue()); } else { formattedString = context.getResources().getString(R.string.fee_mix_formatter, Currency.getInstance(flatFee.getCurrency()).getSymbol(Locale.getDefault()), @@ -94,10 +127,15 @@ private static String getMixFormattedFee(@NonNull Context context, @NonNull List } - private static String getPercentFormattedFee(@NonNull final Context context, @NonNull final Fee fee) { + private static String getPercentFormattedFee(@NonNull final Context context, @NonNull final Fee fee, + String formattedString) { String formattedFee; String minimumAmount = fee.getMin(); String maximumAmount = fee.getMax(); + + if (!isValidFee(fee.getValue())) { + return formattedString; + } if (maximumAmount.isEmpty() && minimumAmount.isEmpty()) { formattedFee = context.getResources().getString(R.string.fee_percent_no_min_and_max_formatter, fee.getValue()); @@ -122,4 +160,41 @@ protected static boolean isFeeAvailable(@Nullable final List fees) { protected static boolean isProcessingTimeAvailable(@Nullable final ProcessingTime processingTime) { return processingTime != null && !TextUtils.isEmpty(processingTime.getValue()); } + + protected static boolean isNoFeeStringAvailable(@NonNull final Context context, String fee) { + return fee.contains(context.getResources().getString(R.string.noFee)); + } + + protected static boolean isValidFee(String fee) { + if (TextUtils.isEmpty(fee)) { + return false; + } else { + return Double.parseDouble(fee) != 0.0; + } + } + + public static String getFormattedFeeAndProcessingTime(@NonNull Context context, @NonNull final List fees, + @Nullable final ProcessingTime processingTime) { + if (isFeeAvailable(fees)) { + String formattedFee = getFormattedFee(context, fees); + if (isNoFeeStringAvailable(context, formattedFee) && isProcessingTimeAvailable(processingTime)) { + return String.format("%s%s", context.getResources().getString(R.string.noFee), + context.getResources().getString(R.string.processingTimeInformation, + processingTime.getValue())); + } else if (!isNoFeeStringAvailable(context, formattedFee) && !isProcessingTimeAvailable(processingTime)) { + return context.getResources().getString(R.string.feeInformation, formattedFee); + } else if (!isNoFeeStringAvailable(context, formattedFee) && isProcessingTimeAvailable(processingTime)) { + return String.format("%s%s", context.getResources().getString(R.string.feeInformation, formattedFee), + context.getResources().getString(R.string.processingTimeInformation, + processingTime.getValue())); + } else { + return context.getResources().getString(R.string.noFee); + } + } else if (isProcessingTimeAvailable(processingTime) && !isFeeAvailable(fees)) { + return String.format("%s%s", context.getResources().getString(R.string.noFee), + context.getResources().getString(R.string.processingTimeInformation, processingTime.getValue())); + } else { + return context.getResources().getString(R.string.noFee); + } + } } diff --git a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodFragment.java b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodFragment.java index 51b7fed6a..268daffd6 100644 --- a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodFragment.java +++ b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/SelectTransferMethodFragment.java @@ -20,6 +20,7 @@ import static com.hyperwallet.android.ui.common.intent.HyperwalletIntent.ADD_TRANSFER_METHOD_REQUEST_CODE; import static com.hyperwallet.android.ui.common.view.TransferMethodUtils.getStringFontIcon; +import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.getFormattedFeeAndProcessingTime; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isFeeAvailable; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isProcessingTimeAvailable; @@ -496,25 +497,14 @@ class ViewHolder extends RecyclerView.ViewHolder { void bind(TransferMethodSelectionItem selectionItem) { mTitle.setText(selectionItem.getTransferMethodName()); mIcon.setText(getStringFontIcon(mIcon.getContext(), selectionItem.getTransferMethodType())); - String formattedFee = FeeFormatter.getFormattedFee(mTitle.getContext(), selectionItem.getFees()); - - if (isFeeAvailable(selectionItem.getFees()) - && isProcessingTimeAvailable(selectionItem.getProcessingTime())) { - mDescriptionFeesAndProcessingTime.setVisibility(View.VISIBLE); - mDescriptionFeesAndProcessingTime.setText(mDescriptionFeesAndProcessingTime.getContext() - .getString(R.string.feeAndProcessingTimeInformation, formattedFee, - selectionItem.getProcessingTime().getValue())); - } else if (isFeeAvailable(selectionItem.getFees()) + if (!isFeeAvailable(selectionItem.getFees()) && !isProcessingTimeAvailable(selectionItem.getProcessingTime())) { - mDescriptionFeesAndProcessingTime.setVisibility(View.VISIBLE); - mDescriptionFeesAndProcessingTime.setText(mDescriptionFeesAndProcessingTime.getContext() - .getString(R.string.feeInformation, formattedFee)); - } else if (isProcessingTimeAvailable(selectionItem.getProcessingTime()) - && !isFeeAvailable(selectionItem.getFees())) { - mDescriptionFeesAndProcessingTime.setVisibility(View.VISIBLE); - mDescriptionFeesAndProcessingTime.setText(selectionItem.getProcessingTime().getValue()); - } else { mDescriptionFeesAndProcessingTime.setVisibility(View.INVISIBLE); + } else { + mDescriptionFeesAndProcessingTime.setVisibility(View.VISIBLE); + mDescriptionFeesAndProcessingTime.setText( + getFormattedFeeAndProcessingTime(mDescriptionFeesAndProcessingTime.getContext(), + selectionItem.getFees(), selectionItem.getProcessingTime())); } itemView.setOnClickListener(new OneClickListener() { diff --git a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/UpdateTransferMethodFragment.java b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/UpdateTransferMethodFragment.java index 49ad03ac6..bba83ac33 100644 --- a/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/UpdateTransferMethodFragment.java +++ b/transfermethodui/src/main/java/com/hyperwallet/android/ui/transfermethod/view/UpdateTransferMethodFragment.java @@ -9,6 +9,7 @@ import static com.hyperwallet.android.model.transfermethod.TransferMethod.TransferMethodTypes.WIRE_ACCOUNT; import static com.hyperwallet.android.ui.common.intent.HyperwalletIntent.EXTRA_TRANSFER_METHOD_UPDATED; import static com.hyperwallet.android.ui.transfermethod.TransferMethodLocalBroadcast.TransferMethodLocalBroadcastAction.ACTION_HYPERWALLET_TRANSFER_METHOD_UPDATED; +import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.getFormattedFeeAndProcessingTime; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isFeeAvailable; import static com.hyperwallet.android.ui.transfermethod.view.FeeFormatter.isProcessingTimeAvailable; @@ -409,23 +410,12 @@ public void showTransactionInformation(@NonNull List fees, View header = getView().findViewById(R.id.update_transfer_method_static_container_header); View container = getView().findViewById(R.id.update_transfer_method_static_container); TextView feeAndProcessingTime = getView().findViewById(R.id.update_transfer_method_information); - - if (isFeeAvailable(fees) && isProcessingTimeAvailable(processingTime)) { - String formattedFee = FeeFormatter.getFormattedFee(header.getContext(), fees); - feeAndProcessingTime.setVisibility(View.VISIBLE); - feeAndProcessingTime.setText( - feeAndProcessingTime.getContext().getString(R.string.feeAndProcessingTimeInformation, formattedFee, - processingTime.getValue())); - } else if (isFeeAvailable(fees) && !isProcessingTimeAvailable(processingTime)) { - String formattedFee = FeeFormatter.getFormattedFee(header.getContext(), fees); + if (!isFeeAvailable(fees) && !isProcessingTimeAvailable(processingTime)) { + feeAndProcessingTime.setVisibility(View.GONE); + } else { feeAndProcessingTime.setVisibility(View.VISIBLE); feeAndProcessingTime.setText( - feeAndProcessingTime.getContext().getString(R.string.feeInformation, formattedFee)); - } else if (isProcessingTimeAvailable(processingTime) && !isFeeAvailable(fees)) { - feeAndProcessingTime.setVisibility(View.VISIBLE); - feeAndProcessingTime.setText(processingTime.getValue()); - } else { - feeAndProcessingTime.setVisibility(View.GONE); + getFormattedFeeAndProcessingTime(feeAndProcessingTime.getContext(), fees, processingTime)); } if (feeAndProcessingTime.getVisibility() == View.VISIBLE) { diff --git a/transfermethodui/src/main/res/values-bg/strings.xml b/transfermethodui/src/main/res/values-bg/strings.xml index f5a46d28c..128f2332f 100644 --- a/transfermethodui/src/main/res/values-bg/strings.xml +++ b/transfermethodui/src/main/res/values-bg/strings.xml @@ -25,8 +25,8 @@ Изберете метод за трансфер по подразбиране ММ/ГГ - %s такса \u2022 %s %s такса + Без такса Добавете метод за трансфер, за да започнете. diff --git a/transfermethodui/src/main/res/values-cs/strings.xml b/transfermethodui/src/main/res/values-cs/strings.xml index 243356557..0b4d243de 100644 --- a/transfermethodui/src/main/res/values-cs/strings.xml +++ b/transfermethodui/src/main/res/values-cs/strings.xml @@ -25,8 +25,8 @@ Vyberte výchozí způsob převodu MM/RR - %s poplatek \u2022 %s %s poplatek + Bez poplatku Chcete-li začít, přidejte způsob převodu. diff --git a/transfermethodui/src/main/res/values-de/strings.xml b/transfermethodui/src/main/res/values-de/strings.xml index e550f1cf1..56c3e5710 100644 --- a/transfermethodui/src/main/res/values-de/strings.xml +++ b/transfermethodui/src/main/res/values-de/strings.xml @@ -25,8 +25,8 @@ Wählen Sie eine Standard-Überweisungsmethode MM/JJ - %s Gebühr \u2022 %s %s Gebühr + Keine Gebühr Fügen Sie eine Überweisungsmethode hinzu, um zu beginnen. diff --git a/transfermethodui/src/main/res/values-el/strings.xml b/transfermethodui/src/main/res/values-el/strings.xml index 5ff2937d1..2066bb7e6 100644 --- a/transfermethodui/src/main/res/values-el/strings.xml +++ b/transfermethodui/src/main/res/values-el/strings.xml @@ -25,8 +25,8 @@ Επιλέξτε έναν προεπιλεγμένο τρόπο μεταφοράς ΜΜ/ΈΈ - %sΤέλος \u2022 %s %sΤέλος + Δωρεάν Ξεκινήστε προσθέτοντας έναν τρόπο μεταφοράς. diff --git a/transfermethodui/src/main/res/values-es/strings.xml b/transfermethodui/src/main/res/values-es/strings.xml index ba89b105d..90f1c403c 100644 --- a/transfermethodui/src/main/res/values-es/strings.xml +++ b/transfermethodui/src/main/res/values-es/strings.xml @@ -25,8 +25,8 @@ Seleccione un método de transferencia predeterminado MM/AA - %s tarifa \u2022 %s %s tarifa + Sin comisiones Añada un método de transferencia para empezar. diff --git a/transfermethodui/src/main/res/values-fi/strings.xml b/transfermethodui/src/main/res/values-fi/strings.xml index 25fc6c328..29763cd89 100644 --- a/transfermethodui/src/main/res/values-fi/strings.xml +++ b/transfermethodui/src/main/res/values-fi/strings.xml @@ -25,8 +25,8 @@ Valitse oletusarvoinen siirtomenetelmä KK/VV - %s maksu \u2022 %s %s maksu + Ei maksu Aloita lisäämällä siirtomenetelmä. diff --git a/transfermethodui/src/main/res/values-fr/strings.xml b/transfermethodui/src/main/res/values-fr/strings.xml index 7c6f3fc0d..3e8823cca 100644 --- a/transfermethodui/src/main/res/values-fr/strings.xml +++ b/transfermethodui/src/main/res/values-fr/strings.xml @@ -25,8 +25,8 @@ Sélectionnez une méthode de transfert par défaut MM/AA - %s frais \u2022 %s %s frais + Pas de frais Ajouter une méthode de transfert pour commencer. diff --git a/transfermethodui/src/main/res/values-hr/strings.xml b/transfermethodui/src/main/res/values-hr/strings.xml index 810c2233f..c72ec615f 100644 --- a/transfermethodui/src/main/res/values-hr/strings.xml +++ b/transfermethodui/src/main/res/values-hr/strings.xml @@ -25,8 +25,8 @@ Izaberite zadani način prijenosa MM/GG - %s naknada \u2022 %s %s naknada + Bez naknade Dodajte način prijenosa da biste započeli. diff --git a/transfermethodui/src/main/res/values-hu/strings.xml b/transfermethodui/src/main/res/values-hu/strings.xml index c8f72a443..7b089f8fb 100644 --- a/transfermethodui/src/main/res/values-hu/strings.xml +++ b/transfermethodui/src/main/res/values-hu/strings.xml @@ -25,8 +25,8 @@ Alapértelmezett átutalási mód kiválasztása HH/ÉÉ - %s díj \u2022 %s %s díj + Nincs díj A kezdéshez adjon hozzá egy átutalási módot. diff --git a/transfermethodui/src/main/res/values-in/strings.xml b/transfermethodui/src/main/res/values-in/strings.xml index 279ee62e2..95a137547 100644 --- a/transfermethodui/src/main/res/values-in/strings.xml +++ b/transfermethodui/src/main/res/values-in/strings.xml @@ -25,8 +25,8 @@ Pilih metode transfer standar BB/TT - Biaya %s \u2022 %s Biaya %s + Tidak Ada Biaya Tambahkan metode transfer untuk memulai. diff --git a/transfermethodui/src/main/res/values-is/strings.xml b/transfermethodui/src/main/res/values-is/strings.xml index 5fb234698..4834449fc 100644 --- a/transfermethodui/src/main/res/values-is/strings.xml +++ b/transfermethodui/src/main/res/values-is/strings.xml @@ -25,8 +25,8 @@ Veldu sjálfvalda millifærsluaðferð MM/ÁÁ - %s gjald \u2022 %s %s gjald + Ekkert gjald Bæta við millifærsluaðferð til að byrja. diff --git a/transfermethodui/src/main/res/values-it/strings.xml b/transfermethodui/src/main/res/values-it/strings.xml index 0525a14fb..e17ef501a 100644 --- a/transfermethodui/src/main/res/values-it/strings.xml +++ b/transfermethodui/src/main/res/values-it/strings.xml @@ -25,8 +25,8 @@ Seleziona un metodo di trasferimento predefinito MM/AA - %sCommissione \u2022 %s %sCommissione + Nessuna commissione Aggiungi un metodo di trasferimento per iniziare. diff --git a/transfermethodui/src/main/res/values-ja/strings.xml b/transfermethodui/src/main/res/values-ja/strings.xml index 79fd90a36..a17a7d601 100644 --- a/transfermethodui/src/main/res/values-ja/strings.xml +++ b/transfermethodui/src/main/res/values-ja/strings.xml @@ -25,8 +25,8 @@ デフォルトの送金方法を選択 MM/YY - %s手数料 \u2022 %s %s手数料 + 手数料なし 始めるには、送金方法を追加します。 diff --git a/transfermethodui/src/main/res/values-ko/strings.xml b/transfermethodui/src/main/res/values-ko/strings.xml index be3cafb31..6576b5056 100644 --- a/transfermethodui/src/main/res/values-ko/strings.xml +++ b/transfermethodui/src/main/res/values-ko/strings.xml @@ -25,8 +25,8 @@ 기본 이체 방법 선택 월월/년년 - %s 수수료 \u2022 %s %s 수수료 + 수수료 없음 시작하려면 이체 방법을 추가하십시오. diff --git a/transfermethodui/src/main/res/values-lv/strings.xml b/transfermethodui/src/main/res/values-lv/strings.xml index 5452fdb04..b508abe5f 100644 --- a/transfermethodui/src/main/res/values-lv/strings.xml +++ b/transfermethodui/src/main/res/values-lv/strings.xml @@ -25,8 +25,8 @@ Atlasiet noklusēto pārskaitījuma veidu MM/GG - %s komisijas maksa \u2022 %s %s komisijas maksa + Bez maksa Pievienojiet pārskaitījuma veidu, lai uzsāktu darījumu. diff --git a/transfermethodui/src/main/res/values-mk/strings.xml b/transfermethodui/src/main/res/values-mk/strings.xml index 03c6262c4..06e05988a 100644 --- a/transfermethodui/src/main/res/values-mk/strings.xml +++ b/transfermethodui/src/main/res/values-mk/strings.xml @@ -25,8 +25,8 @@ Избери стандарден метод на трансфер ММ/ГГ - %s цена \u2022 %s %s цена + Без провизија Додади метод на трансфер за да почнеш. diff --git a/transfermethodui/src/main/res/values-mn/strings.xml b/transfermethodui/src/main/res/values-mn/strings.xml index 6585a2e0a..826c892c0 100644 --- a/transfermethodui/src/main/res/values-mn/strings.xml +++ b/transfermethodui/src/main/res/values-mn/strings.xml @@ -25,8 +25,8 @@ Анхдагч шилжүүлгийн аргыг сонгоно уу СС/ОО - %s хураамж \u2022 %s %s хураамж + Хураамжгүй Эхлэхийн тулд шилжүүлгийн аргыг нэмнэ үү. diff --git a/transfermethodui/src/main/res/values-ms/strings.xml b/transfermethodui/src/main/res/values-ms/strings.xml index 034b9a8aa..e89526e5a 100644 --- a/transfermethodui/src/main/res/values-ms/strings.xml +++ b/transfermethodui/src/main/res/values-ms/strings.xml @@ -25,8 +25,8 @@ Pilih kaedah pemindahan lalai BB/TT - %s yuran \u2022 %s %s yuran + Tiada Yuran Tambah kaedah pemindahan untuk memulakan. diff --git a/transfermethodui/src/main/res/values-nl/strings.xml b/transfermethodui/src/main/res/values-nl/strings.xml index b2e5814f0..ba1dc6bba 100644 --- a/transfermethodui/src/main/res/values-nl/strings.xml +++ b/transfermethodui/src/main/res/values-nl/strings.xml @@ -24,8 +24,8 @@ Selecteer een standaard overboekingsmethode MM/JJ - %s kosten \u2022 %s %s kosten + Geen kosten Voeg een overboekingsmethode toe om te beginnen. diff --git a/transfermethodui/src/main/res/values-pl/strings.xml b/transfermethodui/src/main/res/values-pl/strings.xml index 06ea64c9d..dba3bc1d2 100644 --- a/transfermethodui/src/main/res/values-pl/strings.xml +++ b/transfermethodui/src/main/res/values-pl/strings.xml @@ -25,8 +25,8 @@ Wybierz domyślną metodę przelewu MM/RR - %s opłata \u2022 %s %s opłata + Brak opłat Dodaj metodę przelewu, aby zacząć. diff --git a/transfermethodui/src/main/res/values-pt-rPT/strings.xml b/transfermethodui/src/main/res/values-pt-rPT/strings.xml index ce0e6219c..83df9e3f5 100644 --- a/transfermethodui/src/main/res/values-pt-rPT/strings.xml +++ b/transfermethodui/src/main/res/values-pt-rPT/strings.xml @@ -25,8 +25,8 @@ Selecione um método de transferência padrão MM/AA - %s taxa \u2022 %s %s taxa + Sem taxa Adicione um método de transferência para começar. diff --git a/transfermethodui/src/main/res/values-pt/strings.xml b/transfermethodui/src/main/res/values-pt/strings.xml index aced1c1fd..cab92b951 100644 --- a/transfermethodui/src/main/res/values-pt/strings.xml +++ b/transfermethodui/src/main/res/values-pt/strings.xml @@ -25,8 +25,8 @@ Selecione um método de transferência padrão MM/AA - %staxa \u2022 %s %s taxa + Sem taxa Adicione um método de transferência para começar. diff --git a/transfermethodui/src/main/res/values-ro/strings.xml b/transfermethodui/src/main/res/values-ro/strings.xml index 7160f117b..342c20d4a 100644 --- a/transfermethodui/src/main/res/values-ro/strings.xml +++ b/transfermethodui/src/main/res/values-ro/strings.xml @@ -25,8 +25,8 @@ Selectați o metodă implicită de transfer LL/AA - %s comision \u2022 %s %s comision + Nicio taxă Adăugați o metodă de transfer pentru a începe. diff --git a/transfermethodui/src/main/res/values-ru/strings.xml b/transfermethodui/src/main/res/values-ru/strings.xml index 787a1ad28..4afdaa6af 100644 --- a/transfermethodui/src/main/res/values-ru/strings.xml +++ b/transfermethodui/src/main/res/values-ru/strings.xml @@ -24,8 +24,8 @@ Выбрать способ перевода по умолчанию ММ/ГГ - %s сбор \u2022 %s %s сбор + Комиссия отсутствует Чтобы начать, добавьте способ перевода. diff --git a/transfermethodui/src/main/res/values-sk/strings.xml b/transfermethodui/src/main/res/values-sk/strings.xml index 0a1282c9c..f9850fdb1 100644 --- a/transfermethodui/src/main/res/values-sk/strings.xml +++ b/transfermethodui/src/main/res/values-sk/strings.xml @@ -25,8 +25,8 @@ Vybrať predvolený spôsob prevodu MM/RR - %s poplatok \u2022 %s Poplatok %s + Bez poplatku Pridajte spôsob prevodu, aby ste mohli začať. diff --git a/transfermethodui/src/main/res/values-sl/strings.xml b/transfermethodui/src/main/res/values-sl/strings.xml index 3372831b4..cda0c54b5 100644 --- a/transfermethodui/src/main/res/values-sl/strings.xml +++ b/transfermethodui/src/main/res/values-sl/strings.xml @@ -25,8 +25,8 @@ Izberi privzeti način prenosa MM/LL - %sPristojbina \u2022 %s %s pristojbina + Brez pristojbine Za začetek dodajte način prenosa. diff --git a/transfermethodui/src/main/res/values-sv/strings.xml b/transfermethodui/src/main/res/values-sv/strings.xml index 632205707..7814da3ab 100644 --- a/transfermethodui/src/main/res/values-sv/strings.xml +++ b/transfermethodui/src/main/res/values-sv/strings.xml @@ -25,8 +25,8 @@ Välj en standardöverföringsmetod MM/ÅÅ - %s avgift \u2022 %s %s avgift + Ingen avgift Lägg till en överföringsmetod för att komma igång. diff --git a/transfermethodui/src/main/res/values-th/strings.xml b/transfermethodui/src/main/res/values-th/strings.xml index 7ebb3c941..6011271d7 100644 --- a/transfermethodui/src/main/res/values-th/strings.xml +++ b/transfermethodui/src/main/res/values-th/strings.xml @@ -25,8 +25,8 @@ เลือกวิธีการโอนเงินเริ่มต้น ดด/ปป - ค่าธรรมเนียม %s \u2022 %s ค่าธรรมเนียม %s + ไม่มีค่าธรรมเนียม เพิ่มวิธีการโอนเงินเพื่อเริ่มต้นใช้งาน diff --git a/transfermethodui/src/main/res/values-tr/strings.xml b/transfermethodui/src/main/res/values-tr/strings.xml index 295c3fdae..ba164b4a5 100644 --- a/transfermethodui/src/main/res/values-tr/strings.xml +++ b/transfermethodui/src/main/res/values-tr/strings.xml @@ -25,8 +25,8 @@ Varsayılan bir aktarım yöntemi seç AA/YY - %s ücret \u2022 %s %s ücret + Ücret Yok Başlamak için bir aktarım yöntemi ekle. diff --git a/transfermethodui/src/main/res/values-uk/strings.xml b/transfermethodui/src/main/res/values-uk/strings.xml index 0cd8df2ad..11697c689 100644 --- a/transfermethodui/src/main/res/values-uk/strings.xml +++ b/transfermethodui/src/main/res/values-uk/strings.xml @@ -25,8 +25,8 @@ Вибрати типовий спосіб переказу ММ/РР - %s комісія \u2022 %s %s комісія + Комісія не стягується Щоб розпочати, додайте спосіб переказу. diff --git a/transfermethodui/src/main/res/values-vi/strings.xml b/transfermethodui/src/main/res/values-vi/strings.xml index 38d219cbd..b578d3082 100644 --- a/transfermethodui/src/main/res/values-vi/strings.xml +++ b/transfermethodui/src/main/res/values-vi/strings.xml @@ -24,8 +24,8 @@ Chọn phương thức chuyển mặc định MM/YY - %s phí \u2022 %s %s phí + Miễn phí Thêm phương thức chuyển tiền để bắt đầu. diff --git a/transfermethodui/src/main/res/values-zh-rCN/strings.xml b/transfermethodui/src/main/res/values-zh-rCN/strings.xml index 4471d6385..4687f00cc 100644 --- a/transfermethodui/src/main/res/values-zh-rCN/strings.xml +++ b/transfermethodui/src/main/res/values-zh-rCN/strings.xml @@ -25,8 +25,8 @@ 选择默认转账方式 MM/YY - %s 费用 \u2022 %s %s 费用 + 不收费 添加转账方式以开始。 diff --git a/transfermethodui/src/main/res/values-zh-rTW/strings.xml b/transfermethodui/src/main/res/values-zh-rTW/strings.xml index d265f84c6..4b447addf 100644 --- a/transfermethodui/src/main/res/values-zh-rTW/strings.xml +++ b/transfermethodui/src/main/res/values-zh-rTW/strings.xml @@ -25,8 +25,8 @@ 選擇預設轉帳方式 月/年 - %s手續費\u2022%s %s手續費 + 免手續費 新增轉帳方式以開始使用。 diff --git a/transfermethodui/src/main/res/values-zh/strings.xml b/transfermethodui/src/main/res/values-zh/strings.xml index e8f7aed09..4b447addf 100644 --- a/transfermethodui/src/main/res/values-zh/strings.xml +++ b/transfermethodui/src/main/res/values-zh/strings.xml @@ -25,8 +25,8 @@ 選擇預設轉帳方式 月/年 - %s手續費\u2022 %s %s手續費 + 免手續費 新增轉帳方式以開始使用。 diff --git a/transfermethodui/src/main/res/values/strings.xml b/transfermethodui/src/main/res/values/strings.xml index 406ef6ee6..de9d2b6c5 100644 --- a/transfermethodui/src/main/res/values/strings.xml +++ b/transfermethodui/src/main/res/values/strings.xml @@ -26,8 +26,9 @@ Select a default transfer method MM/YY - %s fee \u2022 %s %s fee + \u0020\u2022 %s + No fee Add a transfer method to get started. diff --git a/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/FeeFormatterTest.java b/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/FeeFormatterTest.java index 7166174e6..27554c383 100644 --- a/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/FeeFormatterTest.java +++ b/transfermethodui/src/test/java/com/hyperwallet/android/ui/transfermethod/FeeFormatterTest.java @@ -1,7 +1,9 @@ package com.hyperwallet.android.ui.transfermethod; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.any; import static org.hamcrest.Matchers.is; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -9,6 +11,7 @@ import android.content.res.Resources; import com.hyperwallet.android.model.graphql.Fee; +import com.hyperwallet.android.model.graphql.ProcessingTime; import com.hyperwallet.android.ui.R; import com.hyperwallet.android.ui.testutils.rule.HyperwalletExternalResourceManager; import com.hyperwallet.android.ui.transfermethod.view.FeeFormatter; @@ -27,6 +30,7 @@ import org.robolectric.RobolectricTestRunner; import java.util.Arrays; +import java.util.Collections; import java.util.List; @RunWith(RobolectricTestRunner.class) @@ -46,6 +50,8 @@ public class FeeFormatterTest { private Resources resources; private Fee mFlatFee; private JSONObject mJSONObject; + @Mock + private FeeFormatter mFeeFormatter; @Before public void setUp() throws JSONException { @@ -148,4 +154,150 @@ public void testGetFormattedFee_returnsPercentAndFlatFormattedFeeWithMinOnly() { assertThat(resourceIdCaptorValue, is(R.string.fee_mix_only_min_formatter)); assertThat(argumentList.size(), is(4)); } + + @Test + public void testGetFormattedFee_returnsFlatNoFee() { + Fee flatFee = new Fee(mJSONObject.optJSONObject("FEE_NINE").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(flatFee)); + verify(resources).getString(resourceIdCaptor.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + assertThat(resourceIdCaptorValue, is(R.string.noFee)); + } + + @Test + public void testGetFormattedFee_returnsPercentNoFee() { + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_EIGHT").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(percentFee)); + verify(resources).getString(resourceIdCaptor.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + assertThat(resourceIdCaptorValue, is(R.string.noFee)); + } + + @Test + public void testGetFormattedFee_returnsMixedNoFee() { + Fee flatFee = new Fee(mJSONObject.optJSONObject("FEE_EIGHT").optJSONArray("nodes").optJSONObject(0)); + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_NINE").optJSONArray("nodes").optJSONObject(0)); + + FeeFormatter.getFormattedFee(context, Arrays.asList(flatFee,percentFee)); + verify(resources).getString(resourceIdCaptor.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + assertThat(resourceIdCaptorValue, is(R.string.noFee)); + } + + @Test + public void testGetFormattedFee_returnsFlatFee() { + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_EIGHT").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(mFlatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_flat_formatter)); + assertThat(argumentList.size(), is(2)); + } + + @Test + public void testGetFormattedFee_returnsFlatFeeWithMinAndMax() { + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_TEN").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(mFlatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_flat_formatter)); + assertThat(argumentList.size(), is(2)); + } + + @Test + public void testGetFormattedFee_returnsFlatFeeWithMaxOnly() { + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_TWELVE").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(mFlatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_flat_formatter)); + assertThat(argumentList.size(), is(2)); + } + + @Test + public void testGetFormattedFee_returnsFlatFeeWithMinOnly() { + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_ELEVEN").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(mFlatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_flat_formatter)); + assertThat(argumentList.size(), is(2)); + } + + @Test + public void testGetFormattedFee_returnsPercentFeeWithMinAndMax() { + Fee flatFee = new Fee(mJSONObject.optJSONObject("FEE_NINE").optJSONArray("nodes").optJSONObject(0)); + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_TWO").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(flatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_percent_formatter)); + assertThat(argumentList.size(), is(4)); + } + + @Test + public void testGetFormattedFee_returnsPercentFeeWithMinOnly() { + Fee flatFee = new Fee(mJSONObject.optJSONObject("FEE_NINE").optJSONArray("nodes").optJSONObject(0)); + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_THREE").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(flatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_percent_only_min_formatter)); + assertThat(argumentList.size(), is(3)); + } + + @Test + public void testGetFormattedFee_returnsPercentFeeWithMaxOnly() { + Fee flatFee = new Fee(mJSONObject.optJSONObject("FEE_NINE").optJSONArray("nodes").optJSONObject(0)); + Fee percentFee = new Fee(mJSONObject.optJSONObject("FEE_FOUR").optJSONArray("nodes").optJSONObject(0)); + FeeFormatter.getFormattedFee(context, Arrays.asList(flatFee,percentFee)); + + verify(resources).getString(resourceIdCaptor.capture(), formatterArgumentCapture.capture()); + int resourceIdCaptorValue = resourceIdCaptor.getValue(); + List argumentList = formatterArgumentCapture.getAllValues(); + assertThat(resourceIdCaptorValue, is(R.string.fee_percent_only_max_formatter)); + assertThat(argumentList.size(), is(3)); + } + + @Test + public void testGetFormattedFeeAndProcessingTime_returnsFormattedFeeAndProcessingTimeWithNoFeeString() throws JSONException { + + JSONObject mJSONObject = new JSONObject(externalResourceManager.getResourceContent("processing_time_information.json")); + ProcessingTime mProcessingTime = new ProcessingTime(mJSONObject.getJSONObject("PROCESSING_TIME_ONE").getJSONArray("nodes").optJSONObject(0)); + + when(FeeFormatter.getFormattedFee(context,Arrays.asList(mFlatFee))).thenReturn("No fee"); + when(context.getResources().getString(R.string.noFee)).thenReturn("No fee"); + when(context.getResources().getString(R.string.fee_flat_formatter)).thenReturn("$2.00"); + when(context.getResources().getString(R.string.processingTimeInformation,"1-2 Business days")).thenReturn(" \u2022 1-2 Business days"); + + String formattedString = FeeFormatter.getFormattedFeeAndProcessingTime(context,Arrays.asList(mFlatFee),mProcessingTime); + assertThat(formattedString , is("No fee \u2022 1-2 Business days")); + } + + @Test + public void testGetFormattedFeeAndProcessingTime_returnsFormattedFeeAndProcessingTimeWithFlatFeeString() throws JSONException { + + JSONObject mJSONObject = new JSONObject(externalResourceManager.getResourceContent("processing_time_information.json")); + ProcessingTime mProcessingTime = new ProcessingTime(mJSONObject.getJSONObject("PROCESSING_TIME_ONE").getJSONArray("nodes").optJSONObject(0)); + + when(FeeFormatter.getFormattedFee(context,Arrays.asList(mFlatFee))).thenReturn("$3.00 fee"); + when(context.getResources().getString(R.string.noFee)).thenReturn("No fee"); + when(context.getResources().getString(R.string.feeInformation,"$3.00 fee")).thenReturn("$3.00 fee"); + when(context.getResources().getString(R.string.processingTimeInformation,"1-2 Business days")).thenReturn(" \u2022 1-2 Business days"); + + String formattedString = FeeFormatter.getFormattedFeeAndProcessingTime(context,Arrays.asList(mFlatFee),mProcessingTime); + assertThat(formattedString , is("$3.00 fee \u2022 1-2 Business days")); + } } \ No newline at end of file diff --git a/transfermethodui/src/test/resources/fee_information.json b/transfermethodui/src/test/resources/fee_information.json index 01ceedeef..959fec6ca 100644 --- a/transfermethodui/src/test/resources/fee_information.json +++ b/transfermethodui/src/test/resources/fee_information.json @@ -73,5 +73,58 @@ "maximum": "" } ] + }, + "FEE_EIGHT": { + "nodes": [ + { + "currency": "USD", + "feeRateType": "PERCENT", + "value": "0.00", + "minimum": "10.00", + "maximum": "" + } + ] + }, + "FEE_NINE": { + "nodes": [ + { + "currency": "USD", + "value": "0.00", + "feeRateType": "FLAT" + } + ] + }, + "FEE_TEN": { + "nodes": [ + { + "currency": "USD", + "feeRateType": "PERCENT", + "value": "0.00", + "minimum": "10.00", + "maximum": "20.00" + } + ] + }, + "FEE_ELEVEN": { + "nodes": [ + { + "currency": "USD", + "feeRateType": "PERCENT", + "value": "0.00", + "minimum": "10.00", + "maximum": "" + } + ] + }, + "FEE_TWELVE": { + "nodes": [ + { + "currency": "USD", + "feeRateType": "PERCENT", + "value": "0.00", + "minimum": "", + "maximum": "20.00" + } + ] } } \ No newline at end of file diff --git a/transfermethodui/src/test/resources/processing_time_information.json b/transfermethodui/src/test/resources/processing_time_information.json new file mode 100644 index 000000000..49dd2ff54 --- /dev/null +++ b/transfermethodui/src/test/resources/processing_time_information.json @@ -0,0 +1,22 @@ +{ + "PROCESSING_TIME_ONE": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + }, + "PROCESSING_TIME_TWO": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CN", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT" + } + ] + } +} \ No newline at end of file diff --git a/transfermethodui/src/test/resources/successful_tmc_keys_mixedfee_response.json b/transfermethodui/src/test/resources/successful_tmc_keys_mixedfee_response.json new file mode 100644 index 000000000..b3c8df6d9 --- /dev/null +++ b/transfermethodui/src/test/resources/successful_tmc_keys_mixedfee_response.json @@ -0,0 +1,565 @@ +{ + "data": { + "countries": { + "nodes": [ + { + "code": "CA", + "name": "Canada", + "currencies": { + "nodes": [ + { + "code": "CAD", + "name": "Canadian Dollar", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "CA", + "currency": "CAD", + "transferMethodType": "BANK_ACCOUNT", + "value": "2.20", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CA", + "currency": "CAD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + }, + { + "code": "PAYPAL_ACCOUNT", + "name": "PayPal", + "fees": { + "nodes": [ + { + "country": "CA", + "currency": "CAD", + "transferMethodType": "PAYPAL_ACCOUNT", + "value": "0.25", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CA", + "currency": "CAD", + "transferMethodType": "PAYPAL_ACCOUNT" + } + ] + } + } + ] + } + }, + { + "code": "USD", + "name": "United States Dollar", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "CA", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT", + "value": "2.00", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CA", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + }, + { + "code": "HR", + "name": "Croatia", + "currencies": { + "nodes": [ + { + "code": "EUR", + "name": "Euro", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "HR", + "currency": "EUR", + "transferMethodType": "BANK_ACCOUNT", + "value": "1.50", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "2-3 Business days", + "country": "HR", + "currency": "EUR", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + }, + { + "code": "HRK", + "name": "Croatian Kuna", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "HR", + "currency": "HRK", + "transferMethodType": "BANK_ACCOUNT", + "value": "1.50", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "HR", + "currency": "HRK", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + }, + { + "code": "MX", + "name": "Mexico", + "currencies": { + "nodes": [ + { + "code": "MXN", + "name": "Mexican Peso", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "MX", + "currency": "MXN", + "transferMethodType": "BANK_ACCOUNT", + "value": "26.15", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "MX", + "currency": "MXN", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + }, + { + "code": "GB", + "name": "United Kingdom", + "currencies": { + "nodes": [ + { + "code": "EUR", + "name": "Euro", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "GB", + "currency": "EUR", + "transferMethodType": "BANK_ACCOUNT", + "value": "1.50", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "2-4 Business days", + "country": "GB", + "currency": "EUR", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + }, + { + "code": "GBP", + "name": "British Pound", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "GB", + "currency": "GBP", + "transferMethodType": "BANK_ACCOUNT", + "value": "1.20", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "GB", + "currency": "GBP", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + }, + { + "code": "US", + "name": "United States", + "currencies": { + "nodes": [ + { + "code": "USD", + "name": "United States Dollar", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT", + "value": "2.00", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "US", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + }, + { + "code": "BANK_CARD", + "name": "Debit Card", + "fees": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "BANK_CARD", + "value": "1.75", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "US", + "currency": "USD", + "transferMethodType": "BANK_CARD" + } + ] + } + }, + { + "code": "WIRE_ACCOUNT", + "name": "Wire Transfer", + "fees": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT", + "value": "20.00", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-3 Business days", + "country": "US", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT" + } + ] + } + }, + { + "code": "PAYPAL_ACCOUNT", + "name": "PayPal", + "fees": { + "nodes": [ + { + "country": "US", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT", + "value": "0.25", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "US", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + }, + { + "code": "CN", + "name": "CHINA", + "currencies": { + "nodes": [ + { + "code": "USD", + "name": "USD", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT", + "value": "0.0", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + }, + { + "code": "BANK_CARD", + "name": "Debit Card", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_CARD", + "value": "0.00", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_CARD" + } + ] + } + }, + + { + "code": "WIRE_ACCOUNT", + "name": "Wire Transfer", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT", + "value": "0.000", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-3 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT" + } + ] + } + }, + { + "code": "PAYPAL_ACCOUNT", + "name": "PayPal", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT", + "value": "0.00", + "feeRateType": "PERCENT", + "minimum": "4.00", + "maximum": "10.00" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CN", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT" + } + ] + } + }, + { + "code": "VENMO_ACCOUNT", + "name": "VENMO", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "VENMO_ACCOUNT", + "value": "5.00", + "feeRateType": "FLAT" + }, + { + "country": "CN", + "currency": "USD", + "transferMethodType": "VENMO_ACCOUNT", + "value": "4.50", + "feeRateType": "PERCENT", + "minimum": "4.00", + "maximum": "10.00" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "VENMO_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/transfermethodui/src/test/resources/successful_tmc_keys_response.json b/transfermethodui/src/test/resources/successful_tmc_keys_response.json index dfe07fea4..f14704117 100644 --- a/transfermethodui/src/test/resources/successful_tmc_keys_response.json +++ b/transfermethodui/src/test/resources/successful_tmc_keys_response.json @@ -405,6 +405,125 @@ } ] } + }, + { + "code": "CN", + "name": "CHINA", + "currencies": { + "nodes": [ + { + "code": "USD", + "name": "USD", + "transferMethodTypes": { + "nodes": [ + { + "code": "BANK_ACCOUNT", + "name": "Bank Account", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT", + "value": "0.0", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-2 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_ACCOUNT" + } + ] + } + }, + { + "code": "BANK_CARD", + "name": "Debit Card", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_CARD", + "value": "0.00", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CN", + "currency": "USD", + "transferMethodType": "BANK_CARD" + } + ] + } + }, + + { + "code": "WIRE_ACCOUNT", + "name": "Wire Transfer", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT", + "value": "0.000", + "feeRateType": "FLAT" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "1-3 Business days", + "country": "CN", + "currency": "USD", + "transferMethodType": "WIRE_ACCOUNT" + } + ] + } + }, + { + "code": "PAYPAL_ACCOUNT", + "name": "PayPal", + "fees": { + "nodes": [ + { + "country": "CN", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT", + "value": "0.00", + "feeRateType": "PERCENT", + "minimum": "4.00", + "maximum": "10.00" + } + ] + }, + "processingTimes": { + "nodes": [ + { + "value": "IMMEDIATE", + "country": "CN", + "currency": "USD", + "transferMethodType": "PAYPAL_ACCOUNT" + } + ] + } + } + ] + } + } + ] + } } ] }