Search in sources :

Example 36 with Customer

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

the class CustomerDataProvider method createCustomers.

@DataProvider(name = "setupCustomers")
public static Object[][] createCustomers() {
    Customer customer1 = new CustomerImpl();
    customer1.setPassword("customer1Password");
    customer1.setUsername("customer1");
    Customer customer2 = new CustomerImpl();
    customer2.setPassword("customer2Password");
    customer2.setUsername("customer2");
    return new Object[][] { new Object[] { customer1 }, new Object[] { customer2 } };
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerImpl(org.broadleafcommerce.profile.core.domain.CustomerImpl) DataProvider(org.testng.annotations.DataProvider)

Example 37 with Customer

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

the class OrderTest method getOrdersForCustomer.

@Test(groups = { "getOrdersForCustomer" }, dependsOnGroups = { "readCustomer", "findCurrentCartForCustomer" })
@Transactional
public void getOrdersForCustomer() {
    String username = "customer1";
    Customer customer = customerService.readCustomerByUsername(username);
    List<Order> orders = orderService.findOrdersForCustomer(customer);
    assert orders != null;
    assert orders.size() > 0;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with Customer

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

the class OrderTest method findNamedOrderForCustomer.

@Test(groups = { "findNamedOrderForCustomer" }, dependsOnGroups = { "findOrderByOrderNumber" })
@Transactional
public void findNamedOrderForCustomer() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    order.setStatus(OrderStatus.NAMED);
    order.setName("COOL ORDER");
    order = orderService.save(order, false);
    Long orderId = order.getId();
    Order newOrder = orderService.findNamedOrderForCustomer("COOL ORDER", customer);
    assert newOrder.getId().equals(orderId);
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with Customer

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

the class OrderTest method createCartForCustomer.

@Test(groups = { "createCartForCustomer" }, dependsOnGroups = { "readCustomer", "createPhone" })
@Transactional
@Rollback(false)
public void createCartForCustomer() {
    String userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    Order order = orderService.createNewCartForCustomer(customer);
    assert order != null;
    assert order.getId() != null;
    this.orderId = order.getId();
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with Customer

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

the class OrderTest method findOrderByOrderNumber.

@Test(groups = { "findOrderByOrderNumber" }, dependsOnGroups = { "findCartForAnonymousCustomer" })
@Transactional
public void findOrderByOrderNumber() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    order.setOrderNumber("3456");
    order = orderService.save(order, false);
    Long orderId = order.getId();
    Order newOrder = orderService.findOrderByOrderNumber("3456");
    assert newOrder.getId().equals(orderId);
    Order nullOrder = orderService.findOrderByOrderNumber(null);
    assert nullOrder == null;
    nullOrder = orderService.findOrderByOrderNumber("");
    assert nullOrder == null;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

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