Search in sources :

Example 11 with CustomerPhone

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

the class CustomerPhoneControllerTest method makePhoneDefaultOnCustomerPhoneController.

@Test(groups = "makePhoneDefaultOnCustomerPhoneController", dependsOnGroups = "createCustomerPhoneFromController")
@Transactional
public void makePhoneDefaultOnCustomerPhoneController() {
    Long nonDefaultPhoneId = null;
    List<CustomerPhone> phones_1 = customerPhoneService.readAllCustomerPhonesByCustomerId(userId);
    for (CustomerPhone p : phones_1) {
        if (!p.getPhone().isDefault()) {
            nonDefaultPhoneId = p.getId();
            break;
        }
    }
    request = this.getNewServletInstance();
    String view = customerPhoneController.makePhoneDefault(nonDefaultPhoneId, request);
    assert (view.indexOf("viewPhone") >= 0);
    List<CustomerPhone> phones = customerPhoneService.readAllCustomerPhonesByCustomerId(userId);
    for (CustomerPhone p : phones) {
        if (p.getId() == nonDefaultPhoneId) {
            assert (p.getPhone().isDefault());
            break;
        }
    }
}
Also used : CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with CustomerPhone

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

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

CustomerPhone (org.broadleafcommerce.profile.core.domain.CustomerPhone)13 Transactional (org.springframework.transaction.annotation.Transactional)5 Test (org.testng.annotations.Test)4 Customer (org.broadleafcommerce.profile.core.domain.Customer)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Phone (org.broadleafcommerce.profile.core.domain.Phone)2 PhoneImpl (org.broadleafcommerce.profile.core.domain.PhoneImpl)2 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)2 BindingResult (org.springframework.validation.BindingResult)2 Query (javax.persistence.Query)1 CustomerPhoneImpl (org.broadleafcommerce.profile.core.domain.CustomerPhoneImpl)1 PhoneNameForm (org.broadleafcommerce.profile.web.core.model.PhoneNameForm)1 Commit (org.springframework.test.annotation.Commit)1 Rollback (org.springframework.test.annotation.Rollback)1 DataProvider (org.testng.annotations.DataProvider)1