Example usage for com.liferay.portal.kernel.test.util RandomTestUtil nextDouble

List of usage examples for com.liferay.portal.kernel.test.util RandomTestUtil nextDouble

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.test.util RandomTestUtil nextDouble.

Prototype

public static double nextDouble() 

Source Link

Usage

From source file:com.liferay.blogs.service.persistence.test.BlogsStatsUserPersistenceTest.java

License:Open Source License

@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    BlogsStatsUser newBlogsStatsUser = _persistence.create(pk);

    newBlogsStatsUser.setGroupId(RandomTestUtil.nextLong());

    newBlogsStatsUser.setCompanyId(RandomTestUtil.nextLong());

    newBlogsStatsUser.setUserId(RandomTestUtil.nextLong());

    newBlogsStatsUser.setEntryCount(RandomTestUtil.nextInt());

    newBlogsStatsUser.setLastPostDate(RandomTestUtil.nextDate());

    newBlogsStatsUser.setRatingsTotalEntries(RandomTestUtil.nextInt());

    newBlogsStatsUser.setRatingsTotalScore(RandomTestUtil.nextDouble());

    newBlogsStatsUser.setRatingsAverageScore(RandomTestUtil.nextDouble());

    _blogsStatsUsers.add(_persistence.update(newBlogsStatsUser));

    BlogsStatsUser existingBlogsStatsUser = _persistence.findByPrimaryKey(newBlogsStatsUser.getPrimaryKey());

    Assert.assertEquals(existingBlogsStatsUser.getStatsUserId(), newBlogsStatsUser.getStatsUserId());
    Assert.assertEquals(existingBlogsStatsUser.getGroupId(), newBlogsStatsUser.getGroupId());
    Assert.assertEquals(existingBlogsStatsUser.getCompanyId(), newBlogsStatsUser.getCompanyId());
    Assert.assertEquals(existingBlogsStatsUser.getUserId(), newBlogsStatsUser.getUserId());
    Assert.assertEquals(existingBlogsStatsUser.getEntryCount(), newBlogsStatsUser.getEntryCount());
    Assert.assertEquals(Time.getShortTimestamp(existingBlogsStatsUser.getLastPostDate()),
            Time.getShortTimestamp(newBlogsStatsUser.getLastPostDate()));
    Assert.assertEquals(existingBlogsStatsUser.getRatingsTotalEntries(),
            newBlogsStatsUser.getRatingsTotalEntries());
    AssertUtils.assertEquals(existingBlogsStatsUser.getRatingsTotalScore(),
            newBlogsStatsUser.getRatingsTotalScore());
    AssertUtils.assertEquals(existingBlogsStatsUser.getRatingsAverageScore(),
            newBlogsStatsUser.getRatingsAverageScore());
}

From source file:com.liferay.blogs.service.persistence.test.BlogsStatsUserPersistenceTest.java

License:Open Source License

protected BlogsStatsUser addBlogsStatsUser() throws Exception {
    long pk = RandomTestUtil.nextLong();

    BlogsStatsUser blogsStatsUser = _persistence.create(pk);

    blogsStatsUser.setGroupId(RandomTestUtil.nextLong());

    blogsStatsUser.setCompanyId(RandomTestUtil.nextLong());

    blogsStatsUser.setUserId(RandomTestUtil.nextLong());

    blogsStatsUser.setEntryCount(RandomTestUtil.nextInt());

    blogsStatsUser.setLastPostDate(RandomTestUtil.nextDate());

    blogsStatsUser.setRatingsTotalEntries(RandomTestUtil.nextInt());

    blogsStatsUser.setRatingsTotalScore(RandomTestUtil.nextDouble());

    blogsStatsUser.setRatingsAverageScore(RandomTestUtil.nextDouble());

    _blogsStatsUsers.add(_persistence.update(blogsStatsUser));

    return blogsStatsUser;
}

From source file:com.liferay.exportimport.test.util.lar.BaseStagedModelDataHandlerTestCase.java

