|
1 | 1 |
|
2 | 2 | package commercetools.cart; |
3 | 3 |
|
| 4 | +import java.util.ArrayList; |
4 | 5 | import java.util.List; |
5 | 6 |
|
6 | 7 | import com.commercetools.api.models.cart.Cart; |
| 8 | +import com.commercetools.api.models.cart.CartDraft; |
| 9 | +import com.commercetools.api.models.cart.CartDraftBuilder; |
| 10 | +import com.commercetools.api.models.product.Product; |
| 11 | +import commercetools.product.ProductFixtures; |
7 | 12 | import commercetools.utils.CommercetoolsTestUtils; |
8 | 13 |
|
9 | 14 | import org.assertj.core.api.Assertions; |
10 | 15 | import org.junit.jupiter.api.Test; |
11 | 16 |
|
| 17 | +import static commercetools.cart.CartsFixtures.createCart; |
| 18 | +import static commercetools.cart.CartsFixtures.deleteCart; |
| 19 | +import static commercetools.category.CategoryFixtures.withCategory; |
| 20 | +import static commercetools.product.ProductFixtures.*; |
| 21 | +import static commercetools.product_type.ProductTypeFixtures.withProductType; |
| 22 | +import static commercetools.tax_category.TaxCategoryFixtures.withTaxCategory; |
| 23 | + |
12 | 24 | public class CartIntegrationTests { |
13 | 25 | @Test |
14 | 26 | public void queryByCustomerId() { |
@@ -73,4 +85,30 @@ public void getByCustomerId() { |
73 | 85 | }); |
74 | 86 | } |
75 | 87 |
|
| 88 | + @Test |
| 89 | + public void bigCart() { |
| 90 | + withTaxCategory(taxCategory -> withCategory(category -> withProductType(createProductTypeDraft(), productType -> { |
| 91 | + List<Product> products = new ArrayList<>(); |
| 92 | + for(int i = 0; i < 100; i++) { |
| 93 | + products.add(createProduct(productType, category, taxCategory, true)); |
| 94 | + } |
| 95 | + |
| 96 | + CartDraftBuilder cartDraft = CartDraft.builder() |
| 97 | + .currency("EUR") |
| 98 | + .country("DE"); |
| 99 | + products.forEach(product -> cartDraft.plusLineItems(lineItemDraftBuilder -> lineItemDraftBuilder |
| 100 | + .sku(product.getMasterData().getCurrent().getMasterVariant().getSku()) |
| 101 | + )); |
| 102 | + |
| 103 | + try { |
| 104 | + final long startTime = System.currentTimeMillis(); |
| 105 | + Cart cart = createCart(cartDraft.build()); |
| 106 | + final long executionTime = System.currentTimeMillis() - startTime; |
| 107 | + deleteCart(cart.getId(), cart.getVersion()); |
| 108 | + } finally { |
| 109 | + products.forEach(ProductFixtures::deleteProduct); |
| 110 | + } |
| 111 | + }))); |
| 112 | + } |
| 113 | + |
76 | 114 | } |
0 commit comments