@Test
  public void testLocalizedSiteAddFileEntryType() throws Exception {
    Group group = GroupTestUtil.addGroup();

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    Locale locale = LocaleThreadLocal.getSiteDefaultLocale();

    try {
      LocaleThreadLocal.setSiteDefaultLocale(LocaleUtil.SPAIN);

      String name = RandomTestUtil.randomString();
      String description = RandomTestUtil.randomString();
      DDMStructure ddmStructure =
          DDMStructureTestUtil.addStructure(
              DLFileEntry.class.getName(), new Locale[] {LocaleUtil.SPAIN}, LocaleUtil.SPAIN);

      DLFileEntryType dlFileEntryType =
          DLFileEntryTypeLocalServiceUtil.addFileEntryType(
              TestPropsValues.getUserId(),
              group.getGroupId(),
              name,
              description,
              new long[] {ddmStructure.getStructureId()},
              serviceContext);

      Assert.assertEquals(name, dlFileEntryType.getName(LocaleUtil.US, true));
      Assert.assertEquals(description, dlFileEntryType.getDescription(LocaleUtil.US, true));
    } finally {
      LocaleThreadLocal.setSiteDefaultLocale(locale);
    }
  }
  protected MDRRuleGroup addMDRRuleGroup() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MDRRuleGroup mdrRuleGroup = _persistence.create(pk);

    mdrRuleGroup.setUuid(RandomTestUtil.randomString());

    mdrRuleGroup.setGroupId(RandomTestUtil.nextLong());

    mdrRuleGroup.setCompanyId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserId(RandomTestUtil.nextLong());

    mdrRuleGroup.setUserName(RandomTestUtil.randomString());

    mdrRuleGroup.setCreateDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setModifiedDate(RandomTestUtil.nextDate());

    mdrRuleGroup.setName(RandomTestUtil.randomString());

    mdrRuleGroup.setDescription(RandomTestUtil.randomString());

    _persistence.update(mdrRuleGroup);

    return mdrRuleGroup;
  }
  protected Team addTeam() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Team team = _persistence.create(pk);

    team.setMvccVersion(RandomTestUtil.nextLong());

    team.setCompanyId(RandomTestUtil.nextLong());

    team.setUserId(RandomTestUtil.nextLong());

    team.setUserName(RandomTestUtil.randomString());

    team.setCreateDate(RandomTestUtil.nextDate());

    team.setModifiedDate(RandomTestUtil.nextDate());

    team.setGroupId(RandomTestUtil.nextLong());

    team.setName(RandomTestUtil.randomString());

    team.setDescription(RandomTestUtil.randomString());

    _teams.add(_persistence.update(team));

    return team;
  }
  @Test
  public void testAddSubfolder() throws Exception {
    BookmarksFolder folder =
        BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksTestUtil.addFolder(
        _group.getGroupId(), folder.getFolderId(), RandomTestUtil.randomString());
  }
 @Test
 public void testCountByU_CArrayable() {
   try {
     _persistence.countByU_C(
         RandomTestUtil.nextLong(), new long[] {RandomTestUtil.nextLong(), 0L});
   } catch (Exception e) {
     Assert.fail(e.getMessage());
   }
 }
  @Test
  public void testCountByL_P() {
    try {
      _persistence.countByL_P(RandomTestUtil.nextDate(), RandomTestUtil.nextDouble());

      _persistence.countByL_P(RandomTestUtil.nextDate(), 0D);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  @Test
  public void testCountByTempImage() {
    try {
      _persistence.countByTempImage(RandomTestUtil.randomBoolean());

      _persistence.countByTempImage(RandomTestUtil.randomBoolean());
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  @Test
  public void testCountByT_A() {
    try {
      _persistence.countByT_A(RandomTestUtil.nextLong(), RandomTestUtil.randomBoolean());

      _persistence.countByT_A(0L, RandomTestUtil.randomBoolean());
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  @Test
  public void testFetchByPrimaryKeyMissing() throws Exception {
    OrgGroupRolePK pk =
        new OrgGroupRolePK(
            RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), RandomTestUtil.nextLong());

    OrgGroupRole missingOrgGroupRole = _persistence.fetchByPrimaryKey(pk);

    Assert.assertNull(missingOrgGroupRole);
  }
  @Test
  public void testCountByG_B() {
    try {
      _persistence.countByG_B(RandomTestUtil.nextLong(), RandomTestUtil.nextLong());

      _persistence.countByG_B(0L, 0L);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  protected MBBan addMBBan() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan mbBan = _persistence.create(pk);

    mbBan.setUuid(RandomTestUtil.randomString());

    mbBan.setGroupId(RandomTestUtil.nextLong());

    mbBan.setCompanyId(RandomTestUtil.nextLong());

    mbBan.setUserId(RandomTestUtil.nextLong());

    mbBan.setUserName(RandomTestUtil.randomString());

    mbBan.setCreateDate(RandomTestUtil.nextDate());

    mbBan.setModifiedDate(RandomTestUtil.nextDate());

    mbBan.setBanUserId(RandomTestUtil.nextLong());

    _mbBans.add(_persistence.update(mbBan));

    return mbBan;
  }
  @Test
  public void testCountByC_V_ST() {
    try {
      _persistence.countByC_V_ST(
          RandomTestUtil.nextLong(), RandomTestUtil.nextDouble(), RandomTestUtil.nextInt());

      _persistence.countByC_V_ST(0L, 0D, 0);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
 @Test
 public void testCountByG_A_STArrayable() {
   try {
     _persistence.countByG_A_ST(
         RandomTestUtil.nextLong(),
         RandomTestUtil.randomString(),
         new int[] {RandomTestUtil.nextInt(), 0});
   } catch (Exception e) {
     Assert.fail(e.getMessage());
   }
 }
  @Test
  public void testCreate() throws Exception {
    OrgGroupRolePK pk =
        new OrgGroupRolePK(
            RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), RandomTestUtil.nextLong());

    OrgGroupRole orgGroupRole = _persistence.create(pk);

    Assert.assertNotNull(orgGroupRole);

    Assert.assertEquals(orgGroupRole.getPrimaryKey(), pk);
  }
 @Test
 public void testCountByT_NArrayable() {
   try {
     _persistence.countByT_N(
         RandomTestUtil.nextLong(),
         new String[] {
           RandomTestUtil.randomString(), StringPool.BLANK, StringPool.NULL, null, null
         });
   } catch (Exception e) {
     Assert.fail(e.getMessage());
   }
 }
  @Test
  public void testCountByG_T_R() {
    try {
      _persistence.countByG_T_R(
          RandomTestUtil.nextLong(), StringPool.BLANK, RandomTestUtil.randomBoolean());

      _persistence.countByG_T_R(0L, StringPool.NULL, RandomTestUtil.randomBoolean());

      _persistence.countByG_T_R(0L, (String) null, RandomTestUtil.randomBoolean());
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  @Test
  public void testCountByG_F_T_V() {
    try {
      _persistence.countByG_F_T_V(
          RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), StringPool.BLANK, StringPool.BLANK);

      _persistence.countByG_F_T_V(0L, 0L, StringPool.NULL, StringPool.NULL);

      _persistence.countByG_F_T_V(0L, 0L, (String) null, (String) null);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
  @Test
  public void testFindByPrimaryKeyMissing() throws Exception {
    OrgGroupRolePK pk =
        new OrgGroupRolePK(
            RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), RandomTestUtil.nextLong());

    try {
      _persistence.findByPrimaryKey(pk);

      Assert.fail("Missing entity did not throw NoSuchOrgGroupRoleException");
    } catch (NoSuchOrgGroupRoleException nsee) {
    }
  }
  @Test
  public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(OrgGroupRole.class, OrgGroupRole.class.getClassLoader());

    dynamicQuery.add(RestrictionsFactoryUtil.eq("id.organizationId", RandomTestUtil.nextLong()));
    dynamicQuery.add(RestrictionsFactoryUtil.eq("id.groupId", RandomTestUtil.nextLong()));
    dynamicQuery.add(RestrictionsFactoryUtil.eq("id.roleId", RandomTestUtil.nextLong()));

    List<OrgGroupRole> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(0, result.size());
  }
  protected OrgGroupRole addOrgGroupRole() throws Exception {
    OrgGroupRolePK pk =
        new OrgGroupRolePK(
            RandomTestUtil.nextLong(), RandomTestUtil.nextLong(), RandomTestUtil.nextLong());

    OrgGroupRole orgGroupRole = _persistence.create(pk);

    orgGroupRole.setMvccVersion(RandomTestUtil.nextLong());

    _persistence.update(orgGroupRole);

    return orgGroupRole;
  }
  @Test
  public void testCountByG_A_NotST() {
    try {
      _persistence.countByG_A_NotST(
          RandomTestUtil.nextLong(), StringPool.BLANK, RandomTestUtil.nextInt());

      _persistence.countByG_A_NotST(0L, StringPool.NULL, 0);

      _persistence.countByG_A_NotST(0L, (String) null, 0);
    } catch (Exception e) {
      Assert.fail(e.getMessage());
    }
  }
Ejemplo n.º 22
0
  protected void searchRecentEntries() throws Exception {
    long initialSearchGroupEntriesCount = searchGroupEntriesCount(group.getGroupId(), 0);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    BaseModel<?> parentBaseModel1 = getParentBaseModel(group, serviceContext);
    BaseModel<?> parentBaseModel2 = getParentBaseModel(group, serviceContext);

    String name = PrincipalThreadLocal.getName();

    try {
      User user1 = UserTestUtil.addUser(null, 0);

      PrincipalThreadLocal.setName(user1.getUserId());

      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel2, true, RandomTestUtil.randomString(), serviceContext);

      User user2 = UserTestUtil.addUser(null, 0);

      PrincipalThreadLocal.setName(user2.getUserId());

      baseModel =
          addBaseModel(parentBaseModel1, true, RandomTestUtil.randomString(), serviceContext);
      baseModel =
          addBaseModel(parentBaseModel2, true, RandomTestUtil.randomString(), serviceContext);
    } finally {
      PrincipalThreadLocal.setName(name);
    }

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 5, searchGroupEntriesCount(group.getGroupId(), 0));

    moveParentBaseModelToTrash((Long) parentBaseModel2.getPrimaryKeyObj());

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 3, searchGroupEntriesCount(group.getGroupId(), 0));

    TrashHandler parentTrashHandler =
        TrashHandlerRegistryUtil.getTrashHandler(getParentBaseModelClassName());

    parentTrashHandler.restoreTrashEntry(
        TestPropsValues.getUserId(), (Long) parentBaseModel2.getPrimaryKeyObj());

    Assert.assertEquals(
        initialSearchGroupEntriesCount + 5, searchGroupEntriesCount(group.getGroupId(), 0));
  }
  @Override
  protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext)
      throws Exception {

    serviceContext = (ServiceContext) serviceContext.clone();

    serviceContext.setWorkflowAction(WorkflowConstants.STATUS_APPROVED);

    return WikiNodeLocalServiceUtil.addNode(
        TestPropsValues.getUserId(),
        RandomTestUtil.randomString(_NODE_NAME_MAX_LENGTH),
        RandomTestUtil.randomString(),
        serviceContext);
  }
  @Before
  public void setUp() throws Exception {
    group = GroupTestUtil.addGroup();
    importedGroup = GroupTestUtil.addGroup();

    layout = LayoutTestUtil.addLayout(group.getGroupId(), RandomTestUtil.randomString());

    // Delete and readd to ensure a different layout ID (not ID or UUID).
    // See LPS-32132.

    LayoutLocalServiceUtil.deleteLayout(layout, true, new ServiceContext());

    layout = LayoutTestUtil.addLayout(group.getGroupId(), RandomTestUtil.randomString());
  }
  protected void testRevertPage(boolean hasExpandoValues) throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    String originalContent = RandomTestUtil.randomString();

    WikiPage originalPage =
        WikiTestUtil.addPage(
            TestPropsValues.getUserId(),
            _node.getNodeId(),
            RandomTestUtil.randomString(),
            originalContent,
            true,
            serviceContext);

    if (hasExpandoValues) {
      addExpandoValueToPage(originalPage);
    }

    WikiPage updatedPage1 =
        WikiTestUtil.updatePage(
            originalPage,
            TestPropsValues.getUserId(),
            originalContent + "\nAdded second line.",
            serviceContext);

    Assert.assertNotEquals(originalContent, updatedPage1.getContent());

    WikiPage updatedPage2 =
        WikiTestUtil.updatePage(
            updatedPage1,
            TestPropsValues.getUserId(),
            updatedPage1.getContent() + "\nAdded third line.",
            serviceContext);

    Assert.assertNotEquals(originalContent, updatedPage2.getContent());

    WikiPage revertedPage =
        WikiPageLocalServiceUtil.revertPage(
            TestPropsValues.getUserId(),
            _node.getNodeId(),
            updatedPage2.getTitle(),
            originalPage.getVersion(),
            serviceContext);

    Assert.assertEquals(revertedPage.getContent(), originalContent);

    checkPopulatedServiceContext(serviceContext, revertedPage, hasExpandoValues);
  }
  @Test(expected = NoSuchRepositoryEntryException.class)
  public void testCreateLocalRepositoryFromNonexistentFileVersionId() throws Exception {

    long fileVersionId = RandomTestUtil.randomLong();

    RepositoryLocalServiceUtil.getLocalRepositoryImpl(0, 0, fileVersionId);
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist()
      throws Exception {
    long pk1 = RandomTestUtil.nextLong();

    long pk2 = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(pk1);
    primaryKeys.add(pk2);

    Map<Serializable, MBBan> mbBans = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertTrue(mbBans.isEmpty());
  }
  @Test(expected = NoSuchRepositoryEntryException.class)
  public void testCreateLocalRepositoryFromInvalidFolderId() throws Exception {

    long folderId = RandomTestUtil.randomLong();

    RepositoryLocalServiceUtil.getLocalRepositoryImpl(folderId, 0, 0);
  }
Ejemplo n.º 29
0
  @Test
  public void testCreateRepositoryFromNonexistentRepositoryId() throws Exception {

    long repositoryId = RandomTestUtil.randomLong();

    RepositoryFactoryUtil.create(repositoryId);
  }
Ejemplo n.º 30
0
  @Test(expected = NoSuchRepositoryEntryException.class)
  public void testCreateRepositoryFromNonexistentFileVersionId() throws Exception {

    long fileVersionId = RandomTestUtil.randomLong();

    RepositoryFactoryUtil.create(0, 0, fileVersionId);
  }