License:Open Source License

protected StagedModelAssets updateAssetEntry(StagedModel stagedModel, Group group) throws Exception {

    AssetEntry assetEntry = fetchAssetEntry(stagedModel, group);

    if (assetEntry == null) {
        return null;
    }//from  www . j  a v a2  s .c  om

    AssetVocabulary assetVocabulary = AssetTestUtil.addVocabulary(stagingGroup.getGroupId());

    AssetCategory assetCategory = AssetTestUtil.addCategory(stagingGroup.getGroupId(),
            assetVocabulary.getVocabularyId());

    Company company = CompanyLocalServiceUtil.getCompany(stagedModel.getCompanyId());

    Group companyGroup = company.getGroup();

    AssetVocabulary companyAssetVocabulary = AssetTestUtil.addVocabulary(companyGroup.getGroupId());

    AssetCategory companyAssetCategory = AssetTestUtil.addCategory(companyGroup.getGroupId(),
            companyAssetVocabulary.getVocabularyId());

    AssetTag assetTag = AssetTestUtil.addTag(stagingGroup.getGroupId());

    double assetPriority = assetEntry.getPriority();

    if (isAssetPrioritySupported()) {
        assetPriority = RandomTestUtil.nextDouble();
    }

    assetEntry = AssetEntryLocalServiceUtil.updateEntry(TestPropsValues.getUserId(), stagingGroup.getGroupId(),
            assetEntry.getCreateDate(), assetEntry.getModifiedDate(), assetEntry.getClassName(),
            assetEntry.getClassPK(), assetEntry.getClassUuid(), assetEntry.getClassTypeId(),
            new long[] { assetCategory.getCategoryId(), companyAssetCategory.getCategoryId() },
            new String[] { assetTag.getName() }, assetEntry.isListable(), assetEntry.isVisible(),
            assetEntry.getStartDate(), assetEntry.getEndDate(), assetEntry.getPublishDate(),
            assetEntry.getExpirationDate(), assetEntry.getMimeType(), assetEntry.getTitle(),
            assetEntry.getDescription(), assetEntry.getSummary(), assetEntry.getUrl(),
            assetEntry.getLayoutUuid(), assetEntry.getHeight(), assetEntry.getWidth(), assetPriority);

    return new StagedModelAssets(assetCategory, assetEntry, assetTag, assetVocabulary);
}

From source file:com.liferay.journal.service.persistence.test.JournalArticlePersistenceTest.java

License:Open Source License

