Example usage for com.liferay.portal.kernel.service EmailAddressLocalServiceUtil fetchEmailAddressByUuidAndCompanyId

List of usage examples for com.liferay.portal.kernel.service EmailAddressLocalServiceUtil fetchEmailAddressByUuidAndCompanyId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service EmailAddressLocalServiceUtil fetchEmailAddressByUuidAndCompanyId.

Prototype

public static com.liferay.portal.kernel.model.EmailAddress fetchEmailAddressByUuidAndCompanyId(String uuid,
        long companyId) 

Source Link

Document

Returns the email address with the matching UUID and company.

Usage

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

License:Open Source License

@Override
protected void validateImport(StagedModel stagedModel, StagedModelAssets stagedModelAssets,
        Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception {

    Organization organization = OrganizationLocalServiceUtil
            .fetchOrganizationByUuidAndCompanyId(stagedModel.getUuid(), group.getCompanyId());

    validateAssets(organization, stagedModelAssets, group);

    List<StagedModel> addressDependentStagedModels = dependentStagedModelsMap
            .get(Address.class.getSimpleName());

    Assert.assertEquals(addressDependentStagedModels.toString(), 1, addressDependentStagedModels.size());

    Address address = (Address) addressDependentStagedModels.get(0);

    Address importedAddress = AddressLocalServiceUtil.fetchAddressByUuidAndCompanyId(address.getUuid(),
            group.getCompanyId());/* w ww.j  a  v a2s.  c om*/

    Assert.assertNotNull(importedAddress);
    Assert.assertEquals(organization.getOrganizationId(), importedAddress.getClassPK());

    List<StagedModel> emailAddressDependentStagedModels = dependentStagedModelsMap
            .get(EmailAddress.class.getSimpleName());

    Assert.assertEquals(emailAddressDependentStagedModels.toString(), 1,
            emailAddressDependentStagedModels.size());

    EmailAddress emailAddress = (EmailAddress) emailAddressDependentStagedModels.get(0);

    EmailAddress importedEmailAddress = EmailAddressLocalServiceUtil
            .fetchEmailAddressByUuidAndCompanyId(emailAddress.getUuid(), group.getCompanyId());

    Assert.assertNotNull(importedEmailAddress);
    Assert.assertEquals(organization.getOrganizationId(), importedEmailAddress.getClassPK());

    List<OrgLabor> importedOrgLabors = OrgLaborLocalServiceUtil.getOrgLabors(organization.getOrganizationId());

    Assert.assertEquals(importedOrgLabors.toString(), 1, importedOrgLabors.size());

    OrgLabor importedOrgLabor = importedOrgLabors.get(0);

    Assert.assertEquals(organization.getOrganizationId(), importedOrgLabor.getOrganizationId());

    List<StagedModel> passwordPolicyDependentStagedModels = dependentStagedModelsMap
            .get(PasswordPolicy.class.getSimpleName());

    Assert.assertEquals(passwordPolicyDependentStagedModels.toString(), 1,
            passwordPolicyDependentStagedModels.size());

    PasswordPolicy passwordPolicy = (PasswordPolicy) passwordPolicyDependentStagedModels.get(0);

    PasswordPolicyRel importedPasswordPolicyRel = PasswordPolicyRelLocalServiceUtil
            .fetchPasswordPolicyRel(organization.getModelClassName(), organization.getOrganizationId());

    Assert.assertNotNull(importedPasswordPolicyRel);
    Assert.assertEquals(passwordPolicy.getPasswordPolicyId(), importedPasswordPolicyRel.getPasswordPolicyId());

    List<StagedModel> phoneDependentStagedModels = dependentStagedModelsMap.get(Phone.class.getSimpleName());

    Assert.assertEquals(phoneDependentStagedModels.toString(), 1, phoneDependentStagedModels.size());

    Phone phone = (Phone) phoneDependentStagedModels.get(0);

    Phone importedPhone = PhoneLocalServiceUtil.fetchPhoneByUuidAndCompanyId(phone.getUuid(),
            group.getCompanyId());

    Assert.assertNotNull(importedPhone);
    Assert.assertEquals(organization.getOrganizationId(), importedPhone.getClassPK());

    List<StagedModel> websiteDependentStagedModels = dependentStagedModelsMap
            .get(Website.class.getSimpleName());

    Assert.assertEquals(websiteDependentStagedModels.toString(), 1, websiteDependentStagedModels.size());

    Website website = (Website) websiteDependentStagedModels.get(0);

    Website importedWebsite = WebsiteLocalServiceUtil.fetchWebsiteByUuidAndCompanyId(website.getUuid(),
            group.getCompanyId());

    Assert.assertNotNull(importedWebsite);
    Assert.assertEquals(organization.getOrganizationId(), importedWebsite.getClassPK());
}