@Test @Transactional public void testExportImportLayoutSetPrototypeInvalidLARType() throws Exception { // Import LayoutSetPrototype to LayoutSet LayoutSetPrototype layoutSetPrototype = LayoutTestUtil.addLayoutSetPrototype(ServiceTestUtil.randomString()); group = layoutSetPrototype.getGroup(); importedGroup = GroupTestUtil.addGroup(); long[] layoutIds = new long[0]; try { exportImportLayouts(layoutIds, getImportParameterMap()); Assert.fail(); } catch (LARTypeException lte) { } // Import LayoutSetPrototype to LayoutPrototyope LayoutPrototype layoutPrototype = LayoutTestUtil.addLayoutPrototype(ServiceTestUtil.randomString()); importedGroup = layoutPrototype.getGroup(); try { exportImportLayouts(layoutIds, getImportParameterMap()); Assert.fail(); } catch (LARTypeException lte) { } }
protected Release addRelease() throws Exception { long pk = ServiceTestUtil.nextLong(); Release release = _persistence.create(pk); release.setMvccVersion(ServiceTestUtil.nextLong()); release.setCreateDate(ServiceTestUtil.nextDate()); release.setModifiedDate(ServiceTestUtil.nextDate()); release.setServletContextName(ServiceTestUtil.randomString()); release.setBuildNumber(ServiceTestUtil.nextInt()); release.setBuildDate(ServiceTestUtil.nextDate()); release.setVerified(ServiceTestUtil.randomBoolean()); release.setState(ServiceTestUtil.nextInt()); release.setTestString(ServiceTestUtil.randomString()); _persistence.update(release); return release; }
protected MDRRuleGroup addMDRRuleGroup() throws Exception { long pk = ServiceTestUtil.nextLong(); MDRRuleGroup mdrRuleGroup = _persistence.create(pk); mdrRuleGroup.setUuid(ServiceTestUtil.randomString()); mdrRuleGroup.setGroupId(ServiceTestUtil.nextLong()); mdrRuleGroup.setCompanyId(ServiceTestUtil.nextLong()); mdrRuleGroup.setUserId(ServiceTestUtil.nextLong()); mdrRuleGroup.setUserName(ServiceTestUtil.randomString()); mdrRuleGroup.setCreateDate(ServiceTestUtil.nextDate()); mdrRuleGroup.setModifiedDate(ServiceTestUtil.nextDate()); mdrRuleGroup.setName(ServiceTestUtil.randomString()); mdrRuleGroup.setDescription(ServiceTestUtil.randomString()); _persistence.update(mdrRuleGroup, false); return mdrRuleGroup; }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); DDMStructureLink newDDMStructureLink = _persistence.create(pk); newDDMStructureLink.setClassNameId(ServiceTestUtil.nextLong()); newDDMStructureLink.setClassPK(ServiceTestUtil.nextLong()); newDDMStructureLink.setStructureId(ServiceTestUtil.nextLong()); _persistence.update(newDDMStructureLink); DDMStructureLink existingDDMStructureLink = _persistence.findByPrimaryKey(newDDMStructureLink.getPrimaryKey()); Assert.assertEquals( existingDDMStructureLink.getStructureLinkId(), newDDMStructureLink.getStructureLinkId()); Assert.assertEquals( existingDDMStructureLink.getClassNameId(), newDDMStructureLink.getClassNameId()); Assert.assertEquals(existingDDMStructureLink.getClassPK(), newDDMStructureLink.getClassPK()); Assert.assertEquals( existingDDMStructureLink.getStructureId(), newDDMStructureLink.getStructureId()); }
@Before public void setUp() throws Exception { FinderCacheUtil.clearCache(); ServiceContextThreadLocal.pushServiceContext(ServiceTestUtil.getServiceContext()); // Group group = GroupTestUtil.addGroup(); // Global scope article Company company = CompanyUtil.fetchByPrimaryKey(group.getCompanyId()); globalGroupId = company.getGroupId(); globalJournalArticle = JournalTestUtil.addArticle(globalGroupId, "Global Article", "Global Content"); // Layout prototype layoutPrototype = LayoutTestUtil.addLayoutPrototype(ServiceTestUtil.randomString()); layoutPrototypeLayout = layoutPrototype.getLayout(); LayoutTestUtil.updateLayoutTemplateId(layoutPrototypeLayout, initialLayoutTemplateId); doSetUp(); }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); ExpandoRow newExpandoRow = _persistence.create(pk); newExpandoRow.setCompanyId(ServiceTestUtil.nextLong()); newExpandoRow.setModifiedDate(ServiceTestUtil.nextDate()); newExpandoRow.setTableId(ServiceTestUtil.nextLong()); newExpandoRow.setClassPK(ServiceTestUtil.nextLong()); _persistence.update(newExpandoRow); ExpandoRow existingExpandoRow = _persistence.findByPrimaryKey(newExpandoRow.getPrimaryKey()); Assert.assertEquals(existingExpandoRow.getRowId(), newExpandoRow.getRowId()); Assert.assertEquals(existingExpandoRow.getCompanyId(), newExpandoRow.getCompanyId()); Assert.assertEquals( Time.getShortTimestamp(existingExpandoRow.getModifiedDate()), Time.getShortTimestamp(newExpandoRow.getModifiedDate())); Assert.assertEquals(existingExpandoRow.getTableId(), newExpandoRow.getTableId()); Assert.assertEquals(existingExpandoRow.getClassPK(), newExpandoRow.getClassPK()); }
protected ShoppingItemPrice addShoppingItemPrice() throws Exception { long pk = ServiceTestUtil.nextLong(); ShoppingItemPrice shoppingItemPrice = _persistence.create(pk); shoppingItemPrice.setItemId(ServiceTestUtil.nextLong()); shoppingItemPrice.setMinQuantity(ServiceTestUtil.nextInt()); shoppingItemPrice.setMaxQuantity(ServiceTestUtil.nextInt()); shoppingItemPrice.setPrice(ServiceTestUtil.nextDouble()); shoppingItemPrice.setDiscount(ServiceTestUtil.nextDouble()); shoppingItemPrice.setTaxable(ServiceTestUtil.randomBoolean()); shoppingItemPrice.setShipping(ServiceTestUtil.nextDouble()); shoppingItemPrice.setUseShippingFormula(ServiceTestUtil.randomBoolean()); shoppingItemPrice.setStatus(ServiceTestUtil.nextInt()); _persistence.update(shoppingItemPrice); return shoppingItemPrice; }
protected void searchComments() throws Exception { ServiceContext serviceContext = ServiceTestUtil.getServiceContext(); serviceContext.setScopeGroupId(group.getGroupId()); SearchContext searchContext = ServiceTestUtil.getSearchContext(); searchContext.setIncludeDiscussions(true); BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext); int initialBaseModelsSearchCount = searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext); baseModel = addBaseModel(parentBaseModel, true, serviceContext); Assert.assertEquals( initialBaseModelsSearchCount + 1, searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext)); addComment(baseModel, getSearchKeywords(), serviceContext); Assert.assertEquals( initialBaseModelsSearchCount + 2, searchBaseModelsCount(getBaseModelClass(), group.getGroupId(), searchContext)); }
protected void trashFileEntry() throws Exception { Group group = ServiceTestUtil.addGroup(); ServiceContext serviceContext = ServiceTestUtil.getServiceContext(); serviceContext.setScopeGroupId(group.getGroupId()); BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext); int initialBaseModelsCount = getBaseModelsNotInTrashCount(parentBaseModel); int initialTrashEntriesCount = getTrashEntriesCount(group.getGroupId()); BaseModel<?> baseModel = addBaseModel(parentBaseModel, true, serviceContext); DLFileShortcut dlFileShortcut = (DLFileShortcut) baseModel; FileEntry fileEntry = DLAppServiceUtil.getFileEntry(dlFileShortcut.getToFileEntryId()); Assert.assertEquals(initialBaseModelsCount + 1, getBaseModelsNotInTrashCount(parentBaseModel)); Assert.assertEquals(initialTrashEntriesCount, getTrashEntriesCount(group.getGroupId())); DLAppServiceUtil.moveFileEntryToTrash(fileEntry.getFileEntryId()); Assert.assertEquals(initialBaseModelsCount, getBaseModelsNotInTrashCount(parentBaseModel)); Assert.assertEquals(initialTrashEntriesCount + 1, getTrashEntriesCount(group.getGroupId())); DLAppServiceUtil.restoreFileEntryFromTrash(fileEntry.getFileEntryId()); Assert.assertEquals(initialBaseModelsCount + 1, getBaseModelsNotInTrashCount(parentBaseModel)); }
protected Group addScopeGroup() throws Exception { Group group = GroupTestUtil.addGroup(); Layout layout = LayoutTestUtil.addLayout(group.getGroupId(), ServiceTestUtil.randomString()); String name = ServiceTestUtil.randomString(); ServiceContext serviceContext = ServiceTestUtil.getServiceContext(group.getGroupId()); Group scopeGroup = GroupLocalServiceUtil.addGroup( TestPropsValues.getUserId(), group.getParentGroupId(), Layout.class.getName(), layout.getPlid(), GroupConstants.DEFAULT_LIVE_GROUP_ID, name, ServiceTestUtil.randomString(), GroupConstants.TYPE_SITE_OPEN, true, GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(name), false, true, serviceContext); return scopeGroup; }
@Override protected void renameModels() throws Exception { DLAppServiceUtil.updateFolder( _folder.getFolderId(), ServiceTestUtil.randomString(), ServiceTestUtil.randomString(), serviceContext); }
@Test public void testCountByG_FArrayable() { try { _persistence.countByG_F( ServiceTestUtil.nextLong(), new long[] {ServiceTestUtil.nextLong(), 0L}); } catch (Exception e) { Assert.fail(e.getMessage()); } }
protected void addBlogsEntry(long groupId, String assetTagName) throws Exception { ServiceContext serviceContext = ServiceTestUtil.getServiceContext(groupId); serviceContext.setAssetTagNames(new String[] {assetTagName}); BlogsTestUtil.addEntry( TestPropsValues.getUserId(), ServiceTestUtil.randomString(), true, serviceContext); }
@Test public void testCountByLtD_S() { try { _persistence.countByLtD_S(ServiceTestUtil.nextDate(), ServiceTestUtil.nextInt()); _persistence.countByLtD_S(ServiceTestUtil.nextDate(), 0); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void testCountByC_L() { try { _persistence.countByC_L(ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong()); _persistence.countByC_L(0L, 0L); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void testFetchByPrimaryKeyMissing() throws Exception { OrgGroupRolePK pk = new OrgGroupRolePK( ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong()); OrgGroupRole missingOrgGroupRole = _persistence.fetchByPrimaryKey(pk); Assert.assertNull(missingOrgGroupRole); }
@Test public void testCountByG_F() { try { _persistence.countByG_F(ServiceTestUtil.nextLong(), ServiceTestUtil.randomBoolean()); _persistence.countByG_F(0L, ServiceTestUtil.randomBoolean()); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Override protected long addContainerModel(long containerModelId) throws Exception { ServiceContext serviceContext = ServiceTestUtil.getServiceContext(group.getGroupId()); BookmarksFolder folder = BookmarksTestUtil.addFolder( containerModelId, ServiceTestUtil.randomString(), serviceContext); return folder.getFolderId(); }
@Test public void testCountByC_V_ST() { try { _persistence.countByC_V_ST( ServiceTestUtil.nextLong(), ServiceTestUtil.nextDouble(), ServiceTestUtil.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( ServiceTestUtil.nextLong(), ServiceTestUtil.randomString(), new int[] {ServiceTestUtil.nextInt(), 0}); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void testCreate() throws Exception { OrgGroupRolePK pk = new OrgGroupRolePK( ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong()); OrgGroupRole orgGroupRole = _persistence.create(pk); Assert.assertNotNull(orgGroupRole); Assert.assertEquals(orgGroupRole.getPrimaryKey(), pk); }
protected OrgGroupRole addOrgGroupRole() throws Exception { OrgGroupRolePK pk = new OrgGroupRolePK( ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong()); OrgGroupRole orgGroupRole = _persistence.create(pk); orgGroupRole.setMvccVersion(ServiceTestUtil.nextLong()); _persistence.update(orgGroupRole); return orgGroupRole; }
@Test public void testDynamicQueryByPrimaryKeyMissing() throws Exception { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(OrgGroupRole.class, OrgGroupRole.class.getClassLoader()); dynamicQuery.add(RestrictionsFactoryUtil.eq("id.organizationId", ServiceTestUtil.nextLong())); dynamicQuery.add(RestrictionsFactoryUtil.eq("id.groupId", ServiceTestUtil.nextLong())); dynamicQuery.add(RestrictionsFactoryUtil.eq("id.roleId", ServiceTestUtil.nextLong())); List<OrgGroupRole> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(0, result.size()); }
@Test public void testCountByG_U_N() { try { _persistence.countByG_U_N( ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong(), StringPool.BLANK); _persistence.countByG_U_N(0L, 0L, StringPool.NULL); _persistence.countByG_U_N(0L, 0L, (String) null); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void testFindByPrimaryKeyMissing() throws Exception { OrgGroupRolePK pk = new OrgGroupRolePK( ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong(), ServiceTestUtil.nextLong()); try { _persistence.findByPrimaryKey(pk); Assert.fail("Missing entity did not throw NoSuchOrgGroupRoleException"); } catch (NoSuchOrgGroupRoleException nsee) { } }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); Country newCountry = _persistence.create(pk); newCountry.setName(ServiceTestUtil.randomString()); newCountry.setA2(ServiceTestUtil.randomString()); newCountry.setA3(ServiceTestUtil.randomString()); newCountry.setNumber(ServiceTestUtil.randomString()); newCountry.setIdd(ServiceTestUtil.randomString()); newCountry.setZipRequired(ServiceTestUtil.randomBoolean()); newCountry.setActive(ServiceTestUtil.randomBoolean()); _persistence.update(newCountry, false); Country existingCountry = _persistence.findByPrimaryKey(newCountry.getPrimaryKey()); Assert.assertEquals(existingCountry.getCountryId(), newCountry.getCountryId()); Assert.assertEquals(existingCountry.getName(), newCountry.getName()); Assert.assertEquals(existingCountry.getA2(), newCountry.getA2()); Assert.assertEquals(existingCountry.getA3(), newCountry.getA3()); Assert.assertEquals(existingCountry.getNumber(), newCountry.getNumber()); Assert.assertEquals(existingCountry.getIdd(), newCountry.getIdd()); Assert.assertEquals(existingCountry.getZipRequired(), newCountry.getZipRequired()); Assert.assertEquals(existingCountry.getActive(), newCountry.getActive()); }
protected DDMStructureLink addDDMStructureLink() throws Exception { long pk = ServiceTestUtil.nextLong(); DDMStructureLink ddmStructureLink = _persistence.create(pk); ddmStructureLink.setClassNameId(ServiceTestUtil.nextLong()); ddmStructureLink.setClassPK(ServiceTestUtil.nextLong()); ddmStructureLink.setStructureId(ServiceTestUtil.nextLong()); _persistence.update(ddmStructureLink); return ddmStructureLink; }
@Test public void testFilterFindByG_N() throws Exception { Group scopeGroup = addScopeGroup(); Group siteGroup = scopeGroup.getParentGroup(); String assetTagName = ServiceTestUtil.randomString(); addAssetTag(siteGroup.getGroupId(), assetTagName, null); User user = UserTestUtil.addUser(null, 0); PermissionChecker originalPermissionChecker = PermissionThreadLocal.getPermissionChecker(); try { PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); try { AssetTagFinderUtil.filterFindByG_N(scopeGroup.getGroupId(), assetTagName); Assert.fail(); } catch (NoSuchTagException nste) { } AssetTag siteGroupAssetTag = AssetTagFinderUtil.filterFindByG_N(siteGroup.getGroupId(), assetTagName); Assert.assertEquals(StringUtil.toLowerCase(assetTagName), siteGroupAssetTag.getName()); } finally { PermissionThreadLocal.setPermissionChecker(originalPermissionChecker); } }
protected void testAvailableLocales( Locale[] sourceAvailableLocales, Locale[] targetAvailableLocales, boolean expectFailure) throws Exception { group = GroupTestUtil.updateDisplaySettings(group.getGroupId(), sourceAvailableLocales, null); importedGroup = GroupTestUtil.updateDisplaySettings( importedGroup.getGroupId(), targetAvailableLocales, null); LayoutTestUtil.addLayout(group.getGroupId(), ServiceTestUtil.randomString()); long[] layoutIds = new long[0]; try { exportImportLayouts(layoutIds, getImportParameterMap()); if (expectFailure) { Assert.fail(); } } catch (LocaleException le) { if (!expectFailure) { Assert.fail(); } } }
@Before public void setUp() throws Exception { _group = ServiceTestUtil.addGroup(); String name = "Test Folder"; String description = "This is a test folder."; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(_group.getGroupId()); try { DLAppServiceHttp.deleteFolder( TestPropsValues.getHttpPrincipal(), _group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, name); } catch (Exception e) { } _folder = DLAppServiceHttp.addFolder( TestPropsValues.getHttpPrincipal(), _group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, name, description, serviceContext); }