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

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

Introduction

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

Prototype

@SafeVarargs
    public static String randomString(RandomizerBumper<String>... randomizerBumpers) 

Source Link

Usage

From source file:com.liferay.calendar.service.test.CalendarResourceServiceTest.java

License:Open Source License

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

    User user = UserTestUtil.addGroupUser(group, RoleConstants.SITE_MEMBER);

    long classNameId = PortalUtil.getClassNameId(CalendarResource.class);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(),
            user.getUserId());//from   w  w  w.  ja  v  a2  s.  c om

    ModelPermissions modelPermissions = ModelPermissionsFactory.create(_CALENDAR_RESOURCE_GROUP_PERMISSIONS,
            null);

    serviceContext.setModelPermissions(modelPermissions);

    CalendarResource calendarResource = CalendarResourceLocalServiceUtil.addCalendarResource(user.getUserId(),
            user.getGroupId(), classNameId, 0, PortalUUIDUtil.generate(), RandomTestUtil.randomString(8),
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), true,
            serviceContext);

    Assert.assertNotNull(calendarResource);
}

From source file:com.liferay.calendar.service.test.CalendarResourceServiceTest.java

License:Open Source License

@Test
public void testSearchCount() throws Exception {
    long classNameId = PortalUtil.getClassNameId(CalendarResource.class);

    Map<Locale, String> nameMap = createNameMap();

    CalendarResourceLocalServiceUtil.addCalendarResource(_user.getUserId(), _user.getGroupId(), classNameId, 0,
            PortalUUIDUtil.generate(), RandomTestUtil.randomString(8), nameMap,
            RandomTestUtil.randomLocaleStringMap(), true, new ServiceContext());

    int count = CalendarResourceServiceUtil.searchCount(_user.getCompanyId(), new long[] { _user.getGroupId() },
            new long[] { classNameId }, nameMap.get(LocaleUtil.getDefault()), true);

    Assert.assertEquals(1, count);//www. j  a  v a2s .  com
}

From source file:com.liferay.document.library.file.rank.trash.test.DLFileRankTrashHandlerTest.java

License:Open Source License

protected Folder addFolder(Group group, long parentBaseModelId, ServiceContext serviceContext)
        throws Exception {

    return DLAppServiceUtil.addFolder(group.getGroupId(), parentBaseModelId,
            RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH), RandomTestUtil.randomString(),
            serviceContext);//from ww  w . ja v  a 2 s .  c  o m
}

From source file:com.liferay.document.library.search.test.DLFileEntrySearchTest.java

License:Open Source License

@Override
protected BaseModel<?> getParentBaseModel(BaseModel<?> parentBaseModel, ServiceContext serviceContext)
        throws Exception {

    Folder folder = DLAppServiceUtil.addFolder(serviceContext.getScopeGroupId(),
            (Long) parentBaseModel.getPrimaryKeyObj(), RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH),
            RandomTestUtil.randomString(), serviceContext);

    return (DLFolder) folder.getModel();
}

From source file:com.liferay.document.library.search.test.DLFileEntrySearchTest.java

License:Open Source License

@Override
protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext) throws Exception {

    Folder folder = DLAppServiceUtil.addFolder(serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH),
            RandomTestUtil.randomString(), serviceContext);

    return (DLFolder) folder.getModel();
}

From source file:com.liferay.document.library.trash.test.DLFileEntryTrashHandlerTest.java

License:Open Source License

@Override
protected BaseModel<?> getParentBaseModel(Group group, long parentBaseModelId, ServiceContext serviceContext)
        throws Exception {

    Folder folder = DLAppServiceUtil.addFolder(group.getGroupId(), parentBaseModelId,
            RandomTestUtil.randomString(_FOLDER_NAME_MAX_LENGTH), RandomTestUtil.randomString(),
            serviceContext);/*from  w w w  .ja  v a 2 s  .c  om*/

    return (DLFolder) folder.getModel();
}