List of usage examples for com.liferay.portal.kernel.test.util UserTestUtil addUser
public static User addUser(long... groupIds) throws Exception
From source file:com.liferay.asset.search.test.AssetSearcherStagingTest.java
License:Open Source License
protected User addUser() throws Exception { User user = UserTestUtil.addUser(_group.getGroupId()); _users.add(user); return user; }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Before public void setUp() throws Exception { group = GroupTestUtil.addGroup();/*from w w w.j a va 2 s . com*/ user = UserTestUtil.addUser(group.getGroupId()); ServiceTestUtil.setUser(TestPropsValues.getUser()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(), user.getUserId()); entry = BlogsTestUtil.addEntryWithWorkflow(user.getUserId(), RandomTestUtil.randomString(), false, serviceContext); }
From source file:com.liferay.layout.type.controller.test.LayoutTypePortletTest.java
License:Open Source License
@Test public void testAddPortletIdCheckColumn() throws Exception { Layout layout = _layoutTypePortlet.getLayout(); _user = UserTestUtil.addUser(layout.getGroupId()); String portletId = PortletKeys.TEST; LayoutTemplate layoutTemplate = _layoutTypePortlet.getLayoutTemplate(); List<String> columns = layoutTemplate.getColumns(); String column1 = columns.get(0); Assert.assertEquals(columns.toString(), 2, columns.size()); portletId = _layoutTypePortlet.addPortletId(_user.getUserId(), portletId); Assert.assertNotNull(portletId);//from w ww. ja v a2 s. c o m List<Portlet> portlets = _layoutTypePortlet.getAllPortlets(column1); Assert.assertEquals(portlets.toString(), 1, portlets.size()); }
From source file:com.liferay.layout.type.controller.test.LayoutTypePortletTest.java
License:Open Source License
@Test public void testAddPortletIdColumn2() throws Exception { Layout layout = _layoutTypePortlet.getLayout(); _user = UserTestUtil.addUser(layout.getGroupId()); String portletId = PortletKeys.TEST; LayoutTemplate layoutTemplate = _layoutTypePortlet.getLayoutTemplate(); List<String> columns = layoutTemplate.getColumns(); Assert.assertEquals(columns.toString(), 2, columns.size()); String column1 = columns.get(0); String column2 = columns.get(1); portletId = _layoutTypePortlet.addPortletId(_user.getUserId(), portletId, column2, -1); Assert.assertNotNull(portletId);// ww w . ja v a 2 s . c o m List<Portlet> portlets = _layoutTypePortlet.getAllPortlets(column1); Assert.assertEquals(portlets.toString(), 0, portlets.size()); portlets = _layoutTypePortlet.getAllPortlets(column2); Assert.assertEquals(portlets.toString(), 1, portlets.size()); }
From source file:com.liferay.layout.type.controller.test.LayoutTypePortletTest.java
License:Open Source License
@Test public void testAddPortletIdWithInvalidId() throws Exception { Layout layout = _layoutTypePortlet.getLayout(); _user = UserTestUtil.addUser(layout.getGroupId()); String portletId = RandomTestUtil.randomString(); portletId = _layoutTypePortlet.addPortletId(_user.getUserId(), portletId); Assert.assertNull(portletId);/*from w ww.j ava2 s .c o m*/ }
From source file:com.liferay.layout.type.controller.test.LayoutTypePortletTest.java
License:Open Source License
@Test public void testAddPortletIdWithValidId() throws Exception { Layout layout = _layoutTypePortlet.getLayout(); _user = UserTestUtil.addUser(layout.getGroupId()); String portletId = PortletKeys.TEST; portletId = _layoutTypePortlet.addPortletId(_user.getUserId(), portletId); Assert.assertNotNull(portletId);//from w w w . java2s . com }
From source file:com.liferay.layout.type.controller.test.LayoutTypePortletTest.java
License:Open Source License
@Test public void testGetAllPortlets() throws Exception { Layout layout = _layoutTypePortlet.getLayout(); _user = UserTestUtil.addUser(layout.getGroupId()); List<Portlet> initialPortlets = _layoutTypePortlet.getAllPortlets(); int initialPortletsSize = initialPortlets.size(); final String portletId = _layoutTypePortlet.addPortletId(_user.getUserId(), PortletKeys.TEST); List<Portlet> portlets = _layoutTypePortlet.getAllPortlets(); Assert.assertEquals(portlets.toString(), initialPortletsSize + 1, portlets.size()); final long companyId = TestPropsValues.getCompanyId(); final PortletLocalService portletLocalService = PortletLocalServiceUtil.getService(); final Method getPortletByIdMethod = PortletLocalService.class.getMethod("getPortletById", long.class, String.class); ReflectionTestUtil.setFieldValue(PortletLocalServiceUtil.class, "_service", ProxyUtil.newProxyInstance(PortletLocalService.class.getClassLoader(), new Class<?>[] { PortletLocalService.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (getPortletByIdMethod.equals(method)) { Portlet portlet = (Portlet) method.invoke(portletLocalService, args); if ((companyId == (long) args[0]) && portletId.equals(args[1])) { portlet = (Portlet) portlet.clone(); portlet.setUndeployedPortlet(true); }/*ww w.ja v a2 s .co m*/ return portlet; } return method.invoke(portletLocalService, args); } })); try { portlets = _layoutTypePortlet.getAllPortlets(); Assert.assertEquals(portlets.toString(), initialPortletsSize + 1, portlets.size()); } finally { ReflectionTestUtil.setFieldValue(PortletLocalServiceUtil.class, "_service", portletLocalService); } }
From source file:com.liferay.message.boards.lar.test.MBBanStagedModelDataHandlerTest.java
License:Open Source License
@Override protected StagedModel addStagedModel(Group group, Map<String, List<StagedModel>> dependentStagedModelsMap) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(), TestPropsValues.getUserId()); User user = UserTestUtil.addUser(TestPropsValues.getGroupId()); return MBBanLocalServiceUtil.addBan(TestPropsValues.getUserId(), user.getUserId(), serviceContext); }
From source file:com.liferay.message.boards.lar.test.MBPortletDataHandlerTest.java
License:Open Source License
@Override protected void addStagedModels() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(), TestPropsValues.getUserId()); MBCategory category = MBCategoryServiceUtil.addCategory(TestPropsValues.getUserId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, RandomTestUtil.randomString(), StringPool.BLANK, serviceContext);//from www .j a va 2s. c o m serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); MBMessage message = MBMessageLocalServiceUtil.addMessage(TestPropsValues.getUserId(), RandomTestUtil.randomString(), stagingGroup.getGroupId(), category.getCategoryId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); MBThreadFlagLocalServiceUtil.addThreadFlag(TestPropsValues.getUserId(), message.getThread(), serviceContext); User user = UserTestUtil.addUser(TestPropsValues.getGroupId()); MBBanLocalServiceUtil.addBan(TestPropsValues.getUserId(), user.getUserId(), serviceContext); }
From source file:com.liferay.message.boards.service.test.MBMessageServiceTest.java
License:Open Source License
@Before public void setUp() throws Exception { String name = "Test Category"; String description = "This is a test category."; String displayStyle = MBCategoryConstants.DEFAULT_DISPLAY_STYLE; String emailAddress = null;/*from ww w. ja v a 2 s .c o m*/ String inProtocol = null; String inServerName = null; int inServerPort = 0; boolean inUseSSL = false; String inUserName = null; String inPassword = null; int inReadInterval = 0; String outEmailAddress = null; boolean outCustom = false; String outServerName = null; int outServerPort = 0; boolean outUseSSL = false; String outUserName = null; String outPassword = null; boolean allowAnonymous = false; boolean mailingListActive = false; _group = GroupTestUtil.addGroup(); for (int i = 0; i < ServiceTestUtil.THREAD_COUNT; i++) { UserTestUtil.addUser(_group.getGroupId()); } ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setGroupPermissions(new String[] { ActionKeys.ADD_MESSAGE, ActionKeys.VIEW }); serviceContext.setGuestPermissions(new String[] { ActionKeys.ADD_MESSAGE, ActionKeys.VIEW }); _category = MBCategoryServiceUtil.addCategory(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, name, description, displayStyle, emailAddress, inProtocol, inServerName, inServerPort, inUseSSL, inUserName, inPassword, inReadInterval, outEmailAddress, outCustom, outServerName, outServerPort, outUseSSL, outUserName, outPassword, allowAnonymous, mailingListActive, serviceContext); _userIds = UserLocalServiceUtil.getGroupUserIds(_group.getGroupId()); }