Skip to content

Commit

Permalink
LPD-25594 integration test added
Browse files Browse the repository at this point in the history
  • Loading branch information
brbalazs authored and brianchandotcom committed May 16, 2024
1 parent ecaa3d1 commit 9b9cb52
Showing 1 changed file with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import com.liferay.headless.admin.user.client.problem.Problem;
import com.liferay.petra.function.transform.TransformUtil;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.model.Address;
import com.liferay.portal.kernel.model.Organization;
import com.liferay.portal.kernel.service.AddressLocalService;
import com.liferay.portal.kernel.test.rule.DataGuard;
import com.liferay.portal.kernel.test.util.OrganizationTestUtil;
import com.liferay.portal.kernel.test.util.RandomTestUtil;
Expand Down Expand Up @@ -175,6 +177,7 @@ public void testPatchAccount() throws Exception {
super.testPatchAccount();

_testPatchAccountWithContactInformation();
_testPatchAccountWithPostalAddressPhoneNumber();
}

@Override
Expand Down Expand Up @@ -284,6 +287,7 @@ public void testPostAccount() throws Exception {

_testPostAccountDuplicateExternalReferenceCode();
_testPostAccountWithContactInformation();
_testPostAccountWithPostalAddressPhoneNumber();
}

@Override
Expand Down Expand Up @@ -352,6 +356,7 @@ public void testPutAccount() throws Exception {
super.testPutAccount();

_testPutAccountWithContactInformation();
_testPutAccountWithPostalAddressPhoneNumber();
}

@Override
Expand Down Expand Up @@ -788,6 +793,33 @@ private void _testPatchAccountWithContactInformation() throws Exception {
patchAccount.getAccountContactInformation());
}

private void _testPatchAccountWithPostalAddressPhoneNumber()
throws Exception {

Account postAccount = testPatchAccount_addAccount();

Account randomPatchAccount = randomPatchAccount();

PostalAddress postalAddress = _randomPostalAddress();

postalAddress.setPhoneNumber(RandomTestUtil.randomString());

randomPatchAccount.setPostalAddresses(
new PostalAddress[] {postalAddress});

Account patchAccount = accountResource.patchAccount(
postAccount.getId(), randomPatchAccount);

List<Address> addresses = _addressLocalService.getAddresses(
TestPropsValues.getCompanyId(), AccountEntry.class.getName(),
patchAccount.getId());

Address address = addresses.get(0);

Assert.assertEquals(
postalAddress.getPhoneNumber(), address.getPhoneNumber());
}

private void _testPostAccountDuplicateExternalReferenceCode()
throws Exception {

Expand Down Expand Up @@ -834,6 +866,29 @@ private void _testPostAccountWithContactInformation() throws Exception {
postAccount.getAccountContactInformation());
}

private void _testPostAccountWithPostalAddressPhoneNumber()
throws Exception {

Account account = randomAccount();

PostalAddress postalAddress = _randomPostalAddress();

postalAddress.setPhoneNumber(RandomTestUtil.randomString());

account.setPostalAddresses(new PostalAddress[] {postalAddress});

Account postAccount = accountResource.postAccount(account);

List<Address> addresses = _addressLocalService.getAddresses(
TestPropsValues.getCompanyId(), AccountEntry.class.getName(),
postAccount.getId());

Address address = addresses.get(0);

Assert.assertEquals(
postalAddress.getPhoneNumber(), address.getPhoneNumber());
}

private void _testPutAccountByExternalReferenceCodeWithContactInformation()
throws Exception {

Expand Down Expand Up @@ -873,11 +928,40 @@ private void _testPutAccountWithContactInformation() throws Exception {
putAccount.getAccountContactInformation());
}

private void _testPutAccountWithPostalAddressPhoneNumber()
throws Exception {

Account postAccount = testPutAccount_addAccount();

Account randomAccount = randomAccount();

PostalAddress postalAddress = _randomPostalAddress();

postalAddress.setPhoneNumber(RandomTestUtil.randomString());

randomAccount.setPostalAddresses(new PostalAddress[] {postalAddress});

Account putAccount = accountResource.putAccount(
postAccount.getId(), randomAccount);

List<Address> addresses = _addressLocalService.getAddresses(
TestPropsValues.getCompanyId(), AccountEntry.class.getName(),
putAccount.getId());

Address address = addresses.get(0);

Assert.assertEquals(
postalAddress.getPhoneNumber(), address.getPhoneNumber());
}

@Inject
private AccountEntryLocalService _accountEntryLocalService;

@Inject
private AccountEntryOrganizationRelLocalService
_accountEntryOrganizationRelLocalService;

@Inject
private AddressLocalService _addressLocalService;

}

0 comments on commit 9b9cb52

Please sign in to comment.