Example usage for com.liferay.portal.kernel.test.util OrganizationTestUtil addOrganization

List of usage examples for com.liferay.portal.kernel.test.util OrganizationTestUtil addOrganization

Introduction

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

Prototype

public static Organization addOrganization() throws Exception 

Source Link

Usage

From source file:com.liferay.blogs.internal.exportimport.portlet.preferences.processor.test.BlogsAggregatorExportImportPortletPreferencesProcessorTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    _group = GroupTestUtil.addGroup();// www  . j a va2s. c  o  m

    _layout = LayoutTestUtil.addLayout(_group.getGroupId());

    LayoutTestUtil.addPortletToLayout(TestPropsValues.getUserId(), _layout, BlogsPortletKeys.BLOGS_AGGREGATOR,
            "column-1", new HashMap<String, String[]>());

    _organization = OrganizationTestUtil.addOrganization();

    _portletDataContextExport = ExportImportTestUtil.getExportPortletDataContext(_group.getGroupId());

    _portletDataContextExport.setPortletId(BlogsPortletKeys.BLOGS_AGGREGATOR);

    _portletDataContextImport = ExportImportTestUtil.getImportPortletDataContext(_group.getGroupId());

    _portletDataContextImport.setPortletId(BlogsPortletKeys.BLOGS_AGGREGATOR);
}

From source file:com.liferay.blogs.internal.exportimport.portlet.preferences.processor.test.BlogsAggregatorExportImportPortletPreferencesProcessorTest.java

License:Open Source License

@Test
public void testProcessOrganizationId() throws Exception {
    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(_layout,
            BlogsPortletKeys.BLOGS_AGGREGATOR);

    long organizationId = _organization.getOrganizationId();

    portletPreferences.setValue("organizationId", String.valueOf(organizationId));

    portletPreferences.store();//from w ww.java2s  .  c om

    ExportImportPortletPreferencesProcessor blogsAggregatorPortletPreferencesProcessor = _serviceTracker
            .getService();

    PortletPreferences exportedPortletPreferences = blogsAggregatorPortletPreferencesProcessor
            .processExportPortletPreferences(_portletDataContextExport, portletPreferences);

    String exportedOrganizationId = exportedPortletPreferences.getValue("organizationId", "");

    Assert.assertEquals(_organization.getUuid(), exportedOrganizationId);

    // Update organization to have a different primary key. We will swap
    // to the new one and verify it.

    OrganizationLocalServiceUtil.deleteOrganization(_organization.getOrganizationId());

    _organization = OrganizationTestUtil.addOrganization();

    _organization.setUuid(exportedOrganizationId);

    OrganizationLocalServiceUtil.updateOrganization(_organization);

    // Test the import

    PortletPreferences importedPortletPreferences = blogsAggregatorPortletPreferencesProcessor
            .processImportPortletPreferences(_portletDataContextImport, exportedPortletPreferences);

    String importedOrganizationId = importedPortletPreferences.getValue("organizationId", "");

    Assert.assertEquals(_organization.getOrganizationId(), GetterUtil.getLong(importedOrganizationId));
}

From source file:com.liferay.blogs.recent.bloggers.internal.exportimport.portlet.preferences.processor.test.RecentBloggersExportImportPortletPreferencesProcessorTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    ServiceTestUtil.setUser(TestPropsValues.getUser());

    _group = GroupTestUtil.addGroup();/*from w  ww.ja v a2s.c o m*/

    _layout = LayoutTestUtil.addLayout(_group.getGroupId());

    LayoutTestUtil.addPortletToLayout(TestPropsValues.getUserId(), _layout,
            RecentBloggersPortletKeys.RECENT_BLOGGERS, "column-1", new HashMap<String, String[]>());

    _organization = OrganizationTestUtil.addOrganization();

    _portletDataContextExport = ExportImportTestUtil.getExportPortletDataContext(_group.getGroupId());

    _portletDataContextExport.setPortletId(RecentBloggersPortletKeys.RECENT_BLOGGERS);

    _portletDataContextImport = ExportImportTestUtil.getImportPortletDataContext(_group.getGroupId());

    _portletDataContextImport.setPortletId(RecentBloggersPortletKeys.RECENT_BLOGGERS);
}

From source file:com.liferay.blogs.recent.bloggers.internal.exportimport.portlet.preferences.processor.test.RecentBloggersExportImportPortletPreferencesProcessorTest.java

License:Open Source License

