Search in sources :

Example 1 with PhoneImpl

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

the class CustomerPhoneControllerTestDataProvider method createCustomerPhone.

@DataProvider(name = "setupCustomerPhoneControllerData")
public static Object[][] createCustomerPhone() {
    PhoneNameForm pnf1 = new PhoneNameForm();
    Phone phone1 = new PhoneImpl();
    phone1.setPhoneNumber("111-222-3333");
    pnf1.setPhone(phone1);
    pnf1.setPhoneName("phone_1");
    PhoneNameForm pnf2 = new PhoneNameForm();
    Phone phone2 = new PhoneImpl();
    phone2.setPhoneNumber("222-333-4444");
    pnf2.setPhone(phone2);
    pnf2.setPhoneName("phone_2");
    return new Object[][] { new Object[] { pnf1 }, new Object[] { pnf2 } };
}
Also used : PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) Phone(org.broadleafcommerce.profile.core.domain.Phone) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) DataProvider(org.testng.annotations.DataProvider)

Example 2 with PhoneImpl

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

the class CustomerPhoneDataProvider method createCustomerPhone.

@DataProvider(name = "setupCustomerPhone")
public static Object[][] createCustomerPhone() {
    CustomerPhone cp1 = new CustomerPhoneImpl();
    Phone phone1 = new PhoneImpl();
    phone1.setPhoneNumber("111-111-1111");
    cp1.setPhone(phone1);
    cp1.setPhoneName("phone1");
    CustomerPhone cp2 = new CustomerPhoneImpl();
    Phone phone2 = new PhoneImpl();
    phone1.setPhoneNumber("222-222-2222");
    cp2.setPhone(phone2);
    cp2.setPhoneName("phone2");
    return new Object[][] { new Object[] { cp1 }, new Object[] { cp2 } };
}
Also used : CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) Phone(org.broadleafcommerce.profile.core.domain.Phone) CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) CustomerPhoneImpl(org.broadleafcommerce.profile.core.domain.CustomerPhoneImpl) CustomerPhoneImpl(org.broadleafcommerce.profile.core.domain.CustomerPhoneImpl) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) DataProvider(org.testng.annotations.DataProvider)

Example 3 with PhoneImpl

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

the class InitBinderServiceImpl method configAddressInitBinder.

@Override
public void configAddressInitBinder(ServletRequestDataBinder binder) {
    /**
     * @deprecated - address.setState() is deprecated in favor of ISO standardization
     * This is here for legacy compatibility
     */
    binder.registerCustomEditor(State.class, "address.state", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            if (StringUtils.isNotEmpty(text)) {
                State state = stateService.findStateByAbbreviation(text);
                setValue(state);
            } else {
                setValue(null);
            }
        }
    });
    /**
     * @deprecated - address.setCountry() is deprecated in favor of ISO standardization
     * This is here for legacy compatibility
     */
    binder.registerCustomEditor(Country.class, "address.country", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            if (StringUtils.isNotEmpty(text)) {
                Country country = countryService.findCountryByAbbreviation(text);
                setValue(country);
            } else {
                setValue(null);
            }
        }
    });
    binder.registerCustomEditor(ISOCountry.class, "address.isoCountryAlpha2", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            if (StringUtils.isNotEmpty(text)) {
                ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code(text);
                setValue(isoCountry);
            } else {
                setValue(null);
            }
        }
    });
    binder.registerCustomEditor(Phone.class, "address.phonePrimary", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            Phone phone = new PhoneImpl();
            phone.setPhoneNumber(text);
            setValue(phone);
        }
    });
    binder.registerCustomEditor(Phone.class, "address.phoneSecondary", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            Phone phone = new PhoneImpl();
            phone.setPhoneNumber(text);
            setValue(phone);
        }
    });
    binder.registerCustomEditor(Phone.class, "address.phoneFax", new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) {
            Phone phone = new PhoneImpl();
            phone.setPhoneNumber(text);
            setValue(phone);
        }
    });
}
Also used : State(org.broadleafcommerce.profile.core.domain.State) Phone(org.broadleafcommerce.profile.core.domain.Phone) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) PropertyEditorSupport(java.beans.PropertyEditorSupport) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Example 4 with PhoneImpl

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

the class PhoneDataProvider method createPhone.

@DataProvider(name = "setupPhone")
public static Object[][] createPhone() {
    Phone phone = new PhoneImpl();
    phone.setPhoneNumber("999-999-9999");
    return new Object[][] { new Object[] { phone } };
}
Also used : Phone(org.broadleafcommerce.profile.core.domain.Phone) PhoneImpl(org.broadleafcommerce.profile.core.domain.PhoneImpl) DataProvider(org.testng.annotations.DataProvider)

Example 5 with PhoneImpl

use of org.broadleafcommerce.profile.core.domain.PhoneImpl 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

Phone (org.broadleafcommerce.profile.core.domain.Phone)7 PhoneImpl (org.broadleafcommerce.profile.core.domain.PhoneImpl)7 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)3 Country (org.broadleafcommerce.profile.core.domain.Country)3 Customer (org.broadleafcommerce.profile.core.domain.Customer)3 State (org.broadleafcommerce.profile.core.domain.State)3 ISOCountryImpl (org.broadleafcommerce.common.i18n.domain.ISOCountryImpl)2 Money (org.broadleafcommerce.common.money.Money)2 Category (org.broadleafcommerce.core.catalog.domain.Category)2 CategoryImpl (org.broadleafcommerce.core.catalog.domain.CategoryImpl)2 CategoryProductXref (org.broadleafcommerce.core.catalog.domain.CategoryProductXref)2 CategoryProductXrefImpl (org.broadleafcommerce.core.catalog.domain.CategoryProductXrefImpl)2 Product (org.broadleafcommerce.core.catalog.domain.Product)2 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)2 Sku (org.broadleafcommerce.core.catalog.domain.Sku)2 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)2 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)2 PromotableOrderImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderImpl)2 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)2 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)2