@NonNull private static Map<String, Object> hashMapFromBankAccount( @Nullable UidProvider provider, @NonNull Context context, @NonNull BankAccount bankAccount) { Map<String, Object> tokenParams = new HashMap<>(); Map<String, Object> accountParams = new HashMap<>(); accountParams.put("country", bankAccount.getCountryCode()); accountParams.put("currency", bankAccount.getCurrency()); accountParams.put("account_number", bankAccount.getAccountNumber()); accountParams.put("routing_number", StripeTextUtils.nullIfBlank(bankAccount.getRoutingNumber())); accountParams.put("account_holder_name", StripeTextUtils.nullIfBlank(bankAccount.getAccountHolderName())); accountParams.put("account_holder_type", StripeTextUtils.nullIfBlank(bankAccount.getAccountHolderType())); // Remove all null values; they cause validation errors removeNullAndEmptyParams(accountParams); tokenParams.put(Token.TYPE_BANK_ACCOUNT, accountParams); addUidParams(provider, context, tokenParams); return tokenParams; }
@Test public void parseSampleAccount_returnsExpectedValue() { BankAccount expectedAccount = new BankAccount( "Jane Austen", BankAccount.TYPE_INDIVIDUAL, "STRIPE TEST BANK", "US", "usd", "1JWtPxqbdX5Gamtc", "6789", "110000000"); BankAccount actualAccount = BankAccount.fromString(RAW_BANK_ACCOUNT); assertNotNull(actualAccount); assertEquals(expectedAccount.getAccountHolderName(), actualAccount.getAccountHolderName()); assertEquals(expectedAccount.getAccountHolderType(), actualAccount.getAccountHolderType()); assertEquals(expectedAccount.getBankName(), actualAccount.getBankName()); assertEquals(expectedAccount.getCountryCode(), actualAccount.getCountryCode()); assertEquals(expectedAccount.getCurrency(), actualAccount.getCurrency()); assertEquals(expectedAccount.getFingerprint(), actualAccount.getFingerprint()); assertEquals(expectedAccount.getLast4(), actualAccount.getLast4()); assertEquals(expectedAccount.getRoutingNumber(), actualAccount.getRoutingNumber()); } }