Search in sources :

Example 16 with ProductImpl

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

the class OfferDataItemProvider method createBasicOrder.

public Order createBasicOrder() {
    Order order = new OrderImpl();
    order.setId(getOrderId());
    Category category1 = new CategoryImpl();
    category1.setName("test1");
    category1.setId(1L);
    Product product1 = new ProductImpl();
    Sku sku1 = new SkuImpl();
    sku1.setName("test1");
    sku1.setId(1L);
    sku1.setDiscountable(true);
    sku1.setRetailPrice(new Money(19.99D));
    product1.setDefaultSku(sku1);
    CategoryProductXref xref1 = new CategoryProductXrefImpl();
    xref1.setProduct(product1);
    xref1.setCategory(category1);
    category1.getAllProductXrefs().add(xref1);
    Category category2 = new CategoryImpl();
    category2.setName("test2");
    category2.setId(2L);
    Product product2 = new ProductImpl();
    Sku sku2 = new SkuImpl();
    sku2.setName("test2");
    sku2.setId(2L);
    sku2.setDiscountable(true);
    sku2.setRetailPrice(new Money(29.99D));
    product2.setDefaultSku(sku2);
    CategoryProductXref xref2 = new CategoryProductXrefImpl();
    xref2.setProduct(product2);
    xref2.setCategory(category2);
    category2.getAllProductXrefs().add(xref2);
    DiscreteOrderItem orderItem1 = new DiscreteOrderItemImpl();
    orderItem1.setCategory(category1);
    orderItem1.setName("test1");
    orderItem1.setOrder(order);
    orderItem1.setOrderItemType(OrderItemType.DISCRETE);
    orderItem1.setProduct(product1);
    orderItem1.setQuantity(2);
    orderItem1.setSku(sku1);
    orderItem1.setId(getOrderItemId());
    orderItem1.setOrder(order);
    OrderItemPriceDetail priceDetail1 = new OrderItemPriceDetailImpl();
    priceDetail1.setOrderItem(orderItem1);
    priceDetail1.setQuantity(2);
    orderItem1.getOrderItemPriceDetails().add(priceDetail1);
    order.getOrderItems().add(orderItem1);
    DiscreteOrderItem orderItem2 = new DiscreteOrderItemImpl();
    orderItem2.setCategory(category2);
    orderItem2.setName("test2");
    orderItem2.setOrder(order);
    orderItem2.setOrderItemType(OrderItemType.DISCRETE);
    orderItem2.setProduct(product2);
    orderItem2.setQuantity(3);
    orderItem2.setSku(sku2);
    orderItem2.setId(getOrderItemId());
    orderItem2.setOrder(order);
    OrderItemPriceDetail priceDetail2 = new OrderItemPriceDetailImpl();
    priceDetail2.setOrderItem(orderItem2);
    priceDetail2.setQuantity(3);
    orderItem2.getOrderItemPriceDetails().add(priceDetail2);
    order.getOrderItems().add(orderItem2);
    Customer customer = new CustomerImpl();
    customer.setEmailAddress("test@test.com");
    customer.setFirstName("John");
    customer.setLastName("Tester");
    customer.setReceiveEmail(true);
    customer.setRegistered(true);
    order.setCustomer(customer);
    order.setEmailAddress("test@test.com");
    FulfillmentGroup fg1 = new FulfillmentGroupImpl();
    fg1.setId(1L);
    Address address1 = new AddressImpl();
    address1.setAddressLine1("123 Test Road");
    address1.setCity("Dallas");
    Country country = new CountryImpl();
    country.setAbbreviation("US");
    country.setName("United States");
    ISOCountry isoCountry = new ISOCountryImpl();
    isoCountry.setAlpha2("US");
    isoCountry.setName("UNITED STATES");
    address1.setCountry(country);
    address1.setIsoCountryAlpha2(isoCountry);
    address1.setDefault(true);
    address1.setFirstName("John");
    address1.setLastName("Tester");
    address1.setPostalCode("75244");
    Phone primary = new PhoneImpl();
    primary.setPhoneNumber("972-976-1234");
    address1.setPhonePrimary(primary);
    State state = new StateImpl();
    state.setAbbreviation("TX");
    state.setCountry(country);
    state.setName("Texas");
    address1.setState(state);
    address1.setIsoCountrySubdivision("US-TX");
    fg1.setAddress(address1);
    fg1.setOrder(order);
    fg1.setPrimary(true);
    fg1.setRetailShippingPrice(new Money(10D));
    fg1.setShippingPrice(new Money(10D));
    fg1.setType(FulfillmentType.PHYSICAL_SHIP);
    fg1.setOrder(order);
    FulfillmentGroupItem fgItem1 = new FulfillmentGroupItemImpl();
    fgItem1.setFulfillmentGroup(fg1);
    fgItem1.setOrderItem(orderItem1);
    fgItem1.setQuantity(2);
    // fgItem1.setRetailPrice(new Money(19.99D));
    fg1.getFulfillmentGroupItems().add(fgItem1);
    order.getFulfillmentGroups().add(fg1);
    FulfillmentGroup fg2 = new FulfillmentGroupImpl();
    fg2.setId(2L);
    Address address2 = new AddressImpl();
    address2.setAddressLine1("124 Test Road");
    address2.setCity("Dallas");
    Country country2 = new CountryImpl();
    country2.setAbbreviation("US");
    country2.setName("United States");
    ISOCountry isoCountry2 = new ISOCountryImpl();
    isoCountry2.setAlpha2("US");
    isoCountry2.setName("UNITED STATES");
    address2.setCountry(country2);
    address2.setIsoCountryAlpha2(isoCountry2);
    address2.setDefault(true);
    address2.setFirstName("John");
    address2.setLastName("Tester");
    address2.setPostalCode("75244");
    Phone primary2 = new PhoneImpl();
    primary2.setPhoneNumber("972-976-1234");
    address2.setPhonePrimary(primary2);
    State state2 = new StateImpl();
    state2.setAbbreviation("TX");
    state2.setCountry(country2);
    state2.setName("Texas");
    address2.setState(state2);
    address2.setIsoCountrySubdivision("US-TX");
    fg2.setAddress(address2);
    fg2.setOrder(order);
    fg2.setPrimary(true);
    fg2.setRetailShippingPrice(new Money(20D));
    fg2.setShippingPrice(new Money(20D));
    fg2.setType(FulfillmentType.PHYSICAL_SHIP);
    fg2.setOrder(order);
    FulfillmentGroupItem fgItem2 = new FulfillmentGroupItemImpl();
    fgItem2.setFulfillmentGroup(fg2);
    fgItem2.setOrderItem(orderItem2);
    fgItem2.setQuantity(3);
    // fgItem2.setRetailPrice(new Money(29.99D));
    fg2.getFulfillmentGroupItems().add(fgItem2);
    order.getFulfillmentGroups().add(fg2);
    order.setSubTotal(new Money((2 * 19.99D) + (3 * 29.99D)));
    orders.put(order.getId(), order);
    return order;
}
Also used : DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) Category(org.broadleafcommerce.core.catalog.domain.Category) CategoryProductXref(org.broadleafcommerce.core.catalog.domain.CategoryProductXref) Address(org.broadleafcommerce.profile.core.domain.Address) DiscreteOrderItemImpl(org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl) Customer(org.broadleafcommerce.profile.core.domain.Customer) OrderItemPriceDetailImpl(org.broadleafcommerce.core.order.domain.OrderItemPriceDetailImpl) Product(org.broadleafcommerce.core.catalog.domain.Product) CustomerImpl(org.broadleafcommerce.profile.core.domain.CustomerImpl) Money(org.broadleafcommerce.common.money.Money) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) CountryImpl(org.broadleafcommerce.profile.core.domain.CountryImpl) Phone(org.broadleafcommerce.profile.core.domain.Phone) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) CategoryProductXrefImpl(org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) FulfillmentGroupItemImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentGroupImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl) StateImpl(org.broadleafcommerce.profile.core.domain.StateImpl) CategoryImpl(org.broadleafcommerce.core.catalog.domain.CategoryImpl) SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) State(org.broadleafcommerce.profile.core.domain.State) OrderImpl(org.broadleafcommerce.core.order.domain.OrderImpl) PromotableOrderImpl(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) OrderItemPriceDetail(org.broadleafcommerce.core.order.domain.OrderItemPriceDetail) Sku(org.broadleafcommerce.core.catalog.domain.Sku)