@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    JournalArticle newJournalArticle = _persistence.create(pk);

    newJournalArticle.setUuid(RandomTestUtil.randomString());

    newJournalArticle.setResourcePrimKey(RandomTestUtil.nextLong());

    newJournalArticle.setGroupId(RandomTestUtil.nextLong());

    newJournalArticle.setCompanyId(RandomTestUtil.nextLong());

    newJournalArticle.setUserId(RandomTestUtil.nextLong());

    newJournalArticle.setUserName(RandomTestUtil.randomString());

    newJournalArticle.setCreateDate(RandomTestUtil.nextDate());

    newJournalArticle.setModifiedDate(RandomTestUtil.nextDate());

    newJournalArticle.setFolderId(RandomTestUtil.nextLong());

    newJournalArticle.setClassNameId(RandomTestUtil.nextLong());

    newJournalArticle.setClassPK(RandomTestUtil.nextLong());

    newJournalArticle.setTreePath(RandomTestUtil.randomString());

    newJournalArticle.setArticleId(RandomTestUtil.randomString());

    newJournalArticle.setVersion(RandomTestUtil.nextDouble());

    newJournalArticle.setUrlTitle(RandomTestUtil.randomString());

    newJournalArticle.setContent(RandomTestUtil.randomString());

    newJournalArticle.setDDMStructureKey(RandomTestUtil.randomString());

    newJournalArticle.setDDMTemplateKey(RandomTestUtil.randomString());

    newJournalArticle.setDefaultLanguageId(RandomTestUtil.randomString());

    newJournalArticle.setLayoutUuid(RandomTestUtil.randomString());

    newJournalArticle.setDisplayDate(RandomTestUtil.nextDate());

    newJournalArticle.setExpirationDate(RandomTestUtil.nextDate());

    newJournalArticle.setReviewDate(RandomTestUtil.nextDate());

    newJournalArticle.setIndexable(RandomTestUtil.randomBoolean());

    newJournalArticle.setSmallImage(RandomTestUtil.randomBoolean());

    newJournalArticle.setSmallImageId(RandomTestUtil.nextLong());

    newJournalArticle.setSmallImageURL(RandomTestUtil.randomString());

    newJournalArticle.setLastPublishDate(RandomTestUtil.nextDate());

    newJournalArticle.setStatus(RandomTestUtil.nextInt());

    newJournalArticle.setStatusByUserId(RandomTestUtil.nextLong());

    newJournalArticle.setStatusByUserName(RandomTestUtil.randomString());

    newJournalArticle.setStatusDate(RandomTestUtil.nextDate());

    _journalArticles.add(_persistence.update(newJournalArticle));

    JournalArticle existingJournalArticle = _persistence.findByPrimaryKey(newJournalArticle.getPrimaryKey());

    Assert.assertEquals(existingJournalArticle.getUuid(), newJournalArticle.getUuid());
    Assert.assertEquals(existingJournalArticle.getId(), newJournalArticle.getId());
    Assert.assertEquals(existingJournalArticle.getResourcePrimKey(), newJournalArticle.getResourcePrimKey());
    Assert.assertEquals(existingJournalArticle.getGroupId(), newJournalArticle.getGroupId());
    Assert.assertEquals(existingJournalArticle.getCompanyId(), newJournalArticle.getCompanyId());
    Assert.assertEquals(existingJournalArticle.getUserId(), newJournalArticle.getUserId());
    Assert.assertEquals(existingJournalArticle.getUserName(), newJournalArticle.getUserName());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getCreateDate()),
            Time.getShortTimestamp(newJournalArticle.getCreateDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getModifiedDate()),
            Time.getShortTimestamp(newJournalArticle.getModifiedDate()));
    Assert.assertEquals(existingJournalArticle.getFolderId(), newJournalArticle.getFolderId());
    Assert.assertEquals(existingJournalArticle.getClassNameId(), newJournalArticle.getClassNameId());
    Assert.assertEquals(existingJournalArticle.getClassPK(), newJournalArticle.getClassPK());
    Assert.assertEquals(existingJournalArticle.getTreePath(), newJournalArticle.getTreePath());
    Assert.assertEquals(existingJournalArticle.getArticleId(), newJournalArticle.getArticleId());
    AssertUtils.assertEquals(existingJournalArticle.getVersion(), newJournalArticle.getVersion());
    Assert.assertEquals(existingJournalArticle.getUrlTitle(), newJournalArticle.getUrlTitle());
    Assert.assertEquals(existingJournalArticle.getContent(), newJournalArticle.getContent());
    Assert.assertEquals(existingJournalArticle.getDDMStructureKey(), newJournalArticle.getDDMStructureKey());
    Assert.assertEquals(existingJournalArticle.getDDMTemplateKey(), newJournalArticle.getDDMTemplateKey());
    Assert.assertEquals(existingJournalArticle.getDefaultLanguageId(),
            newJournalArticle.getDefaultLanguageId());
    Assert.assertEquals(existingJournalArticle.getLayoutUuid(), newJournalArticle.getLayoutUuid());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getDisplayDate()),
            Time.getShortTimestamp(newJournalArticle.getDisplayDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getExpirationDate()),
            Time.getShortTimestamp(newJournalArticle.getExpirationDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getReviewDate()),
            Time.getShortTimestamp(newJournalArticle.getReviewDate()));
    Assert.assertEquals(existingJournalArticle.getIndexable(), newJournalArticle.getIndexable());
    Assert.assertEquals(existingJournalArticle.getSmallImage(), newJournalArticle.getSmallImage());
    Assert.assertEquals(existingJournalArticle.getSmallImageId(), newJournalArticle.getSmallImageId());
    Assert.assertEquals(existingJournalArticle.getSmallImageURL(), newJournalArticle.getSmallImageURL());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getLastPublishDate()),
            Time.getShortTimestamp(newJournalArticle.getLastPublishDate()));
    Assert.assertEquals(existingJournalArticle.getStatus(), newJournalArticle.getStatus());
    Assert.assertEquals(existingJournalArticle.getStatusByUserId(), newJournalArticle.getStatusByUserId());
    Assert.assertEquals(existingJournalArticle.getStatusByUserName(), newJournalArticle.getStatusByUserName());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalArticle.getStatusDate()),
            Time.getShortTimestamp(newJournalArticle.getStatusDate()));
}

