use of com.github.javafaker.Faker in project api-snippets by TwilioDevEd.
the class Webapp method main.
public static void main(String[] args) {
// Serve static files from src/main/resources/public
staticFileLocation("/public");
String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
String API_KEY = System.getenv("TWILIO_API_KEY");
String API_SECRET = System.getenv("TWILIO_API_SECRET");
String TWILIO_CONFIGURATION_SID = System.getenv("TWILIO_CONFIGURATION_SID");
// Create a Faker instance to generate a random username for the connecting user
Faker faker = new Faker();
// Create an access token using our Twilio credentials
get("/token", "application/json", (request, response) -> {
// Generate a random username for the connecting client
String identity = faker.name().firstName() + faker.name().lastName() + faker.address().zipCode();
// Create Video grant
VideoGrant grant = new VideoGrant().setConfigurationProfileSid(TWILIO_CONFIGURATION_SID);
// Create access token
AccessToken token = new AccessToken.Builder(ACCOUNT_SID, API_KEY, API_SECRET).identity(identity).grant(grant).build();
// create JSON response payload
HashMap<String, String> json = new HashMap<String, String>();
json.put("identity", identity);
json.put("token", token.toJwt());
// Render JSON response
Gson gson = new Gson();
return gson.toJson(json);
});
}
use of com.github.javafaker.Faker in project java-faker by DiUS.
the class Issue194SlashFormatRegexIT method enGBZipCodeReturnsProperRegexifiedValue.
@Test
public void enGBZipCodeReturnsProperRegexifiedValue() {
final Locale uk = new Locale("en-GB");
final String postalCode = new Faker(uk).address().zipCode();
assertThat(postalCode, matchesRegularExpression("[A-PR-UWYZ]([A-HK-Y][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?) [0-9][ABD-HJLNP-UW-Z]{2}"));
}
use of com.github.javafaker.Faker in project java-faker by DiUS.
the class Issue194SlashFormatRegexIT method enCAZipCodeReturnsProperRegexifiedValue.
@Test
public void enCAZipCodeReturnsProperRegexifiedValue() {
final Locale uk = new Locale("en-CA");
final String postalCode = new Faker(uk).address().zipCode();
assertThat(postalCode, matchesRegularExpression("[A-CEJ-NPR-TVXY][0-9][A-CEJ-NPR-TV-Z] ?[0-9][A-CEJ-NPR-TV-Z][0-9]"));
}
use of com.github.javafaker.Faker in project java-faker by DiUS.
the class FakeValuesServiceTest method bothify2Args.
@Test
public void bothify2Args() {
final DummyService dummy = mock(DummyService.class);
Faker f = new Faker();
String value = fakeValuesService.resolve("property.bothify_2", dummy, f);
assertThat(value, matchesRegularExpression("[A-Z]{2}\\d{2}"));
}
use of com.github.javafaker.Faker in project bisq-api by mrosseel.
the class ApiTestHelper method randomValidCreateSepaAccountPayload.
public static SepaPaymentAccount randomValidCreateSepaAccountPayload(String tradeCurrency, String countryCode) {
final Faker faker = new Faker();
final SepaPaymentAccount accountToCreate = new SepaPaymentAccount();
if (null == countryCode)
countryCode = faker.options().nextElement(CountryUtil.getAllSepaCountries()).code;
accountToCreate.paymentMethod = PaymentMethod.SEPA_ID;
accountToCreate.accountName = faker.commerce().productName();
accountToCreate.bic = faker.finance().bic();
accountToCreate.iban = faker.finance().iban();
accountToCreate.holderName = faker.name().fullName();
accountToCreate.countryCode = countryCode;
accountToCreate.acceptedCountries = new ArrayList<>(new HashSet<>(Arrays.asList("PL", "GB", countryCode)));
accountToCreate.selectedTradeCurrency = faker.options().option("PLN", "USD", "EUR", "GBP");
if (null != tradeCurrency)
accountToCreate.selectedTradeCurrency = tradeCurrency;
accountToCreate.tradeCurrencies = Collections.singletonList(accountToCreate.selectedTradeCurrency);
return accountToCreate;
}
Aggregations