Search in sources :

Example 66 with Customer

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

the class CustomerPhoneControllerTest method viewExistingCustomerPhoneFromController.

@Test(groups = "viewExistingCustomerPhoneFromController", dependsOnGroups = "createCustomerPhoneFromController")
@Transactional
public void viewExistingCustomerPhoneFromController() {
    List<CustomerPhone> phones_1 = customerPhoneService.readAllCustomerPhonesByCustomerId(userId);
    PhoneNameForm pnf = new PhoneNameForm();
    BindingResult errors = new BeanPropertyBindingResult(pnf, "phoneNameForm");
    Customer customer = customerService.readCustomerByUsername("customer1");
    request = this.getNewServletInstance();
    request.setAttribute(CustomerStateRequestProcessor.getCustomerRequestAttributeName(), customer);
    String view = customerPhoneController.viewPhone(phones_1.get(0).getId(), request, pnf, errors);
    assert (view.indexOf(SUCCESS) >= 0);
    assert (request.getAttribute("customerPhoneId").equals(phones_1.get(0).getId()));
}
Also used : CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) Customer(org.broadleafcommerce.profile.core.domain.Customer) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 67 with Customer

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

the class OfferServiceTest method createTestOrderWithOfferAndGiftWrap.

private Order createTestOrderWithOfferAndGiftWrap() throws PricingException {
    Customer customer = customerService.createCustomerFromId(null);
    Order order = orderService.createNewCartForCustomer(customer);
    customerService.saveCustomer(order.getCustomer());
    createCountry();
    createState();
    Address address = new AddressImpl();
    address.setAddressLine1("123 Test Rd");
    address.setCity("Dallas");
    address.setFirstName("Jeff");
    address.setLastName("Fischer");
    address.setPostalCode("75240");
    address.setPrimaryPhone("972-978-9067");
    address.setState(stateService.findStateByAbbreviation("KY"));
    address.setCountry(countryService.findCountryByAbbreviation("US"));
    address.setIsoCountrySubdivision("US-KY");
    address.setIsoCountryAlpha2(isoService.findISOCountryByAlpha2Code("US"));
    FulfillmentGroup group = new FulfillmentGroupImpl();
    group.setAddress(address);
    group.setIsShippingPriceTaxable(true);
    List<FulfillmentGroup> groups = new ArrayList<FulfillmentGroup>();
    FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
    option.setPrice(new Money("8.50"));
    option.setFulfillmentType(FulfillmentType.PHYSICAL_SHIP);
    group.setFulfillmentOption(option);
    group.setFulfillmentOption(option);
    group.setOrder(order);
    groups.add(group);
    order.setFulfillmentGroups(groups);
    Money total = new Money(5D);
    group.setRetailShippingPrice(total);
    group.setShippingPrice(total);
    DiscreteOrderItem item1;
    {
        item1 = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Sku");
        sku.setRetailPrice(new Money(10D));
        sku.setDiscountable(true);
        sku = catalogService.saveSku(sku);
        item1.setSku(sku);
        item1.setQuantity(2);
        item1.setOrder(order);
        item1.setOrderItemType(OrderItemType.DISCRETE);
        item1 = (DiscreteOrderItem) orderItemService.saveOrderItem(item1);
        order.addOrderItem(item1);
        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item1);
        fgItem.setQuantity(2);
        // fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
    }
    {
        DiscreteOrderItem item = new DiscreteOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test Product 2");
        sku.setRetailPrice(new Money(20D));
        sku.setDiscountable(true);
        sku = catalogService.saveSku(sku);
        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.setOrderItemType(OrderItemType.DISCRETE);
        item = (DiscreteOrderItem) orderItemService.saveOrderItem(item);
        order.addOrderItem(item);
        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item);
        fgItem.setQuantity(1);
        // fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
    }
    {
        GiftWrapOrderItem item = new GiftWrapOrderItemImpl();
        Sku sku = new SkuImpl();
        sku.setName("Test GiftWrap");
        sku.setRetailPrice(new Money(1D));
        sku.setDiscountable(true);
        sku = catalogService.saveSku(sku);
        item.setSku(sku);
        item.setQuantity(1);
        item.setOrder(order);
        item.getWrappedItems().add(item1);
        item.setOrderItemType(OrderItemType.GIFTWRAP);
        item = (GiftWrapOrderItem) orderItemService.saveOrderItem(item);
        order.addOrderItem(item);
        FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
        fgItem.setFulfillmentGroup(group);
        fgItem.setOrderItem(item);
        fgItem.setQuantity(1);
        // fgItem.setPrice(new Money(0D));
        group.addFulfillmentGroupItem(fgItem);
    }
    return order;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) FulfillmentGroupImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl) Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) DiscreteOrderItemImpl(org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl) ArrayList(java.util.ArrayList) Money(org.broadleafcommerce.common.money.Money) SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) FixedPriceFulfillmentOption(org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) GiftWrapOrderItem(org.broadleafcommerce.core.order.domain.GiftWrapOrderItem) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) GiftWrapOrderItemImpl(org.broadleafcommerce.core.order.domain.GiftWrapOrderItemImpl) Sku(org.broadleafcommerce.core.catalog.domain.Sku) FixedPriceFulfillmentOptionImpl(org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOptionImpl) FulfillmentGroupItemImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)

Example 68 with Customer

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

the class CartTest method testMergeWithInactiveAnonymousCart.

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

Example 69 with Customer

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

the class OrderBaseTest method createNamedCustomer.

protected Customer createNamedCustomer() {
    Customer customer = customerService.createCustomerFromId(null);
    customer.setUsername(String.valueOf(customer.getId()));
    return customer;
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer)

Example 70 with Customer

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

the class OrderBaseTest method setUpNamedOrder.

public Order setUpNamedOrder() throws AddToCartException {
    Customer customer = customerService.saveCustomer(createNamedCustomer());
    Order order = orderService.createNamedOrderForCustomer("Boxes Named Order", customer);
    Product newProduct = addTestProduct("Cube Box", "Boxes");
    Category newCategory = newProduct.getDefaultCategory();
    order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 2), 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)

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