Search in sources :

Example 61 with Customer

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;
}
Also used : Entity(org.broadleafcommerce.openadmin.dto.Entity) ServiceException(org.broadleafcommerce.common.exception.ServiceException) Customer(org.broadleafcommerce.profile.core.domain.Customer) PasswordReset(org.broadleafcommerce.common.security.util.PasswordReset)

Example 62 with Customer

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());
}
Also used : Customer(org.broadleafcommerce.profile.core.domain.Customer)

Example 63 with Customer

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;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) OrderPayment(org.broadleafcommerce.core.payment.domain.OrderPayment) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 64 with Customer

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;
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Customer(org.broadleafcommerce.profile.core.domain.Customer) CustomerAddress(org.broadleafcommerce.profile.core.domain.CustomerAddress) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 65 with Customer

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);
}
Also used : CustomerPhone(org.broadleafcommerce.profile.core.domain.CustomerPhone) BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) Customer(org.broadleafcommerce.profile.core.domain.Customer) Commit(org.springframework.test.annotation.Commit) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Customer (org.broadleafcommerce.profile.core.domain.Customer)98 Order (org.broadleafcommerce.core.order.domain.Order)41 Transactional (org.springframework.transaction.annotation.Transactional)34 Test (org.testng.annotations.Test)33 Address (org.broadleafcommerce.profile.core.domain.Address)14 Rollback (org.springframework.test.annotation.Rollback)11 HashMap (java.util.HashMap)9 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)9 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)8 MergeCartResponse (org.broadleafcommerce.core.order.service.call.MergeCartResponse)6 ArrayList (java.util.ArrayList)5 Money (org.broadleafcommerce.common.money.Money)5 Category (org.broadleafcommerce.core.catalog.domain.Category)5 Product (org.broadleafcommerce.core.catalog.domain.Product)5 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)5 CommonSetupBaseTest (org.broadleafcommerce.test.CommonSetupBaseTest)5 CustomerImpl (org.broadleafcommerce.profile.core.domain.CustomerImpl)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 ServiceException (org.broadleafcommerce.common.exception.ServiceException)3 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)3