protected Customer createNamedCustomer() { Customer customer = customerService.createCustomerFromId(null); customer.setUsername(String.valueOf(customer.getId())); return customer; }
@DataProvider(name = "setupCustomers") public static Object[][] createCustomers() { Customer customer1 = new CustomerImpl(); customer1.setPassword("customer1Password"); customer1.setUsername("customer1"); Customer customer2 = new CustomerImpl(); customer2.setPassword("customer2Password"); customer2.setUsername("customer2"); return new Object[][] { new Object[] { customer1 }, new Object[] { customer2 } }; } }
customer.setUsername(form.getEmailAddress());
@Override public Entity add(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException { Entity entity = persistencePackage.getEntity(); try { PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective(); Customer adminInstance = (Customer) Class.forName(entity.getType()[0]).newInstance(); adminInstance.setId(customerService.findNextCustomerId()); Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(Customer.class.getName(), persistencePerspective); adminInstance = (Customer) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false); if (useEmailForLogin) { adminInstance.setUsername(adminInstance.getEmailAddress()); } Entity errorEntity = validateUniqueUsername(entity, adminInstance, true); if (errorEntity != null) { return errorEntity; } adminInstance = dynamicEntityDao.merge(adminInstance); customerService.createRegisteredCustomerRoles(adminInstance); Entity adminEntity = helper.getRecord(adminProperties, adminInstance, null, null); return adminEntity; } catch (Exception e) { LOG.error("Unable to execute persistence activity", e); throw new ServiceException("Unable to add entity for " + entity.getType()[0], e); } }
public String register(RegisterCustomerForm registerCustomerForm, HttpServletRequest request, HttpServletResponse response, Model model) { Connection<?> connection = ProviderSignInUtils.getConnection(new ServletWebRequest(request)); if (connection != null) { UserProfile userProfile = connection.fetchUserProfile(); Customer customer = registerCustomerForm.getCustomer(); customer.setFirstName(userProfile.getFirstName()); customer.setLastName(userProfile.getLastName()); customer.setEmailAddress(userProfile.getEmail()); if (isUseEmailForLogin()){ customer.setUsername(userProfile.getEmail()); } else { customer.setUsername(userProfile.getUsername()); } } return super.register(registerCustomerForm, request, response, model); }
customer.setUsername(customer.getEmailAddress());
/** * Creates a country, state, and customer with the supplied customerAddress * @param customerAddress * @return customer created */ public CustomerAddress createCustomerWithAddress(CustomerAddress customerAddress) { createCountry(); createState(); Customer customer = createCustomer(); customer.setUsername(String.valueOf(customer.getId())); customerAddress.setCustomer(customer); return saveCustomerAddress(customerAddress); }
@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()); }
@Override public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException { Entity entity = persistencePackage.getEntity(); try { PersistencePerspective persistencePerspective = persistencePackage.getPersistencePerspective(); Map<String, FieldMetadata> adminProperties = helper.getSimpleMergedProperties(Customer.class.getName(), persistencePerspective); Object primaryKey = helper.getPrimaryKey(entity, adminProperties); Customer adminInstance = (Customer) dynamicEntityDao.retrieve(Class.forName(entity.getType()[0]), primaryKey); Entity errorEntity = validateUniqueUsername(entity, adminInstance, false); if (errorEntity != null) { return errorEntity; } String passwordBefore = adminInstance.getPassword(); adminInstance.setPassword(null); adminInstance = (Customer) helper.createPopulatedInstance(adminInstance, entity, adminProperties, false); adminInstance.setPassword(passwordBefore); if (useEmailForLogin) { adminInstance.setUsername(adminInstance.getEmailAddress()); } adminInstance = customerService.saveCustomer(adminInstance); Entity adminEntity = helper.getRecord(adminProperties, adminInstance, null, null); return adminEntity; } catch (Exception e) { throw new ServiceException("Unable to update entity for " + entity.getType()[0], e); } }
if (isUseEmailForLogin()) { Customer customer = registerCustomerForm.getCustomer(); customer.setUsername(customer.getEmailAddress());
cloned.setUsername(username); cloned.setUnencodedPassword(unencodedPassword); cloned.setTaxExemptionCode(taxExemptionCode);
Order order = create(); if (customer.getUsername() == null) { customer.setUsername(String.valueOf(customer.getId())); if (customerDao.readCustomerById(customer.getId()) != null) { throw new IllegalArgumentException("Attempting to save a customer with an id (" + customer.getId() + ") " +
@DataProvider(name = "setupCustomerControllerData") public static Object[][] createCustomer() { Customer customer = new CustomerImpl(); customer.setEmailAddress("testCase@test.com"); customer.setFirstName("TestFirstName"); customer.setLastName("TestLastName"); customer.setUsername("TestCase"); ChallengeQuestion question = new ChallengeQuestionImpl(); question.setId(1L); customer.setChallengeQuestion(question); customer.setChallengeAnswer("Challenge CandidateItemOfferAnswer"); RegisterCustomerForm registerCustomer = new RegisterCustomerForm(); registerCustomer.setCustomer(customer); registerCustomer.setPassword("TestPassword"); registerCustomer.setPasswordConfirm("TestPassword"); return new Object[][] { new Object[] { registerCustomer } }; } }
customer.setUsername(username); customer.setEmailAddress(email);
public Customer createAnonymousCustomer() throws DataAccessException { Customer customer = customerService.createNewCustomer(); customer.setUsername(String.valueOf(customer.getId())); customer.setPassword(RandomStringUtils.randomAscii(8)); return customerService.saveCustomer(customer); }