Search in sources :

Example 16 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class CartTest method testMergeWithBothCarts.

@Transactional
@Test(groups = { "testMergeCart" })
public void testMergeWithBothCarts() throws PricingException, RemoveFromCartException, AddToCartException {
    Order anonymousCart = setUpCartWithActiveSku();
    Order customerCart = setUpCartWithActiveSku();
    Customer customer = customerCart.getCustomer();
    MergeCartResponse response = mergeCartService.mergeCart(customer, anonymousCart);
    assert response.getOrder().getOrderItems().size() == 1;
    assert response.getOrder().getId().equals(anonymousCart.getId());
    assert response.isMerged() == false;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) MergeCartResponse(org.broadleafcommerce.core.order.service.call.MergeCartResponse) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class CartTest method testMergeWithNoCustomerCart.

@Transactional
@Test(groups = { "testMergeCart" })
public void testMergeWithNoCustomerCart() throws PricingException, RemoveFromCartException, AddToCartException {
    Order anonymousCart = setUpCartWithActiveSku();
    Order customerCart = null;
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    MergeCartResponse response = mergeCartService.mergeCart(customer, anonymousCart);
    assert response.getOrder().getOrderItems().size() == 1;
    assert response.getOrder().getId().equals(anonymousCart.getId());
    assert response.isMerged() == false;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) MergeCartResponse(org.broadleafcommerce.core.order.service.call.MergeCartResponse) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class OrderBaseTest method setUpCartWithActiveSku.

public Order setUpCartWithActiveSku() throws AddToCartException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNewCartForCustomer(customer);
    Product newProduct = addTestProduct("Plastic Crate Active", "Crates");
    Category newCategory = newProduct.getDefaultCategory();
    order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
    return order;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Category(org.broadleafcommerce.core.catalog.domain.Category) OrderItemRequestDTO(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO) Customer(org.broadleafcommerce.profile.core.domain.Customer) Product(org.broadleafcommerce.core.catalog.domain.Product)

Example 19 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class OrderBaseTest method setUpCartWithInactiveSku.

public Order setUpCartWithInactiveSku() throws AddToCartException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNewCartForCustomer(customer);
    Product newProduct = addTestProduct("Plastic Crate Should Be Inactive", "Crates");
    Category newCategory = newProduct.getDefaultCategory();
    order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
    // Make the SKU inactive
    newProduct.getDefaultSku().setActiveEndDate(DateUtils.addDays(new Date(), -1));
    catalogService.saveSku(newProduct.getDefaultSku());
    return order;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Category(org.broadleafcommerce.core.catalog.domain.Category) OrderItemRequestDTO(org.broadleafcommerce.core.order.service.call.OrderItemRequestDTO) Customer(org.broadleafcommerce.profile.core.domain.Customer) Product(org.broadleafcommerce.core.catalog.domain.Product) Date(java.util.Date)

Example 20 with Customer

use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.

the class CommonSetupBaseTest method createCustomerWithAddresses.

/**
 * Creates a country, state, and customer with some CustomerAddresses
 * @return customer created
 */
public Customer createCustomerWithAddresses() {
    createCountry();
    createState();
    CustomerAddress ca1 = new CustomerAddressImpl();
    Address address1 = new AddressImpl();
    address1.setAddressLine1("1234 Merit Drive");
    address1.setCity("Bozeman");
    address1.setPostalCode("75251");
    ca1.setAddress(address1);
    ca1.setAddressName("address1");
    CustomerAddress caResult = createCustomerWithAddress(ca1);
    assert caResult != null;
    assert caResult.getCustomer() != null;
    Customer customer = caResult.getCustomer();
    CustomerAddress ca2 = new CustomerAddressImpl();
    Address address2 = new AddressImpl();
    address2.setAddressLine1("12 Testing Drive");
    address2.setCity("Portland");
    address2.setPostalCode("75251");
    ca2.setAddress(address2);
    ca2.setAddressName("address2");
    ca2.setCustomer(customer);
    CustomerAddress addResult = saveCustomerAddress(ca2);
    assert addResult != null;
    return customer;
}
Also used : CustomerAddressImpl(org.broadleafcommerce.profile.core.domain.CustomerAddressImpl) Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) CustomerAddressImpl(org.broadleafcommerce.profile.core.domain.CustomerAddressImpl) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress)

Aggregations

Customer (org.broadleafcommerce.profile.core.domain.Customer)98 Order (org.broadleafcommerce.core.order.domain.Order)41 Transactional (org.springframework.transaction.annotation.Transactional)34 Test (org.testng.annotations.Test)33 Address (org.broadleafcommerce.profile.core.domain.Address)14 Rollback (org.springframework.test.annotation.Rollback)11 HashMap (java.util.HashMap)9 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)9 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)8 MergeCartResponse (org.broadleafcommerce.core.order.service.call.MergeCartResponse)6 ArrayList (java.util.ArrayList)5 Money (org.broadleafcommerce.common.money.Money)5 Category (org.broadleafcommerce.core.catalog.domain.Category)5 Product (org.broadleafcommerce.core.catalog.domain.Product)5 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)5 CommonSetupBaseTest (org.broadleafcommerce.test.CommonSetupBaseTest)5 CustomerImpl (org.broadleafcommerce.profile.core.domain.CustomerImpl)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)3