added credit card data

This commit is contained in:
Ricky
2014-04-24 15:02:25 +10:00
parent 3ed8e876f5
commit a88c7d41a1
6 changed files with 76 additions and 1 deletions
@@ -0,0 +1,21 @@
package com.github.javafaker;
public class Business {
private final FakeValuesService fakeValuesService;
public Business(FakeValuesService fakeValuesService) {
this.fakeValuesService = fakeValuesService;
}
public String creditCardNumber() {
return fakeValuesService.fetchString("business.credit_card_numbers");
}
public String creditCardType() {
return fakeValuesService.fetchString("business.credit_card_types");
}
public String creditCardExpiry() {
return fakeValuesService.fetchString("business.credit_card_expiry_dates");
}
}
@@ -18,6 +18,7 @@ public class Faker {
private final Internet internet;
private final PhoneNumber phoneNumber;
private final Address address;
private final Business business;
public Faker() {
this(Locale.ENGLISH);
@@ -39,6 +40,7 @@ public class Faker {
this.internet = new Internet(name, fakeValuesService);
this.phoneNumber = new PhoneNumber(fakeValuesService);
this.address = new Address(name, fakeValuesService);
this.business = new Business(fakeValuesService);
}
public String numerify(String numberString) {
@@ -174,4 +176,8 @@ public class Faker {
public String country() {
return address.country();
}
public Business business() {
return business;
}
}
+4
View File
@@ -58,3 +58,7 @@ en:
- :last_name
phone_number:
formats: ['###-###-####', '(###)###-####', '1-###-###-####', '###.###.####', '###-###-####', '(###)###-####', '1-###-###-####', '###.###.####', '###-###-#### x###', '(###)###-#### x###', '1-###-###-#### x###', '###.###.#### x###', '###-###-#### x####', '(###)###-#### x####', '1-###-###-#### x####', '###.###.#### x####', '###-###-#### x#####', '(###)###-#### x#####', '1-###-###-#### x#####', '###.###.#### x#####']
business:
credit_card_numbers: ['1234-2121-1221-1211', '1212-1221-1121-1234', '1211-1221-1234-2201', '1228-1221-1221-1431']
credit_card_expiry_dates: ['2011-10-12', '2012-11-12', '2015-11-11', '2013-9-12']
credit_card_types: ['visa', 'mastercard', 'americanexpress', 'discover']
+4 -1
View File
@@ -1799,4 +1799,7 @@ fi:
formats:
- "###-###-####"
- "(###)###-####"
business:
credit_card_numbers: ['1234-2121-1221-1211', '1212-1221-1121-1234', '1211-1221-1234-2201', '1228-1221-1221-1431']
credit_card_expiry_dates: ['2011-10-12', '2012-11-12', '2015-11-11', '2013-9-12']
credit_card_types: ['visa', 'mastercard', 'americanexpress', 'discover']
+4
View File
@@ -58,3 +58,7 @@ fr:
phone_number:
formats: ['01########', '02########', '03########', '04########', '05########', '06########', '07########', '+33 1########', '+33 2########', '+33 3########', '+33 4########', '+33 5########', '+33 6########', '+33 7########']
business:
credit_card_numbers: ['1234-2121-1221-1211', '1212-1221-1121-1234', '1211-1221-1234-2201', '1228-1221-1221-1431']
credit_card_expiry_dates: ['2011-10-12', '2012-11-12', '2015-11-11', '2013-9-12']
credit_card_types: ['visa', 'mastercard', 'americanexpress', 'discover']
@@ -0,0 +1,37 @@
package com.github.javafaker;
import org.junit.Test;
import java.util.Locale;
import java.util.Random;
import static org.junit.Assert.assertNotNull;
public class BusinessTest extends AbstractFakerTest {
public BusinessTest(Locale locale, Random random) {
super(locale, random);
}
@Test
public void testCreditCardNumber() {
final String creditCardNumber = faker.business().creditCardNumber();
logger.info("Credit card number is " + creditCardNumber);
assertNotNull(creditCardNumber);
}
@Test
public void testCreditCardExpiry() {
final String creditCardExpiry = faker.business().creditCardExpiry();
logger.info("Credit card expiry is " + creditCardExpiry);
assertNotNull(creditCardExpiry);
}
@Test
public void testCreditCardTypes() {
final String creditCardType = faker.business().creditCardType();
logger.info("Credit card type is " + creditCardType);
assertNotNull(creditCardType);
}
}