| 8 | import static org.junit.Assert.assertThat; |
| 9 | |
| 10 | public class FinanceTest extends AbstractFakerTest { |
| 11 | |
| 12 | @Test |
| 13 | public void creditCard() { |
| 14 | for (int i = 0; i < 100; i++) { |
| 15 | final String creditCard = faker.finance().creditCard(); |
| 16 | assertCardLuhnDigit(creditCard); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | private void assertCardLuhnDigit(String creditCard) { |
| 21 | final String creditCardStripped = creditCard.replaceAll("-", ""); |
| 22 | assertThat(LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(creditCardStripped), is(true)); |
| 23 | } |
| 24 | |
| 25 | @Test |
| 26 | public void bic() { |
| 27 | assertThat(faker.finance().bic(), matchesRegularExpression("([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?")); |
| 28 | } |
| 29 | |
| 30 | @Test |
| 31 | public void iban() { |
| 32 | assertThat(faker.finance().iban(), matchesRegularExpression("[A-Z]{2}\\p{Alnum}{13,30}")); |
| 33 | } |
| 34 | |
| 35 | @Test |
| 36 | public void ibanWithCountryCode() { |
| 37 | assertThat(faker.finance().iban("DE"), matchesRegularExpression("DE\\d{20}")); |
| 38 | } |
| 39 | |
| 40 | @Test |
| 41 | public void creditCardWithType() { |
| 42 | for(CreditCardType type : CreditCardType.values()) { |
| 43 | final String creditCard = faker.finance().creditCard(type); |
| 44 | assertCardLuhnDigit(creditCard); |
| 45 | } |
| 46 | } |
| 47 | } |
nothing calls this directly
no outgoing calls
no test coverage detected