List of usage examples for com.liferay.portal.kernel.test.util GroupTestUtil addGroup
public static Group addGroup(long parentGroupId) throws Exception
From source file:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java
License:Open Source License
@Test public void testChildLayoutScopeIds() throws Exception { Map<String, String[]> preferenceMap = new HashMap<>(); Group childGroup = GroupTestUtil.addGroup(group.getGroupId()); preferenceMap.put("scopeIds", new String[] { AssetPublisherHelper.SCOPE_ID_CHILD_GROUP_PREFIX + childGroup.getGroupId() }); try {//from ww w . j av a 2 s. c om PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap); Assert.assertEquals(null, portletPreferences.getValue("scopeId", null)); Assert.assertTrue("The child group ID should have been filtered out on import", ArrayUtil.isEmpty(portletPreferences.getValues("scopeIds", null))); } finally { GroupLocalServiceUtil.deleteGroup(childGroup); } }
From source file:com.liferay.dynamic.data.lists.service.test.DDLRecordServiceTest.java
License:Open Source License
@Test(expected = RecordGroupIdException.class) public void testAddRecordWithDifferentGroupIdFromRecordSet() throws Exception { long groupId = RandomTestUtil.nextLong(); DDMForm ddmForm = DDMFormTestUtil.createDDMForm("Field"); DDLRecordSet ddlRecordSet = addRecordSet(ddmForm); DDLRecordTestHelper ddlRecordTestHelper = new DDLRecordTestHelper(GroupTestUtil.addGroup(groupId), ddlRecordSet);//from w w w . ja v a 2 s . c om ddlRecordTestHelper.addRecord(); }
From source file:com.liferay.dynamic.data.mapping.service.test.DDMTemplateServiceTest.java
License:Open Source License
@Test public void testGetTemplatesByIncludeAncestorTemplates() throws Exception { Group childGroup = GroupTestUtil.addGroup(group.getGroupId()); DDMStructure structure = addStructure(_recordSetClassNameId, StringUtil.randomString()); addDisplayTemplate(structure.getStructureId(), StringUtil.randomString(), WorkflowConstants.STATUS_ANY); addDisplayTemplate(structure.getStructureId(), StringUtil.randomString(), WorkflowConstants.STATUS_ANY); List<DDMTemplate> templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(), childGroup.getGroupId(), _structureClassNameId, structure.getStructureId(), _recordSetClassNameId, true, WorkflowConstants.STATUS_ANY); Assert.assertEquals(templates.toString(), 2, templates.size()); templates = DDMTemplateServiceUtil.getTemplates(TestPropsValues.getCompanyId(), childGroup.getGroupId(), _structureClassNameId, structure.getStructureId(), _recordSetClassNameId, false, WorkflowConstants.STATUS_ANY); Assert.assertEquals(templates.toString(), 0, templates.size()); GroupLocalServiceUtil.deleteGroup(childGroup); }
From source file:com.liferay.site.service.persistence.test.GroupLocalServiceTreeTest.java
License:Open Source License
@Override protected TreeModel addTreeModel(TreeModel parentTreeModel) throws Exception { long parentGroupId = GroupConstants.DEFAULT_PARENT_GROUP_ID; if (parentTreeModel != null) { Group group = (Group) parentTreeModel; parentGroupId = group.getGroupId(); }//from ww w . ja v a 2s .c om Group group = GroupTestUtil.addGroup(parentGroupId); group.setTreePath(null); return GroupLocalServiceUtil.updateGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testFindGroupByDescription() throws Exception { Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("manualMembership", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, group.getDescription(getLocale()), groupParams)); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testFindGroupByDescriptionWithSpaces() throws Exception { Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); group.setDescription(RandomTestUtil.randomString() + StringPool.SPACE + RandomTestUtil.randomString()); GroupLocalServiceUtil.updateGroup(group); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("manualMembership", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, group.getDescription(getLocale()), groupParams)); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testFindGroupByName() throws Exception { Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("manualMembership", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, group.getName(getLocale()), groupParams)); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testFindGroupByNameWithSpaces() throws Exception { Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); group.setName(RandomTestUtil.randomString() + StringPool.SPACE + RandomTestUtil.randomString()); GroupLocalServiceUtil.updateGroup(group); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("manualMembership", Boolean.TRUE); groupParams.put("site", Boolean.TRUE); Assert.assertEquals(1, GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, group.getName(getLocale()), groupParams)); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
@Test public void testFindGroupByRole() throws Exception { Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); long roleId = RoleTestUtil.addGroupRole(group.getGroupId()); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("groupsRoles", Long.valueOf(roleId)); groupParams.put("site", Boolean.TRUE); Assert.assertEquals(1,// w w w . j a v a 2s. c o m GroupLocalServiceUtil.searchCount(TestPropsValues.getCompanyId(), null, groupParams)); List<Group> groups = GroupLocalServiceUtil.search(TestPropsValues.getCompanyId(), null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS); Assert.assertEquals(groups.toString(), 1, groups.size()); Assert.assertEquals(group, groups.get(0)); Assert.assertEquals(1, GroupLocalServiceUtil.getRoleGroupsCount(roleId)); groups = GroupLocalServiceUtil.getRoleGroups(roleId); Assert.assertEquals(groups.toString(), 1, groups.size()); Assert.assertEquals(group, groups.get(0)); GroupLocalServiceUtil.deleteGroup(group); }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
protected void testUpdateDisplaySettings(Collection<Locale> portalAvailableLocales, Collection<Locale> groupAvailableLocales, Locale groupDefaultLocale, boolean expectFailure) throws Exception { Set<Locale> availableLocales = LanguageUtil.getAvailableLocales(); CompanyTestUtil.resetCompanyLocales(TestPropsValues.getCompanyId(), portalAvailableLocales, LocaleUtil.getDefault());//from ww w. ja v a 2s . c o m Group group = GroupTestUtil.addGroup(GroupConstants.DEFAULT_PARENT_GROUP_ID); try { GroupTestUtil.updateDisplaySettings(group.getGroupId(), groupAvailableLocales, groupDefaultLocale); Assert.assertFalse(expectFailure); } catch (LocaleException le) { Assert.assertTrue(expectFailure); } finally { CompanyTestUtil.resetCompanyLocales(TestPropsValues.getCompanyId(), availableLocales, LocaleUtil.getDefault()); } GroupLocalServiceUtil.deleteGroup(group); }