use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerPasswordCustomPersistenceHandler method update.
@Override
public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
Entity entity = persistencePackage.getEntity();
Customer customer = customerService.readCustomerByUsername(entity.findProperty("username").getValue());
if (StringUtils.isEmpty(customer.getEmailAddress())) {
throw new ServiceException("Unable to update password because an email address is not available for this customer. An email address is required to send the customer the new system generated password.");
}
PasswordReset passwordReset = new PasswordReset();
passwordReset.setUsername(entity.findProperty("username").getValue());
passwordReset.setPasswordChangeRequired(false);
passwordReset.setEmail(customer.getEmailAddress());
passwordReset.setPasswordLength(22);
passwordReset.setSendResetEmailReliableAsync(false);
customer = customerService.resetPassword(passwordReset);
return entity;
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class OrderToPaymentRequestDTOServiceImpl method populateCustomerInfo.
@Override
public void populateCustomerInfo(Order order, PaymentRequestDTO requestDTO) {
Customer customer = order.getCustomer();
paymentRequestDTOService.populateCustomerInfo(requestDTO, customer, order.getEmailAddress());
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class PaymentInfoServiceTest method createTestPayment.
@Test(groups = { "testCreatePaymentInfo" }, dependsOnGroups = { "createPaymentInfo" })
@Transactional
public void createTestPayment() {
userName = "customer1";
OrderPayment paymentInfo = paymentInfoService.create();
Customer customer = customerService.readCustomerByUsername(userName);
List<CustomerAddress> addresses = customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId());
Address address = null;
if (!addresses.isEmpty())
address = addresses.get(0).getAddress();
Order salesOrder = orderService.findCartForCustomer(customer);
paymentInfo.setBillingAddress(address);
paymentInfo.setOrder(salesOrder);
paymentInfo.setType(PaymentType.CREDIT_CARD);
assert paymentInfo != null;
paymentInfo = paymentInfoService.save(paymentInfo);
assert paymentInfo.getId() != null;
Long paymentInfoId = paymentInfo.getId();
paymentInfoService.delete(paymentInfo);
paymentInfo = paymentInfoService.readPaymentById(paymentInfoId);
assert paymentInfo == null;
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class PaymentInfoServiceTest method createPayment.
@Test(groups = { "createPaymentInfo" }, dataProvider = "basicPaymentInfo", dataProviderClass = PaymentInfoDataProvider.class, dependsOnGroups = { "readCustomer", "createOrder" })
@Rollback(false)
@Transactional
public void createPayment(OrderPayment payment) {
userName = "customer1";
Customer customer = customerService.readCustomerByUsername(userName);
List<CustomerAddress> addresses = customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId());
Address address = null;
if (!addresses.isEmpty())
address = addresses.get(0).getAddress();
Order salesOrder = orderService.createNewCartForCustomer(customer);
payment.setBillingAddress(address);
payment.setOrder(salesOrder);
payment.setType(PaymentType.CREDIT_CARD);
assert payment.getId() == null;
payment = paymentInfoService.save(payment);
assert payment.getId() != null;
this.paymentInfo = payment;
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerPhoneControllerTest method createCustomerPhoneFromController.
@Test(groups = "createCustomerPhoneFromController", dataProvider = "setupCustomerPhoneControllerData", dataProviderClass = CustomerPhoneControllerTestDataProvider.class, dependsOnGroups = "readCustomer")
@Transactional
@Commit
public void createCustomerPhoneFromController(PhoneNameForm phoneNameForm) {
BindingResult errors = new BeanPropertyBindingResult(phoneNameForm, "phoneNameForm");
Customer customer = customerService.readCustomerByUsername("customer1");
request = this.getNewServletInstance();
request.setAttribute(CustomerStateRequestProcessor.getCustomerRequestAttributeName(), customer);
String view = customerPhoneController.savePhone(phoneNameForm, errors, request, null, null);
assert (view.indexOf(SUCCESS) >= 0);
List<CustomerPhone> phones = customerPhoneService.readAllCustomerPhonesByCustomerId(userId);
boolean inPhoneList = false;
Long id = (Long) request.getAttribute("customerPhoneId");
assert (id != null);
for (CustomerPhone p : phones) {
if ((p.getPhoneName() != null) && p.getPhoneName().equals(phoneNameForm.getPhoneName())) {
inPhoneList = true;
}
}
assert (inPhoneList == true);
createdCustomerPhoneIds.add(id);
}
Aggregations