Search in sources :

Example 71 with Customer

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

the class OrderTest method testReadOrdersForCustomer.

@Test(groups = { "testReadOrdersForCustomer" }, dependsOnGroups = { "findNamedOrderForCustomer" })
@Transactional
public void testReadOrdersForCustomer() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    order.setStatus(OrderStatus.IN_PROCESS);
    order = orderService.save(order, false);
    List<Order> newOrders = orderService.findOrdersForCustomer(customer, OrderStatus.IN_PROCESS);
    boolean containsOrder = false;
    if (newOrders.contains(order)) {
        containsOrder = true;
    }
    assert containsOrder == true;
    containsOrder = false;
    newOrders = orderService.findOrdersForCustomer(customer, null);
    if (newOrders.contains(order)) {
        containsOrder = true;
    }
    assert containsOrder == true;
}
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 72 with Customer

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

the class OrderTest method testSubmitOrder.

@Test(groups = { "testSubmitOrder" }, dependsOnGroups = { "findNamedOrderForCustomer" })
public void testSubmitOrder() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    order.setStatus(OrderStatus.IN_PROCESS);
    order = orderService.save(order, false);
    Long orderId = order.getId();
    Order confirmedOrder = orderService.confirmOrder(order);
    confirmedOrder = orderService.findOrderById(confirmedOrder.getId());
    Long confirmedOrderId = confirmedOrder.getId();
    assert orderId.equals(confirmedOrderId);
    assert confirmedOrder.getStatus().equals(OrderStatus.SUBMITTED);
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test)

Example 73 with Customer

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

the class OrderTest method testOrderPaymentInfos.

@Test(groups = { "testOrderPaymentInfos" }, dataProvider = "basicPaymentInfo", dataProviderClass = PaymentInfoDataProvider.class)
@Transactional
public void testOrderPaymentInfos(OrderPayment info) throws PricingException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNewCartForCustomer(customer);
    info = orderService.addPaymentToOrder(order, info, null);
    boolean foundInfo = false;
    assert order.getPayments() != null;
    for (OrderPayment testInfo : order.getPayments()) {
        if (testInfo.equals(info)) {
            foundInfo = true;
        }
    }
    assert foundInfo == true;
    assert orderService.findPaymentsForOrder(order) != null;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 74 with Customer

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

the class OrderTest method findCartForAnonymousCustomer.

@Test(groups = { "findCartForAnonymousCustomer" }, dependsOnGroups = { "getOrdersForCustomer" })
public void findCartForAnonymousCustomer() {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.findCartForCustomer(customer);
    assert order == null;
    order = orderService.createNewCartForCustomer(customer);
    Long orderId = order.getId();
    Order newOrder = orderService.findOrderById(orderId);
    assert newOrder != null;
    assert newOrder.getCustomer() != null;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test)

Example 75 with Customer

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

the class OrderTest method findCurrentCartForCustomer.

@Test(groups = { "findCurrentCartForCustomer" }, dependsOnGroups = { "readCustomer", "createPhone", "createCartForCustomer" })
@Transactional
@Rollback(false)
public void findCurrentCartForCustomer() {
    String userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    Order order = orderService.findCartForCustomer(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)

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