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;
}
}
}
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()));
}
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();
}
Aggregations