Search in sources :

Example 6 with RelatedProduct

use of org.broadleafcommerce.core.catalog.domain.RelatedProduct in project BroadleafCommerce by BroadleafCommerce.

the class ProductDaoTest method createCrossSaleValues.

@Test(groups = "createCrossSaleValues", dependsOnGroups = "testReadProductsWithUpSaleValues")
@Rollback(false)
@Transactional
public void createCrossSaleValues() {
    Product prod1 = savedProducts.get(0);
    List<RelatedProduct> crossSale = new ArrayList<>();
    getRelatedCrossProduct(prod1, savedProducts.get(2), crossSale);
    getRelatedCrossProduct(prod1, savedProducts.get(3), crossSale);
    getRelatedCrossProduct(prod1, savedProducts.get(4), crossSale);
    prod1.setCrossSaleProducts(crossSale);
    prod1 = catalogService.saveProduct(prod1);
    assert (prod1.getId() != null);
    Product prod2 = savedProducts.get(1);
    List<RelatedProduct> crossSale2 = new ArrayList<>();
    getRelatedCrossProduct(prod2, savedProducts.get(5), crossSale2);
    getRelatedCrossProduct(prod2, savedProducts.get(6), crossSale2);
    prod2.setCrossSaleProducts(crossSale2);
    prod2 = catalogService.saveProduct(prod2);
    assert (prod2.getId() != null);
}
Also used : ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct) RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

RelatedProduct (org.broadleafcommerce.core.catalog.domain.RelatedProduct)6 Product (org.broadleafcommerce.core.catalog.domain.Product)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Test (org.testng.annotations.Test)4 ArrayList (java.util.ArrayList)2 CrossSaleProductImpl (org.broadleafcommerce.core.catalog.domain.CrossSaleProductImpl)2 UpSaleProductImpl (org.broadleafcommerce.core.catalog.domain.UpSaleProductImpl)2 Rollback (org.springframework.test.annotation.Rollback)2