use of com.github.javafaker.DateAndTime in project com-liferay-apio-architect by liferay.
the class PersonModel method compute.
/**
* Computes the fake data for this model class.
*/
public static void compute() {
if (!_personModels.isEmpty()) {
return;
}
for (long index = 0; index < 10; index++) {
Faker faker = new Faker();
Address address = faker.address();
Internet internet = faker.internet();
DateAndTime dateAndTime = faker.date();
Calendar calendar = Calendar.getInstance();
calendar.add(YEAR, -21);
Date birthDate = dateAndTime.past(10000, DAYS, calendar.getTime());
Name name = faker.name();
RandomService randomService = faker.random();
IntStream intStream = IntStream.range(0, randomService.nextInt(5));
List<String> jobTitles = intStream.mapToObj(__ -> name.title()).collect(Collectors.toList());
PersonModel personModel = new PersonModel(address.fullAddress(), internet.avatar(), birthDate, internet.safeEmailAddress(), name.firstName(), jobTitles, name.lastName(), _count.get());
_personModels.put(_count.getAndIncrement(), personModel);
}
}
use of com.github.javafaker.DateAndTime in project com-liferay-apio-architect by liferay.
the class BlogPostingModel method compute.
/**
* Computes the fake data for this model class.
*/
public static void compute() {
if (!_blogPostings.isEmpty()) {
return;
}
for (long index = 0; index < 42; index++) {
Faker faker = new Faker();
Book book = faker.book();
Lorem lorem = faker.lorem();
RandomService randomService = faker.random();
int creatorId = randomService.nextInt(PersonModel.getCount());
DateAndTime dateAndTime = faker.date();
Date date = dateAndTime.past(400, DAYS);
BlogPostingModel blogPostingModel = new BlogPostingModel(_count.get(), lorem.paragraph(), date, creatorId, date, lorem.sentence(), book.title());
_blogPostings.put(_count.getAndIncrement(), blogPostingModel);
}
}
use of com.github.javafaker.DateAndTime in project com-liferay-apio-architect by liferay.
the class BlogPostingCommentModel method compute.
/**
* Computes the fake data for this model class.
*/
public static void compute() {
if (!_blogPostingCommentModels.isEmpty()) {
return;
}
for (long index = 0; index < BlogPostingModel.getCount(); index++) {
Map<Long, BlogPostingCommentModel> blogPostingCommentModels = new HashMap<>();
Random random = new Random();
for (int i = 0; i < random.nextInt(70); i++) {
long authorId = random.nextInt(PersonModel.getCount());
Faker faker = new Faker();
Shakespeare shakespeare = faker.shakespeare();
DateAndTime dateAndTime = faker.date();
Date date = dateAndTime.past(400, DAYS);
BlogPostingCommentModel blogPostingCommentModel = new BlogPostingCommentModel(authorId, _count.get(), index, shakespeare.hamletQuote(), date, date);
blogPostingCommentModels.put(_count.getAndIncrement(), blogPostingCommentModel);
}
_blogPostingCommentModels.put(index, blogPostingCommentModels);
}
}
Aggregations