Search in sources :

Example 76 with Customer

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

the class OrderTest method testNamedOrderForCustomer.

@Test(groups = { "testNamedOrderForCustomer" }, dependsOnGroups = { "testOrderProperties" })
public void testNamedOrderForCustomer() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    customer = customerService.saveCustomer(customer);
    Order order = orderService.createNamedOrderForCustomer("Birthday Order", customer);
    Long orderId = order.getId();
    assert order != null;
    assert order.getName().equals("Birthday Order");
    assert order.getCustomer().equals(customer);
    orderService.cancelOrder(order);
    assert orderService.findOrderById(orderId) == null;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test)

Example 77 with Customer

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

the class OrderTest method testOrderProperties.

@Test(groups = { "testOrderProperties" }, dependsOnGroups = { "testReadOrdersForCustomer" })
public void testOrderProperties() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    assert order.getSubTotal() == null;
    assert order.getTotal() == null;
    Calendar testCalendar = Calendar.getInstance();
    order.setSubmitDate(testCalendar.getTime());
    assert order.getSubmitDate().equals(testCalendar.getTime());
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Customer(org.broadleafcommerce.profile.core.domain.Customer) Calendar(java.util.Calendar) Test(org.testng.annotations.Test)

Example 78 with Customer

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

the class CommonSetupBaseTest method createCustomerWithAddress.

/**
 * Creates a country, state, and customer with the supplied customerAddress
 * @param customerAddress
 * @return customer created
 */
public CustomerAddress createCustomerWithAddress(CustomerAddress customerAddress) {
    createCountry();
    createState();
    Customer customer = createCustomer();
    customer.setUsername(String.valueOf(customer.getId()));
    customerAddress.setCustomer(customer);
    return saveCustomerAddress(customerAddress);
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer)

Example 79 with Customer

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

the class CustomerAddressTest method createCustomerAddress.

/**
 * This method only exists because so many other tests depend on it, but should be removed once tests are more isolated
 * @param customerAddress
 */
@Deprecated
@Test(groups = "createCustomerAddress", dataProvider = "setupCustomerAddress", dataProviderClass = CustomerAddressDataProvider.class, dependsOnGroups = { "readCustomer", "createCountry", "createState" })
@Transactional
@Rollback(false)
public void createCustomerAddress(CustomerAddress customerAddress) {
    userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    assert customerAddress.getId() == null;
    customerAddress.setCustomer(customer);
    State state = stateService.findStateByAbbreviation("KY");
    customerAddress.getAddress().setState(state);
    Country country = countryService.findCountryByAbbreviation("US");
    customerAddress.getAddress().setCountry(country);
    customerAddress.getAddress().setIsoCountrySubdivision("US-KY");
    ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code("US");
    customerAddress.getAddress().setIsoCountryAlpha2(isoCountry);
    customerAddress = customerAddressService.saveCustomerAddress(customerAddress);
    assert customer.equals(customerAddress.getCustomer());
    userId = customerAddress.getCustomer().getId();
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) State(org.broadleafcommerce.profile.core.domain.State) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) Test(org.testng.annotations.Test) CommonSetupBaseTest(org.broadleafcommerce.test.CommonSetupBaseTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 80 with Customer

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

the class CustomerPhoneTest method createCustomerPhone.

@Test(groups = "createCustomerPhone", dataProvider = "setupCustomerPhone", dataProviderClass = CustomerPhoneDataProvider.class, dependsOnGroups = "readCustomer")
@Transactional
@Rollback(false)
public void createCustomerPhone(CustomerPhone customerPhone) {
    userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    assert customerPhone.getId() == null;
    customerPhone.setCustomer(customer);
    Phone phone = new PhoneImpl();
    phone.setPhoneNumber("214-214-2134");
    customerPhone.setPhone(phone);
    customerPhone = customerPhoneService.saveCustomerPhone(customerPhone);
    assert customer.equals(customerPhone.getCustomer());
    userId = customerPhone.getCustomer().getId();
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer) Phone(org.broadleafcommerce.profile.core.domain.Phone) CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) 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