From source file:com.liferay.journal.service.persistence.test.JournalArticlePersistenceTest.java

License:Open Source License

@Test
public void testCountByC_V() throws Exception {
    _persistence.countByC_V(RandomTestUtil.nextLong(), RandomTestUtil.nextDouble());

    _persistence.countByC_V(0L, 0D);
}

From source file:com.liferay.journal.service.persistence.test.JournalArticlePersistenceTest.java

License:Open Source License

@Test
public void testCountByG_A_V() throws Exception {
    _persistence.countByG_A_V(RandomTestUtil.nextLong(), StringPool.BLANK, RandomTestUtil.nextDouble());

    _persistence.countByG_A_V(0L, StringPool.NULL, 0D);

    _persistence.countByG_A_V(0L, (String) null, 0D);
}

From source file:com.liferay.journal.service.persistence.test.JournalArticlePersistenceTest.java

License:Open Source License

@Test
public void testCountByC_V_ST() throws Exception {
    _persistence.countByC_V_ST(RandomTestUtil.nextLong(), RandomTestUtil.nextDouble(),
            RandomTestUtil.nextInt());// ww w .  j a  va 2s . co  m

    _persistence.countByC_V_ST(0L, 0D, 0);
}

From source file:com.liferay.journal.service.persistence.test.JournalArticlePersistenceTest.java

License:Open Source License

protected JournalArticle addJournalArticle() throws Exception {
    long pk = RandomTestUtil.nextLong();

    JournalArticle journalArticle = _persistence.create(pk);

    journalArticle.setUuid(RandomTestUtil.randomString());

    journalArticle.setResourcePrimKey(RandomTestUtil.nextLong());

    journalArticle.setGroupId(RandomTestUtil.nextLong());

    journalArticle.setCompanyId(RandomTestUtil.nextLong());

    journalArticle.setUserId(RandomTestUtil.nextLong());

    journalArticle.setUserName(RandomTestUtil.randomString());

    journalArticle.setCreateDate(RandomTestUtil.nextDate());

    journalArticle.setModifiedDate(RandomTestUtil.nextDate());

    journalArticle.setFolderId(RandomTestUtil.nextLong());

    journalArticle.setClassNameId(RandomTestUtil.nextLong());

    journalArticle.setClassPK(RandomTestUtil.nextLong());

    journalArticle.setTreePath(RandomTestUtil.randomString());

    journalArticle.setArticleId(RandomTestUtil.randomString());

    journalArticle.setVersion(RandomTestUtil.nextDouble());

    journalArticle.setUrlTitle(RandomTestUtil.randomString());

    journalArticle.setContent(RandomTestUtil.randomString());

    journalArticle.setDDMStructureKey(RandomTestUtil.randomString());

    journalArticle.setDDMTemplateKey(RandomTestUtil.randomString());

    journalArticle.setDefaultLanguageId(RandomTestUtil.randomString());

    journalArticle.setLayoutUuid(RandomTestUtil.randomString());

    journalArticle.setDisplayDate(RandomTestUtil.nextDate());

    journalArticle.setExpirationDate(RandomTestUtil.nextDate());

    journalArticle.setReviewDate(RandomTestUtil.nextDate());

    journalArticle.setIndexable(RandomTestUtil.randomBoolean());

    journalArticle.setSmallImage(RandomTestUtil.randomBoolean());

    journalArticle.setSmallImageId(RandomTestUtil.nextLong());

    journalArticle.setSmallImageURL(RandomTestUtil.randomString());

    journalArticle.setLastPublishDate(RandomTestUtil.nextDate());

    journalArticle.setStatus(RandomTestUtil.nextInt());

    journalArticle.setStatusByUserId(RandomTestUtil.nextLong());

    journalArticle.setStatusByUserName(RandomTestUtil.randomString());

    journalArticle.setStatusDate(RandomTestUtil.nextDate());

    _journalArticles.add(_persistence.update(journalArticle));

    return journalArticle;
}

