Search in sources :

Example 11 with Customer

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

the class FulfillmentGroupDaoTest method createDefaultFulfillmentGroup.

@Test(groups = "createDefaultFulfillmentGroup", dataProvider = "basicFulfillmentGroup", dataProviderClass = FulfillmentGroupDataProvider.class)
@Transactional
@Rollback(false)
public void createDefaultFulfillmentGroup(FulfillmentGroup fulfillmentGroup) {
    Customer customer = createCustomerWithBasicOrderAndAddresses();
    Address address = (customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId())).get(0).getAddress();
    Order salesOrder = orderDao.readOrdersForCustomer(customer.getId()).get(0);
    FulfillmentGroup newFG = fulfillmentGroupDao.createDefault();
    newFG.setAddress(address);
    newFG.setRetailShippingPrice(fulfillmentGroup.getRetailShippingPrice());
    newFG.setMethod(fulfillmentGroup.getMethod());
    newFG.setService(fulfillmentGroup.getService());
    newFG.setOrder(salesOrder);
    newFG.setReferenceNumber(fulfillmentGroup.getReferenceNumber());
    assert newFG.getId() == null;
    fulfillmentGroup = fulfillmentGroupService.save(newFG);
    assert fulfillmentGroup.getId() != null;
    defaultFulfillmentGroupOrderId = salesOrder.getId();
    defaultFulfillmentGroupId = fulfillmentGroup.getId();
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) CommonSetupBaseTest(org.broadleafcommerce.test.CommonSetupBaseTest) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Customer

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

the class FulfillmentGroupItemDaoTest method createDefaultFulfillmentGroup.

@Test(groups = "createItemFulfillmentGroup", dataProvider = "basicFulfillmentGroup", dataProviderClass = FulfillmentGroupDataProvider.class, dependsOnGroups = { "createOrder", "createCustomerAddress" })
@Rollback(false)
@Transactional
public void createDefaultFulfillmentGroup(FulfillmentGroup fulfillmentGroup) {
    String userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    Address address = (customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId())).get(0).getAddress();
    salesOrder = orderDao.createNewCartForCustomer(customer);
    FulfillmentGroup newFG = fulfillmentGroupDao.createDefault();
    newFG.setAddress(address);
    newFG.setRetailShippingPrice(fulfillmentGroup.getRetailShippingPrice());
    newFG.setMethod(fulfillmentGroup.getMethod());
    newFG.setService(fulfillmentGroup.getService());
    newFG.setOrder(salesOrder);
    newFG.setReferenceNumber(fulfillmentGroup.getReferenceNumber());
    assert newFG.getId() == null;
    this.fulfillmentGroup = fulfillmentGroupService.save(newFG);
    assert this.fulfillmentGroup.getId() != null;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with Customer

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

the class OrderDaoTest method createOrder.

@Test(groups = { "createOrder" }, dataProvider = "basicOrder", dataProviderClass = OrderDataProvider.class, dependsOnGroups = { "readCustomer", "createPhone" })
@Rollback(false)
@Transactional
public void createOrder(Order order) {
    userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    assert order.getId() == null;
    order.setCustomer(customer);
    order = orderDao.save(order);
    assert order.getId() != null;
    orderId = order.getId();
}
Also used : 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 14 with Customer

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

the class OrderDaoTest method readOrdersForCustomer.

@Test(groups = { "readOrdersForCustomer" }, dependsOnGroups = { "readCustomer", "createOrder" })
@Transactional
public void readOrdersForCustomer() {
    userName = "customer1";
    Customer user = customerService.readCustomerByUsername(userName);
    List<Order> orders = orderDao.readOrdersForCustomer(user.getId());
    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 15 with Customer

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

the class CartTest method testMergeWithNoAnonymousCart.

@Transactional
@Test(groups = { "testMergeCart" })
public void testMergeWithNoAnonymousCart() throws PricingException, RemoveFromCartException, AddToCartException {
    Order anonymousCart = null;
    Order customerCart = setUpCartWithActiveSku();
    Customer customer = customerCart.getCustomer();
    MergeCartResponse response = mergeCartService.mergeCart(customer, anonymousCart);
    assert response.getOrder().getOrderItems().size() == 1;
    assert response.getOrder().getId().equals(customerCart.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)

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