(CreditCardType creditCardType)
| 20 | createCountryCodeToBasicBankAccountNumberPatternMap(); |
| 21 | |
| 22 | public String creditCard(CreditCardType creditCardType) { |
| 23 | final String key = String.format("finance.credit_card.%s", creditCardType.toString().toLowerCase()); |
| 24 | String value = faker.fakeValuesService().resolve(key, this, faker); |
| 25 | final String template = faker.numerify(value); |
| 26 | |
| 27 | String[] split = template.replaceAll("[^0-9]", "").split(""); |
| 28 | List<Integer> reversedAsInt = new ArrayList<Integer>(); |
| 29 | for (int i = 0; i < split.length; i++) { |
| 30 | final String current = split[split.length - 1 - i]; |
| 31 | if (!current.isEmpty()) { |
| 32 | reversedAsInt.add(Integer.valueOf(current)); |
| 33 | } |
| 34 | } |
| 35 | int luhnSum = 0; |
| 36 | int multiplier = 1; |
| 37 | for (Integer digit : reversedAsInt) { |
| 38 | multiplier = (multiplier == 2 ? 1 : 2); |
| 39 | luhnSum += sum(String.valueOf(digit * multiplier).split("")); |
| 40 | } |
| 41 | int luhnDigit = (10 - (luhnSum % 10)) % 10; |
| 42 | return template.replace('\\', ' ').replace('/', ' ').trim().replace('L', String.valueOf(luhnDigit).charAt(0)); |
| 43 | } |
| 44 | |
| 45 | public String creditCard() { |
| 46 | CreditCardType type = randomCreditCardType(); |
nothing calls this directly
no test coverage detected