From source file:com.liferay.journal.service.persistence.test.JournalFeedPersistenceTest.java

License:Open Source License

@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    JournalFeed newJournalFeed = _persistence.create(pk);

    newJournalFeed.setUuid(RandomTestUtil.randomString());

    newJournalFeed.setGroupId(RandomTestUtil.nextLong());

    newJournalFeed.setCompanyId(RandomTestUtil.nextLong());

    newJournalFeed.setUserId(RandomTestUtil.nextLong());

    newJournalFeed.setUserName(RandomTestUtil.randomString());

    newJournalFeed.setCreateDate(RandomTestUtil.nextDate());

    newJournalFeed.setModifiedDate(RandomTestUtil.nextDate());

    newJournalFeed.setFeedId(RandomTestUtil.randomString());

    newJournalFeed.setName(RandomTestUtil.randomString());

    newJournalFeed.setDescription(RandomTestUtil.randomString());

    newJournalFeed.setDDMStructureKey(RandomTestUtil.randomString());

    newJournalFeed.setDDMTemplateKey(RandomTestUtil.randomString());

    newJournalFeed.setDDMRendererTemplateKey(RandomTestUtil.randomString());

    newJournalFeed.setDelta(RandomTestUtil.nextInt());

    newJournalFeed.setOrderByCol(RandomTestUtil.randomString());

    newJournalFeed.setOrderByType(RandomTestUtil.randomString());

    newJournalFeed.setTargetLayoutFriendlyUrl(RandomTestUtil.randomString());

    newJournalFeed.setTargetPortletId(RandomTestUtil.randomString());

    newJournalFeed.setContentField(RandomTestUtil.randomString());

    newJournalFeed.setFeedFormat(RandomTestUtil.randomString());

    newJournalFeed.setFeedVersion(RandomTestUtil.nextDouble());

    newJournalFeed.setLastPublishDate(RandomTestUtil.nextDate());

    _journalFeeds.add(_persistence.update(newJournalFeed));

    JournalFeed existingJournalFeed = _persistence.findByPrimaryKey(newJournalFeed.getPrimaryKey());

    Assert.assertEquals(existingJournalFeed.getUuid(), newJournalFeed.getUuid());
    Assert.assertEquals(existingJournalFeed.getId(), newJournalFeed.getId());
    Assert.assertEquals(existingJournalFeed.getGroupId(), newJournalFeed.getGroupId());
    Assert.assertEquals(existingJournalFeed.getCompanyId(), newJournalFeed.getCompanyId());
    Assert.assertEquals(existingJournalFeed.getUserId(), newJournalFeed.getUserId());
    Assert.assertEquals(existingJournalFeed.getUserName(), newJournalFeed.getUserName());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalFeed.getCreateDate()),
            Time.getShortTimestamp(newJournalFeed.getCreateDate()));
    Assert.assertEquals(Time.getShortTimestamp(existingJournalFeed.getModifiedDate()),
            Time.getShortTimestamp(newJournalFeed.getModifiedDate()));
    Assert.assertEquals(existingJournalFeed.getFeedId(), newJournalFeed.getFeedId());
    Assert.assertEquals(existingJournalFeed.getName(), newJournalFeed.getName());
    Assert.assertEquals(existingJournalFeed.getDescription(), newJournalFeed.getDescription());
    Assert.assertEquals(existingJournalFeed.getDDMStructureKey(), newJournalFeed.getDDMStructureKey());
    Assert.assertEquals(existingJournalFeed.getDDMTemplateKey(), newJournalFeed.getDDMTemplateKey());
    Assert.assertEquals(existingJournalFeed.getDDMRendererTemplateKey(),
            newJournalFeed.getDDMRendererTemplateKey());
    Assert.assertEquals(existingJournalFeed.getDelta(), newJournalFeed.getDelta());
    Assert.assertEquals(existingJournalFeed.getOrderByCol(), newJournalFeed.getOrderByCol());
    Assert.assertEquals(existingJournalFeed.getOrderByType(), newJournalFeed.getOrderByType());
    Assert.assertEquals(existingJournalFeed.getTargetLayoutFriendlyUrl(),
            newJournalFeed.getTargetLayoutFriendlyUrl());
    Assert.assertEquals(existingJournalFeed.getTargetPortletId(), newJournalFeed.getTargetPortletId());
    Assert.assertEquals(existingJournalFeed.getContentField(), newJournalFeed.getContentField());
    Assert.assertEquals(existingJournalFeed.getFeedFormat(), newJournalFeed.getFeedFormat());
    AssertUtils.assertEquals(existingJournalFeed.getFeedVersion(), newJournalFeed.getFeedVersion());
    Assert.assertEquals(Time.getShortTimestamp(existingJournalFeed.getLastPublishDate()),
            Time.getShortTimestamp(newJournalFeed.getLastPublishDate()));
}