Example 17 with ProductImpl

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

the class ProductSiteMapGeneratorTest method testProductSiteMapGenerator.

@Test
public void testProductSiteMapGenerator() throws SiteMapException, IOException {
    Product p1 = new ProductImpl();
    p1.setUrl("/hot-sauces/sudden_death_sauce");
    Sku s1 = new SkuImpl();
    p1.setDefaultSku(s1);
    Product p2 = new ProductImpl();
    p2.setUrl("hot-sauces/sweet_death_sauce");
    Sku s2 = new SkuImpl();
    p2.setDefaultSku(s2);
    Product p3 = new ProductImpl();
    p3.setUrl("/hot-sauces/hoppin_hot_sauce");
    Sku s3 = new SkuImpl();
    p3.setDefaultSku(s3);
    Product p4 = new ProductImpl();
    p4.setUrl("/hot-sauces/day_of_the_dead_chipotle_hot_sauce");
    Sku s4 = new SkuImpl();
    p4.setDefaultSku(s4);
    List<Product> products = new ArrayList<Product>();
    products.add(p1);
    products.add(p2);
    products.add(p3);
    products.add(p4);
    ProductDao productDao = EasyMock.createMock(ProductDao.class);
    EasyMock.expect(productDao.readAllActiveProducts(EasyMock.eq(0), EasyMock.eq(5))).andReturn(products);
    EasyMock.replay(productDao);
    ProductSiteMapGenerator psmg = new ProductSiteMapGenerator();
    psmg.setProductDao(productDao);
    psmg.setPageSize(5);
    SiteMapGeneratorConfiguration smgc = new SiteMapGeneratorConfigurationImpl();
    smgc.setDisabled(false);
    smgc.setSiteMapGeneratorType(SiteMapGeneratorType.PRODUCT);
    smgc.setSiteMapChangeFreq(SiteMapChangeFreqType.HOURLY);
    smgc.setSiteMapPriority(SiteMapPriorityType.POINT5);
    testGenerator(smgc, psmg);
    File file1 = fileService.getResource("/sitemap_index.xml");
    File file2 = fileService.getResource("/sitemap1.xml");
    File file3 = fileService.getResource("/sitemap2.xml");
    compareFiles(file1, "src/test/resources/org/broadleafcommerce/sitemap/product/sitemap_index.xml");
    compareFiles(file2, "src/test/resources/org/broadleafcommerce/sitemap/product/sitemap1.xml");
    compareFiles(file3, "src/test/resources/org/broadleafcommerce/sitemap/product/sitemap2.xml");
}
Also used : SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) Sku(org.broadleafcommerce.core.catalog.domain.Sku) SiteMapGeneratorConfigurationImpl(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfigurationImpl) ProductDao(org.broadleafcommerce.core.catalog.dao.ProductDao) SiteMapGeneratorConfiguration(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfiguration) File(java.io.File) Test(org.junit.Test) SiteMapGeneratorTest(org.broadleafcommerce.common.sitemap.service.SiteMapGeneratorTest)

