com.github.javafaker.service.RandomService Java Examples

The following examples show how to use com.github.javafaker.service.RandomService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaFakerUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void testFakeValuesService() throws Exception {

    FakeValuesService fakeValuesService = new FakeValuesService(new Locale("en-GB"), new RandomService());

    String email = fakeValuesService.bothify("????##@gmail.com");
    Matcher emailMatcher = Pattern.compile("\\w{4}\\d{2}@gmail.com")
        .matcher(email);
    assertTrue(emailMatcher.find());

    String alphaNumericString = fakeValuesService.regexify("[a-z1-9]{10}");
    Matcher alphaNumericMatcher = Pattern.compile("[a-z1-9]{10}")
        .matcher(alphaNumericString);
    assertTrue(alphaNumericMatcher.find());

}
 
Example #2
Source File: EstatioFakeDataService.java    From estatio with Apache License 2.0 5 votes vote down vote up
public EstatioFakeDataService() {

        randomService = new RandomService(random);

        this.strings = new Strings();
        this.chars = new Chars();
        this.dates = new Dates();
        this.periods = new Periods();
    }
 
Example #3
Source File: JavaFakerUnitTest.java    From tutorials with MIT License 3 votes vote down vote up
@Test
public void givenJavaFakerService_testFakersCreated() throws Exception {

    RandomService randomService = new RandomService();

    System.out.println(randomService.nextBoolean());
    System.out.println(randomService.nextDouble());

    Faker faker = new Faker(new Random(randomService.nextLong()));

    System.out.println(faker.address()
        .city());

}