public String creditCard(CreditCardType creditCardType) { final String key = String.format("finance.credit_card.%s", creditCardType.toString().toLowerCase()); String value = faker.fakeValuesService().resolve(key, this, faker); final String template = faker.numerify(value); String[] split = template.replaceAll("[^0-9]", "").split(""); List<Integer> reversedAsInt = new ArrayList<Integer>(); for (int i = 0; i < split.length; i++) { final String current = split[split.length - 1 - i]; if (!current.isEmpty()) { reversedAsInt.add(Integer.valueOf(current)); } } int luhnSum = 0; int multiplier = 1; for (Integer digit : reversedAsInt) { multiplier = (multiplier == 2 ? 1 : 2); luhnSum += sum(String.valueOf(digit * multiplier).split("")); } int luhnDigit = (10 - (luhnSum % 10)) % 10; return template.replace('\\', ' ').replace('/', ' ').trim().replace('L', String.valueOf(luhnDigit).charAt(0)); }
public String getValidSsn(Faker f) { String candidate = ""; while (!validSwedishSsn(candidate)) { String pattern = getPattern(f); candidate = f.numerify(pattern); } return candidate; }
public String getInvalidSsn(Faker f) { String candidate = "121212-1212"; // Seed with a valid number while (validSwedishSsn(candidate)) { String pattern = getPattern(f); candidate = f.numerify(pattern); } return candidate; }
public String invalid() { return faker.numerify(faker.fakeValuesService().resolve("id_number.invalid", this, faker)); }
public String secondaryAddress() { return faker.numerify(faker.fakeValuesService().resolve("address.secondary_address", this,faker)); }
public String phoneNumber() { return faker.numerify(faker.fakeValuesService().resolve("phone_number.formats", this, faker)); } }
public String buildingNumber() { return faker.numerify(faker.fakeValuesService().resolve("address.building_number", this, faker)); }
public String cellPhone() { return faker.numerify(faker.fakeValuesService().resolve("cell_phone.formats", this, faker)); }
public String version() { return faker.numerify(faker.fakeValuesService().resolve("app.version", this, faker)); }