Example 18 with ProductImpl

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

the class SkuSiteMapGeneratorTest method testSkuSiteMapGenerator.

@Test
public void testSkuSiteMapGenerator() throws SiteMapException, IOException {
    Product p1 = new ProductImpl();
    p1.setUrl("/hot-sauces/sudden_death_sauce");
    Sku s1 = new SkuImpl();
    p1.setDefaultSku(s1);
    Product p2 = new ProductImpl();
    p2.setUrl("/merchandise/hawt_like_a_habanero_mens");
    Sku s2 = new SkuImpl();
    s2.setUrlKey("/black_s");
    s2.setProduct(p2);
    Sku s3 = new SkuImpl();
    s3.setUrlKey("/black_m");
    s3.setProduct(p2);
    Sku s4 = new SkuImpl();
    s4.setUrlKey("/black_l");
    s4.setProduct(p2);
    List<Sku> skus = new ArrayList<Sku>();
    skus.add(s1);
    skus.add(s2);
    skus.add(s3);
    skus.add(s4);
    SkuDao skuDao = EasyMock.createMock(SkuDao.class);
    EasyMock.expect(skuDao.readAllActiveSkus(EasyMock.eq(0), EasyMock.eq(5))).andReturn(skus);
    EasyMock.replay(skuDao);
    SkuSiteMapGenerator ssmg = new SkuSiteMapGenerator();
    ssmg.setSkuDao(skuDao);
    ssmg.setPageSize(5);
    SiteMapGeneratorConfiguration smgc = new SiteMapGeneratorConfigurationImpl();
    smgc.setDisabled(false);
    smgc.setSiteMapGeneratorType(SiteMapGeneratorType.SKU);
    smgc.setSiteMapChangeFreq(SiteMapChangeFreqType.HOURLY);
    smgc.setSiteMapPriority(SiteMapPriorityType.POINT5);
    testGenerator(smgc, ssmg);
    File file1 = fileService.getResource("/sitemap_index.xml");
    File file2 = fileService.getResource("/sitemap1.xml");
    File file3 = fileService.getResource("/sitemap2.xml");
    compareFiles(file1, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap_index.xml");
    compareFiles(file2, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap1.xml");
    compareFiles(file3, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap2.xml");
}
Also used : SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) SkuDao(org.broadleafcommerce.core.catalog.dao.SkuDao) Sku(org.broadleafcommerce.core.catalog.domain.Sku) SiteMapGeneratorConfigurationImpl(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfigurationImpl) SiteMapGeneratorConfiguration(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfiguration) File(java.io.File) Test(org.junit.Test) SiteMapGeneratorTest(org.broadleafcommerce.common.sitemap.service.SiteMapGeneratorTest)

Aggregations

ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)18 Product (org.broadleafcommerce.core.catalog.domain.Product)16 Sku (org.broadleafcommerce.core.catalog.domain.Sku)16 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)11 ArrayList (java.util.ArrayList)9 Money (org.broadleafcommerce.common.money.Money)8 Category (org.broadleafcommerce.core.catalog.domain.Category)7 CategoryImpl (org.broadleafcommerce.core.catalog.domain.CategoryImpl)7 CategoryProductXref (org.broadleafcommerce.core.catalog.domain.CategoryProductXref)5 CategoryProductXrefImpl (org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl)5 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)5 Calendar (java.util.Calendar)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 OrderImpl (org.broadleafcommerce.core.order.domain.OrderImpl)4 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)3 PromotableOrderImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl)3 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)3 Order (org.broadleafcommerce.core.order.domain.Order)3 OrderItemPriceDetail (org.broadleafcommerce.core.order.domain.OrderItemPriceDetail)3 OrderItemPriceDetailImpl (org.broadleafcommerce.core.order.domain.OrderItemPriceDetailImpl)3