use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerAddressTest method readCustomerAddresses.
@Test(groups = "testCustomerAddress")
@Transactional
public void readCustomerAddresses() {
Customer customer = createCustomerWithAddresses();
List<CustomerAddress> customerAddressList = customerAddressService.readActiveCustomerAddressesByCustomerId(customer.getId());
for (CustomerAddress ca : customerAddressList) {
assert ca != null;
}
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerAddressTest method createNewDefaultAddress.
@Test(groups = "testCustomerAddress")
@Transactional
public void createNewDefaultAddress() {
Customer customer = createCustomerWithAddresses();
CustomerAddress ca = new CustomerAddressImpl();
Address address = new AddressImpl();
address.setAddressLine1("123 Main");
address.setCity("Dallas");
address.setPostalCode("75201");
address.setDefault(true);
ca.setAddress(address);
ca.setCustomer(customer);
ca.setAddressName("address3");
CustomerAddress savedAddress = saveCustomerAddress(ca);
List<CustomerAddress> customerAddressList = customerAddressService.readActiveCustomerAddressesByCustomerId(customer.getId());
for (CustomerAddress customerAddress : customerAddressList) {
if (customerAddress.getId().equals(savedAddress.getId())) {
assert customerAddress.getAddress().isDefault();
} else {
assert !customerAddress.getAddress().isDefault();
}
}
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerTest method createCustomer.
@Test(groups = "createCustomers", dependsOnGroups = "createCustomerIdGeneration", dataProvider = "setupCustomers", dataProviderClass = CustomerDataProvider.class)
@Rollback(false)
public void createCustomer(Customer customerInfo) {
Customer customer = customerService.createCustomerFromId(null);
customer.setPassword(customerInfo.getPassword());
customer.setUsername(customerInfo.getUsername());
Long customerId = customer.getId();
assert customerId != null;
customer = customerService.saveCustomer(customer);
assert customer.getId() == customerId;
userIds.add(customer.getId());
userNames.add(customer.getUsername());
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerTest method changeCustomerPasswords.
/*@Test(groups = { "readCustomer1" }, dependsOnGroups = { "createCustomers" })
public void readCustomersByUsername1() {
for (String userName : userNames) {
UserDetails userDetails = userDetailsService.loadUserByUsername(userName);
assert userDetails != null && userDetails.getPassword().equals(userDetails.getUsername() + "Password");
}
}*/
@Test(groups = { "changeCustomerPassword" }, dependsOnGroups = { "readCustomer" })
@Transactional
@Commit
public void changeCustomerPasswords() {
for (String userName : userNames) {
Customer customer = customerService.readCustomerByUsername(userName);
customer.setPassword(customer.getPassword() + "-Changed");
customerService.saveCustomer(customer);
}
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class CustomerStateRequestProcessor method mergeCustomerIfRequired.
/**
* Allows the merging of anonymous customer data and / or session data, to the logged in customer, if required.
* This is written to only require it to happen once.
* @param request
* @param customer
* @return
*/
protected Customer mergeCustomerIfRequired(WebRequest request, Customer customer) {
if (BLCRequestUtils.isOKtoUseSession(request)) {
// Don't call this if it has already been called
if (request.getAttribute(getAnonymousCustomerMergedSessionAttributeName(), WebRequest.SCOPE_GLOBAL_SESSION) == null) {
// Set this so we don't do this every time.
request.setAttribute(getAnonymousCustomerMergedSessionAttributeName(), Boolean.TRUE, WebRequest.SCOPE_GLOBAL_SESSION);
Customer anonymousCustomer = getAnonymousCustomer(request);
customer = copyAnonymousCustomerInfoToCustomer(request, anonymousCustomer, customer);
}
}
return customer;
}
Aggregations