@Test public void matchesCurrencyPattern_whenInvalid_returnsFalse() { assertFalse(matchesCurrencyPatternOrEmpty(".99")); assertFalse(matchesCurrencyPatternOrEmpty("0.123")); assertFalse(matchesCurrencyPatternOrEmpty("1.")); }
public static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString) { if (TextUtils.isEmpty(priceString)) { return true; } Pattern pattern = Pattern.compile("^-?[0-9]+(\\.[0-9][0-9])?"); return pattern.matcher(priceString).matches(); }
PaymentUtils { public static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString) { if (TextUtils.isEmpty(priceString)) { return true; } Pattern pattern = Pattern.compile("^-?[0-9]+(\\.[0-9][0-9])?"); return pattern.matcher(priceString).matches(); } }
PaymentUtils { public static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString) { if (TextUtils.isEmpty(priceString)) { return true; } Pattern pattern = Pattern.compile("^-?[0-9]+(\\.[0-9][0-9])?"); return pattern.matcher(priceString).matches(); }  }
PaymentUtils { public static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString) { if (TextUtils.isEmpty(priceString)) { return true; } Pattern pattern = Pattern.compile("^-?[0-9]+(\\.[0-9][0-9])?"); return pattern.matcher(priceString).matches(); }  static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString); static boolean matchesQuantityPatternOrEmpty(@Nullable String quantityString); @NonNull static List<CartError> validateLineItemList(
            List<LineItem> lineItems,
            @NonNull String currencyCode); static CartError searchLineItemForErrors(LineItem lineItem); @NonNull static String getPriceString(long price); @NonNull static List<CartError> removeErrorType(
            @NonNull List<CartError> errors,
            @NonNull @CartError.CartErrorType String errorType); @NonNull static String getPriceString(Long price, @NonNull Currency currency); static IsReadyToPayRequest getStripeIsReadyToPayRequest(); }
PaymentUtils { public static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString) { if (TextUtils.isEmpty(priceString)) { return true; } Pattern pattern = Pattern.compile("^-?[0-9]+(\\.[0-9][0-9])?"); return pattern.matcher(priceString).matches(); }  static boolean matchesCurrencyPatternOrEmpty(@Nullable String priceString); static boolean matchesQuantityPatternOrEmpty(@Nullable String quantityString); @NonNull static List<CartError> validateLineItemList(
            List<LineItem> lineItems,
            @NonNull String currencyCode); static CartError searchLineItemForErrors(LineItem lineItem); @NonNull static String getPriceString(long price); @NonNull static List<CartError> removeErrorType(
            @NonNull List<CartError> errors,
            @NonNull @CartError.CartErrorType String errorType); @NonNull static String getPriceString(Long price, @NonNull Currency currency); static IsReadyToPayRequest getStripeIsReadyToPayRequest();  }