Skip to content

Commit

Permalink
LPD-50061 Add integretion test
Browse files Browse the repository at this point in the history
  • Loading branch information
CrescenzoRegaLF committed Feb 28, 2025
1 parent 8801495 commit 7375fc8
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.liferay.commerce.exception.CommerceOrderAccountLimitException;
import com.liferay.commerce.model.CommerceAddress;
import com.liferay.commerce.model.CommerceOrder;
import com.liferay.commerce.order.CommerceOrderThreadLocal;
import com.liferay.commerce.order.engine.CommerceOrderEngine;
import com.liferay.commerce.product.constants.CommerceChannelConstants;
import com.liferay.commerce.product.model.CommerceChannel;
Expand Down Expand Up @@ -987,6 +988,64 @@ public void testGetPlacedCommerceOrder() throws Exception {
_accountEntryLocalService.deleteAccountEntry(accountEntry);
}

@Test
public void testSkipValidateAccountOrdersLimit() throws Exception {
Settings settings = FallbackKeysSettingsUtil.getSettings(
new GroupServiceSettingsLocator(
_commerceChannel.getGroupId(),
CommerceConstants.SERVICE_NAME_COMMERCE_ORDER_FIELDS));

ModifiableSettings modifiableSettings =
settings.getModifiableSettings();

modifiableSettings.setValue("accountCartMaxAllowed", "1");

modifiableSettings.store();

AccountEntry accountEntry =
CommerceAccountTestUtil.addBusinessAccountEntry(
_user.getUserId(), "Test Business Account", null, null,
new long[] {_user.getUserId()}, null, _serviceContext);

long commerceChannelGroupId = _commerceChannel.getGroupId();

_commerceOrderLocalService.addCommerceOrder(
_user.getUserId(), commerceChannelGroupId,
accountEntry.getAccountEntryId(), _commerceCurrency.getCode(), 0);

try {
_commerceOrderLocalService.addCommerceOrder(
_user.getUserId(), commerceChannelGroupId,
accountEntry.getAccountEntryId(), _commerceCurrency.getCode(),
0);
}
catch (CommerceOrderAccountLimitException
commerceOrderAccountLimitException) {

Assert.assertNotNull(commerceOrderAccountLimitException);
}

Assert.assertEquals(
1,
_commerceOrderService.getPendingCommerceOrdersCount(
commerceChannelGroupId, accountEntry.getAccountEntryId(),
StringPool.BLANK));

CommerceOrderThreadLocal.setSkipValidateAccountOrdersLimit(true);

_commerceOrderLocalService.addCommerceOrder(
_user.getUserId(), commerceChannelGroupId,
accountEntry.getAccountEntryId(), _commerceCurrency.getCode(), 0);

Assert.assertEquals(
2,
_commerceOrderService.getPendingCommerceOrdersCount(
commerceChannelGroupId, accountEntry.getAccountEntryId(),
StringPool.BLANK));

_accountEntries.add(accountEntry);
}

@Test
public void testValidateAccountOrdersLimit() throws Exception {
frutillaRule.scenario(
Expand Down

0 comments on commit 7375fc8

Please sign in to comment.