Search in sources :

Example 1 with Shakespeare

use of com.github.javafaker.Shakespeare 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);
    }
}
Also used : Random(java.util.Random) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Faker(com.github.javafaker.Faker) Shakespeare(com.github.javafaker.Shakespeare) AtomicLong(java.util.concurrent.atomic.AtomicLong) DateAndTime(com.github.javafaker.DateAndTime) Date(java.util.Date)

Aggregations

DateAndTime (com.github.javafaker.DateAndTime)1 Faker (com.github.javafaker.Faker)1 Shakespeare (com.github.javafaker.Shakespeare)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1