From source file:com.liferay.journal.service.persistence.test.JournalFeedPersistenceTest.java

License:Open Source License

protected JournalFeed addJournalFeed() throws Exception {
    long pk = RandomTestUtil.nextLong();

    JournalFeed journalFeed = _persistence.create(pk);

    journalFeed.setUuid(RandomTestUtil.randomString());

    journalFeed.setGroupId(RandomTestUtil.nextLong());

    journalFeed.setCompanyId(RandomTestUtil.nextLong());

    journalFeed.setUserId(RandomTestUtil.nextLong());

    journalFeed.setUserName(RandomTestUtil.randomString());

    journalFeed.setCreateDate(RandomTestUtil.nextDate());

    journalFeed.setModifiedDate(RandomTestUtil.nextDate());

    journalFeed.setFeedId(RandomTestUtil.randomString());

    journalFeed.setName(RandomTestUtil.randomString());

    journalFeed.setDescription(RandomTestUtil.randomString());

    journalFeed.setDDMStructureKey(RandomTestUtil.randomString());

    journalFeed.setDDMTemplateKey(RandomTestUtil.randomString());

    journalFeed.setDDMRendererTemplateKey(RandomTestUtil.randomString());

    journalFeed.setDelta(RandomTestUtil.nextInt());

    journalFeed.setOrderByCol(RandomTestUtil.randomString());

    journalFeed.setOrderByType(RandomTestUtil.randomString());

    journalFeed.setTargetLayoutFriendlyUrl(RandomTestUtil.randomString());

    journalFeed.setTargetPortletId(RandomTestUtil.randomString());

    journalFeed.setContentField(RandomTestUtil.randomString());

    journalFeed.setFeedFormat(RandomTestUtil.randomString());

    journalFeed.setFeedVersion(RandomTestUtil.nextDouble());

    journalFeed.setLastPublishDate(RandomTestUtil.nextDate());

    _journalFeeds.add(_persistence.update(journalFeed));

    return journalFeed;
}