Search in sources :

Example 1 with PhoneNameForm

use of org.broadleafcommerce.profile.web.core.model.PhoneNameForm 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 PhoneNameForm

use of org.broadleafcommerce.profile.web.core.model.PhoneNameForm 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 3 with PhoneNameForm

use of org.broadleafcommerce.profile.web.core.model.PhoneNameForm in project BroadleafCommerce by BroadleafCommerce.

the class CustomerPhoneControllerTest method viewCustomerPhoneFromController.

@Test(groups = "viewCustomerPhoneFromController")
public void viewCustomerPhoneFromController() {
    PhoneNameForm pnf = new PhoneNameForm();
    BindingResult errors = new BeanPropertyBindingResult(pnf, "phoneNameForm");
    request = this.getNewServletInstance();
    String view = customerPhoneController.viewPhone(null, request, pnf, errors);
    assert (view.indexOf(SUCCESS) >= 0);
    assert (request.getAttribute("customerPhoneId") == null);
}
Also used : BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) Test(org.testng.annotations.Test)

Example 4 with PhoneNameForm

use of org.broadleafcommerce.profile.web.core.model.PhoneNameForm in project BroadleafCommerce by BroadleafCommerce.

the class CustomerPhoneController method initPhoneNameForm.

/**
 * Called before each and every request comes into the controller, and is placed on the request for use by those methods.
 *
 * @param request
 * @param model
 *
 * @return
 */
@ModelAttribute("phoneNameForm")
public PhoneNameForm initPhoneNameForm(HttpServletRequest request, Model model) {
    PhoneNameForm form = new PhoneNameForm();
    form.setPhone((Phone) entityConfiguration.createEntityInstance("org.broadleafcommerce.profile.core.domain.Phone"));
    return form;
}
Also used : PhoneNameForm(org.broadleafcommerce.profile.web.core.model.PhoneNameForm) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Aggregations

PhoneNameForm (org.broadleafcommerce.profile.web.core.model.PhoneNameForm)4 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)2 BindingResult (org.springframework.validation.BindingResult)2 Test (org.testng.annotations.Test)2 Customer (org.broadleafcommerce.profile.core.domain.Customer)1 CustomerPhone (org.broadleafcommerce.profile.core.domain.CustomerPhone)1 Phone (org.broadleafcommerce.profile.core.domain.Phone)1 PhoneImpl (org.broadleafcommerce.profile.core.domain.PhoneImpl)1 Transactional (org.springframework.transaction.annotation.Transactional)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1 DataProvider (org.testng.annotations.DataProvider)1