List of usage examples for com.liferay.portal.kernel.test.util CompanyTestUtil addCompany
public static Company addCompany() throws Exception
From source file:com.liferay.adaptive.media.blogs.web.internal.counter.test.BlogsAMImageCounterTest.java
License:Open Source License
@Before public void setUp() throws Exception { _company1 = CompanyTestUtil.addCompany(); _user1 = UserTestUtil.getAdminUser(_company1.getCompanyId()); _group1 = GroupTestUtil.addGroup(_company1.getCompanyId(), _user1.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID); _company2 = CompanyTestUtil.addCompany(); _user2 = UserTestUtil.getAdminUser(_company2.getCompanyId()); _group2 = GroupTestUtil.addGroup(_company2.getCompanyId(), _user2.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID); }
From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.commands.test.AdaptiveMediaThumbnailsOSGiCommandsTest.java
License:Open Source License
@Before public void setUp() throws Exception { ServiceTestUtil.setUser(TestPropsValues.getUser()); _company = CompanyTestUtil.addCompany(); _user = UserTestUtil.addCompanyAdminUser(_company); _group = GroupTestUtil.addGroup(_company.getCompanyId(), _user.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID); _addConfiguration(100, 100);//from www. j av a 2s . c o m _addConfiguration(300, 300); _serviceContext = ServiceContextTestUtil.getServiceContext(_group, _user.getUserId()); ServiceContextThreadLocal.pushServiceContext(_serviceContext); }
From source file:com.liferay.adaptive.media.image.service.impl.test.AMImageEntryLocalServiceTest.java
License:Open Source License
@Test public void testGetExpectedAMImageEntriesCount() throws Exception { Company company = CompanyTestUtil.addCompany(); ServiceRegistration<AMImageCounter> amImageCounterServiceRegistration = null; try {//from w w w. j a v a2 s . c o m amImageCounterServiceRegistration = _registerAMImageCounter("test", 100); Assert.assertEquals(100, AMImageEntryLocalServiceUtil.getExpectedAMImageEntriesCount(company.getCompanyId())); } finally { _unregisterAMImageCounter(amImageCounterServiceRegistration); _companyLocalService.deleteCompany(company); } }
From source file:com.liferay.adaptive.media.image.service.impl.test.AMImageEntryLocalServiceTest.java
License:Open Source License
@Test public void testGetExpectedAMImageEntriesCountSumsAllAMImageCounters() throws Exception { Company company = CompanyTestUtil.addCompany(); ServiceRegistration<AMImageCounter> amImageCounterServiceRegistration1 = null; ServiceRegistration<AMImageCounter> amImageCounterServiceRegistration2 = null; try {/* w ww. ja va2 s . c o m*/ amImageCounterServiceRegistration1 = _registerAMImageCounter("test1", 100); amImageCounterServiceRegistration2 = _registerAMImageCounter("test2", 50); Assert.assertEquals(150, AMImageEntryLocalServiceUtil.getExpectedAMImageEntriesCount(company.getCompanyId())); } finally { _unregisterAMImageCounter(amImageCounterServiceRegistration1); _unregisterAMImageCounter(amImageCounterServiceRegistration2); _companyLocalService.deleteCompany(company); } }
From source file:com.liferay.adaptive.media.image.service.impl.test.AMImageEntryLocalServiceTest.java
License:Open Source License
@Test public void testGetPercentage() throws Exception { Company company = CompanyTestUtil.addCompany(); User user = UserTestUtil.getAdminUser(company.getCompanyId()); Group group = GroupTestUtil.addGroup(company.getCompanyId(), user.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID); AMImageConfigurationEntry amImageConfigurationEntry = _addAMImageConfigurationEntry(company.getCompanyId(), "uuid1", 100, 200); ServiceRegistration<AMImageCounter> amImageCounterServiceRegistration = null; try {//from ww w . ja va2 s . c om amImageCounterServiceRegistration = _registerAMImageCounter("test", 4); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId()); byte[] bytes = _getImageBytes(); FileEntry fileEntry = _addFileEntry(user.getUserId(), group.getGroupId(), bytes, serviceContext); AMImageEntryLocalServiceUtil.addAMImageEntry(amImageConfigurationEntry, fileEntry.getFileVersion(), 100, 200, new UnsyncByteArrayInputStream(bytes), 12345); Assert.assertEquals(20, AMImageEntryLocalServiceUtil.getPercentage(company.getCompanyId(), amImageConfigurationEntry.getUUID())); } finally { _unregisterAMImageCounter(amImageCounterServiceRegistration); _companyLocalService.deleteCompany(company); } }
From source file:com.liferay.adaptive.media.image.service.impl.test.AMImageEntryLocalServiceTest.java
License:Open Source License
@Test public void testGetPercentageMax100() throws Exception { Company company = CompanyTestUtil.addCompany(); User user = UserTestUtil.getAdminUser(company.getCompanyId()); Group group = GroupTestUtil.addGroup(company.getCompanyId(), user.getUserId(), GroupConstants.DEFAULT_PARENT_GROUP_ID); AMImageConfigurationEntry amImageConfigurationEntry = _addAMImageConfigurationEntry(company.getCompanyId(), "uuid1", 100, 200); ServiceRegistration<AMImageCounter> amImageCounterServiceRegistration = null; try {/*from ww w . ja v a 2s . c o m*/ amImageCounterServiceRegistration = _registerAMImageCounter("test", -1); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId()); byte[] bytes = _getImageBytes(); FileEntry fileEntry1 = _addFileEntry(user.getUserId(), group.getGroupId(), bytes, serviceContext); AMImageEntryLocalServiceUtil.addAMImageEntry(amImageConfigurationEntry, fileEntry1.getFileVersion(), 100, 200, new UnsyncByteArrayInputStream(bytes), 12345); FileEntry fileEntry2 = _addFileEntry(user.getUserId(), group.getGroupId(), bytes, serviceContext); AMImageEntryLocalServiceUtil.addAMImageEntry(amImageConfigurationEntry, fileEntry2.getFileVersion(), 100, 200, new UnsyncByteArrayInputStream(bytes), 12345); Assert.assertEquals(100, AMImageEntryLocalServiceUtil.getPercentage(company.getCompanyId(), amImageConfigurationEntry.getUUID())); } finally { _unregisterAMImageCounter(amImageCounterServiceRegistration); _companyLocalService.deleteCompany(company); } }
From source file:com.liferay.adaptive.media.image.service.impl.test.AMImageEntryLocalServiceTest.java
License:Open Source License
@Test public void testGetPercentageWhenNoImages() throws Exception { Company company = CompanyTestUtil.addCompany(); AMImageConfigurationEntry amImageConfigurationEntry1 = _addAMImageConfigurationEntry(company.getCompanyId(), "uuid1", 100, 200); try {/*from w w w .ja v a2 s .c o m*/ Assert.assertEquals(0, AMImageEntryLocalServiceUtil.getPercentage(company.getCompanyId(), amImageConfigurationEntry1.getUUID())); } finally { _companyLocalService.deleteCompany(company); } }
From source file:com.liferay.application.list.my.account.permissions.test.PanelAppMyAccountPermissionsTest.java
License:Open Source License
protected Company addCompany() throws Exception { Company company = CompanyTestUtil.addCompany(); WebAppPool.put(company.getCompanyId(), WebKeys.PORTLET_CATEGORY, new PortletCategory()); return company; }