Search in sources :

Example 1 with FeaturedProduct

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

the class CategoryDaoTest method testSetFeaturedProducts.

@Test(groups = { "testSetFeaturedProducts" }, dataProvider = "basicCategory", dataProviderClass = CategoryDaoDataProvider.class)
@Transactional
public void testSetFeaturedProducts(Category category) {
    category = catalogService.saveCategory(category);
    Sku sku = new SkuImpl();
    sku.setDescription("This thing will change your life");
    sku.setName("Test Product");
    catalogService.saveSku(sku);
    Product product = new ProductImpl();
    product.setModel("KGX200");
    product.setDefaultSku(sku);
    product = catalogService.saveProduct(product);
    FeaturedProduct featuredProduct = new FeaturedProductImpl();
    featuredProduct.setCategory(category);
    featuredProduct.setProduct(product);
    featuredProduct.setPromotionMessage("BUY ME NOW!!!!");
    List<FeaturedProduct> featuredProducts = new ArrayList<>();
    featuredProducts.add(featuredProduct);
    category.setFeaturedProducts(featuredProducts);
    category = catalogService.saveCategory(category);
    Category categoryTest = categoryDao.readCategoryById(category.getId());
    FeaturedProduct featuredProductTest = categoryTest.getFeaturedProducts().get(0);
    assert (featuredProductTest.getPromotionMessage() == "BUY ME NOW!!!!");
    assert (featuredProductTest.getProduct().getModel().equals("KGX200"));
}
Also used : SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) FeaturedProductImpl(org.broadleafcommerce.core.catalog.domain.FeaturedProductImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) Category(org.broadleafcommerce.core.catalog.domain.Category) FeaturedProduct(org.broadleafcommerce.core.catalog.domain.FeaturedProduct) ArrayList(java.util.ArrayList) FeaturedProduct(org.broadleafcommerce.core.catalog.domain.FeaturedProduct) Product(org.broadleafcommerce.core.catalog.domain.Product) FeaturedProductImpl(org.broadleafcommerce.core.catalog.domain.FeaturedProductImpl) Sku(org.broadleafcommerce.core.catalog.domain.Sku) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ArrayList (java.util.ArrayList)1 Category (org.broadleafcommerce.core.catalog.domain.Category)1 FeaturedProduct (org.broadleafcommerce.core.catalog.domain.FeaturedProduct)1 FeaturedProductImpl (org.broadleafcommerce.core.catalog.domain.FeaturedProductImpl)1 Product (org.broadleafcommerce.core.catalog.domain.Product)1 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)1 Sku (org.broadleafcommerce.core.catalog.domain.Sku)1 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Test (org.testng.annotations.Test)1