Search in sources :

Example 1 with RelatedProduct

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

the class ProductDaoTest method getRelatedCrossProduct.

private static RelatedProduct getRelatedCrossProduct(Product prod, Product prodToRelate, List<RelatedProduct> upSales) {
    RelatedProduct rp1 = new CrossSaleProductImpl();
    rp1.setProduct(prod);
    rp1.setPromotionMessage("brand new coffee");
    rp1.setRelatedProduct(prodToRelate);
    upSales.add(rp1);
    return rp1;
}
Also used : RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct) CrossSaleProductImpl(org.broadleafcommerce.core.catalog.domain.CrossSaleProductImpl)

Example 2 with RelatedProduct

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

the class ProductDaoTest method getRelatedUpSaleProduct.

private static RelatedProduct getRelatedUpSaleProduct(Product prod, Product prodToRelate, List<RelatedProduct> upSales) {
    RelatedProduct rp1 = new UpSaleProductImpl();
    rp1.setProduct(prod);
    rp1.setPromotionMessage("brand new coffee");
    rp1.setRelatedProduct(prodToRelate);
    upSales.add(rp1);
    return rp1;
}
Also used : UpSaleProductImpl(org.broadleafcommerce.core.catalog.domain.UpSaleProductImpl) RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct)

Example 3 with RelatedProduct

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

the class ProductDaoTest method testReadProductsWithCrossSaleValues.

@Test(groups = "testReadProductsWithCrossSaleValues", dependsOnGroups = "createCrossSaleValues")
@Transactional
public void testReadProductsWithCrossSaleValues() {
    Product result = productDao.readProductById(savedProducts.get(1).getId());
    List<RelatedProduct> related = result.getCrossSaleProducts();
    assert (related != null);
    assert (!related.isEmpty());
    assert (related.size() == 2 || related.size() == 3);
    for (RelatedProduct rp : related) {
        assert (rp instanceof CrossSaleProductImpl);
    }
}
Also used : Product(org.broadleafcommerce.core.catalog.domain.Product) RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct) RelatedProduct(org.broadleafcommerce.core.catalog.domain.RelatedProduct) CrossSaleProductImpl(org.broadleafcommerce.core.catalog.domain.CrossSaleProductImpl) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with RelatedProduct

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

the class ProductDaoTest method createUpSaleValues.

@Test(groups = "createUpSaleValues", dependsOnGroups = "createProducts")
@Rollback(false)
@Transactional
public void createUpSaleValues() {
    Product prod1 = savedProducts.get(0);
    List<RelatedProduct> upSales = new ArrayList<>();
    getRelatedUpSaleProduct(prod1, savedProducts.get(2), upSales);
    getRelatedUpSaleProduct(prod1, savedProducts.get(3), upSales);
    getRelatedUpSaleProduct(prod1, savedProducts.get(4), upSales);
    prod1.setUpSaleProducts(upSales);
    prod1 = catalogService.saveProduct(prod1);
    assert (prod1.getId() != null);
    Product prod2 = savedProducts.get(1);
    List<RelatedProduct> upSales2 = new ArrayList<>();
    getRelatedUpSaleProduct(prod2, savedProducts.get(5), upSales2);
    getRelatedUpSaleProduct(prod2, savedProducts.get(6), upSales2);
    prod2.setUpSaleProducts(upSales2);
    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)

Example 5 with RelatedProduct

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

the class ProductDaoTest method testReadProductsWithUpSaleValues.

@Test(groups = "testReadProductsWithUpSaleValues", dependsOnGroups = "createUpSaleValues")
@Transactional
public void testReadProductsWithUpSaleValues() {
    Product result = productDao.readProductById(savedProducts.get(0).getId());
    List<RelatedProduct> related = result.getUpSaleProducts();
    assert (related != null);
    assert (!related.isEmpty());
    assert (related.size() == 2 || related.size() == 3);
    for (RelatedProduct rp : related) {
        assert (rp instanceof UpSaleProductImpl);
    }
}
Also used : UpSaleProductImpl(org.broadleafcommerce.core.catalog.domain.UpSaleProductImpl) 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) 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