@Test
public void testProcessOrganizationId() throws Exception {
    PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(_layout,
            RecentBloggersPortletKeys.RECENT_BLOGGERS);

    long organizationId = _organization.getOrganizationId();

    portletPreferences.setValue("organizationId", String.valueOf(organizationId));

    portletPreferences.store();/*  w  ww  .  j  av a2s.c  om*/

    ExportImportPortletPreferencesProcessor blogsAggregatorPortletPreferencesProcessor = _serviceTracker
            .getService();

    PortletPreferences exportedPortletPreferences = blogsAggregatorPortletPreferencesProcessor
            .processExportPortletPreferences(_portletDataContextExport, portletPreferences);

    String exportedOrganizationId = exportedPortletPreferences.getValue("organizationId", "");

    Assert.assertEquals(_organization.getUuid(), exportedOrganizationId);

    // Update organization to have a different primary key. We will swap
    // to the new one and verify it.

    OrganizationLocalServiceUtil.deleteOrganization(_organization.getOrganizationId());

    _organization = OrganizationTestUtil.addOrganization();

    _organization.setUuid(exportedOrganizationId);

    OrganizationLocalServiceUtil.updateOrganization(_organization);

    // Test the import

    PortletPreferences importedPortletPreferences = blogsAggregatorPortletPreferencesProcessor
            .processImportPortletPreferences(_portletDataContextImport, exportedPortletPreferences);

    String importedOrganizationId = importedPortletPreferences.getValue("organizationId", "");

    Assert.assertEquals(_organization.getOrganizationId(), GetterUtil.getLong(importedOrganizationId));
}

From source file:com.liferay.blogs.service.test.BlogsEntryLocalServiceTest.java

License:Open Source License

protected void testGetOrganizationEntries(boolean statusInTrash) throws Exception {

    QueryDefinition<BlogsEntry> queryDefinition = _statusInTrashQueryDefinition;

    if (!statusInTrash) {
        queryDefinition = _statusAnyQueryDefinition;
    }//from  www. j  a v  a  2 s  .  c o m

    Organization organization = OrganizationTestUtil.addOrganization();

    User user = UserTestUtil.addOrganizationOwnerUser(organization);

    List<BlogsEntry> initialEntries = BlogsEntryLocalServiceUtil
            .getOrganizationEntries(organization.getOrganizationId(), new Date(), queryDefinition);

    int initialCount = initialEntries.size();

    addEntry(user.getUserId(), false);
    addEntry(user.getUserId(), true);

    List<BlogsEntry> actualEntries = BlogsEntryLocalServiceUtil
            .getOrganizationEntries(organization.getOrganizationId(), new Date(), queryDefinition);

    Assert.assertEquals(initialCount + 1, actualEntries.size());

    assertBlogsEntriesStatus(actualEntries, statusInTrash);
}

From source file:com.liferay.blogs.service.test.BlogsEntryLocalServiceTest.java

License:Open Source License

protected void testGetOrganizationEntriesCount(boolean statusInTrash) throws Exception {

    QueryDefinition<BlogsEntry> queryDefinition = _statusInTrashQueryDefinition;

    if (!statusInTrash) {
        queryDefinition = _statusAnyQueryDefinition;
    }/*w w w.j a v a2 s. c  o  m*/

    Organization organization = OrganizationTestUtil.addOrganization();

    User user = UserTestUtil.addOrganizationOwnerUser(organization);

    int initialCount = BlogsEntryLocalServiceUtil.getOrganizationEntriesCount(organization.getOrganizationId(),
            new Date(), queryDefinition);

    addEntry(user.getUserId(), false);
    addEntry(user.getUserId(), true);

    int actualCount = BlogsEntryLocalServiceUtil.getOrganizationEntriesCount(organization.getOrganizationId(),
            new Date(), queryDefinition);

    Assert.assertEquals(initialCount + 1, actualCount);
}

From source file:com.liferay.users.admin.internal.exportimport.data.handler.test.OrganizationStagedModelDataHandlerTest.java

License:Open Source License

@Override
protected StagedModel addStagedModel(Group group, Map<String, List<StagedModel>> dependentStagedModelsMap)
        throws Exception {

    _organization = OrganizationTestUtil.addOrganization();

    Organization suborganization = OrganizationTestUtil.addOrganization(_organization.getOrganizationId(),
            RandomTestUtil.randomString(), false);

    addDependentStagedModel(dependentStagedModelsMap, Organization.class, suborganization);

    Address address = OrganizationTestUtil.addAddress(_organization);

    addDependentStagedModel(dependentStagedModelsMap, Address.class, address);

    EmailAddress emailAddress = OrganizationTestUtil.addEmailAddress(_organization);

    addDependentStagedModel(dependentStagedModelsMap, EmailAddress.class, emailAddress);

    OrganizationTestUtil.addOrgLabor(_organization);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    PasswordPolicy passwordPolicy = OrganizationTestUtil.addPasswordPolicyRel(_organization, serviceContext);

    addDependentStagedModel(dependentStagedModelsMap, PasswordPolicy.class, passwordPolicy);

    Phone phone = OrganizationTestUtil.addPhone(_organization);

    addDependentStagedModel(dependentStagedModelsMap, Phone.class, phone);

    Website website = OrganizationTestUtil.addWebsite(_organization);

    addDependentStagedModel(dependentStagedModelsMap, Website.class, website);

    return _organization;
}

From source file:com.liferay.users.admin.internal.exportimport.data.handler.test.UsersAdminPortletDataHandlerTest.java

License:Open Source License

@Override
protected void addStagedModels() throws Exception {
    _organization = OrganizationTestUtil.addOrganization();
}