CustomerServiceImpl extends BaseGenericServiceImpl<Customer> implements CustomerService { @Override public Customer create(final Customer customer, final Shop shop) { if (shop != null) { final String customerType = StringUtils.isNotBlank(customer.getCustomerType()) ? customer.getCustomerType() : AttributeNamesKeys.Cart.CUSTOMER_TYPE_REGULAR; final boolean requiredApproval = shop.getMaster() != null ? shop.getMaster().isSfRequireCustomerRegistrationApproval(customerType) : shop.isSfRequireCustomerRegistrationApproval(customerType); final CustomerShop customerShop = getGenericDao().getEntityFactory().getByIface(CustomerShop.class); customerShop.setCustomer(customer); customerShop.setShop(shop); customerShop.setDisabled(requiredApproval); customer.getShops().add(customerShop); } return super.create(customer); } CustomerServiceImpl(final GenericDAO<Customer, Long> genericDao,
                               final HashHelper passwordHashHelper,
                               final GenericDAO<Object, Long> customerShopDao,
                               final AttributeService attributeService,
                               final ShopService shopService,
                               final CustomerNameFormatter customerNameFormatter); @Override Customer getCustomerByEmail(final String email, Shop shop); @Override Customer findCustomerByEmail(final String email, final Shop shop, final boolean includeDisabled); @Override Customer getCustomerByToken(final String token); @Override Customer getCustomerByPublicKey(final String publicKey, final String lastName); @Override List<Shop> getCustomerShops(final Customer customer); @Override String formatNameFor(final Customer customer, final Shop shop); @Override List<Customer> findCustomers(final int start,
                                        final int offset,
                                        final String sort,
                                        final boolean sortDescending,
                                        final Map<String, List> filter); @Override int findCustomerCount(final Map<String, List> filter); @Override boolean isCustomerExists(final String email, final Shop shop, final boolean includeDisabled); @Override boolean isPasswordValid(final String email, final Shop shop, final String password); @Override List<AttrValueCustomer> getRankedAttributeValues(final Customer customer); @Override void resetPassword(final Customer customer, final Shop shop, final String authToken); @Override void updatePassword(final Customer customer, final Shop shop, final String newPassword); @Override Customer create(final Customer customer, final Shop shop); @Override Customer updateActivate(final Customer customer, final Shop shop, final boolean soft); @Override Customer updateDeactivate(final Customer customer, final Shop shop, final boolean soft); @Override Customer create(final Customer instance); @Override Customer update(final String email, final String shopCode); @Override Customer update(final Customer instance); @Override void delete(final Customer instance);  }
@Test public void testCreate() { Customer customer10 = getCustomer(getTestName()); customer10 = customerService.create(customer10, shopService.getById(10L)); assertTrue(customer10.getCustomerId() > 0); assertFalse(customer10.getShops().isEmpty()); Customer customer10check = customerService.getCustomerByEmail(customer10.getEmail(), shopService.getById(10L)); assertNotNull(customer10check); assertEquals(customer10check.getCustomerId(), customer10.getCustomerId()); Customer customer20 = getCustomer(getTestName()); customer20 = customerService.create(customer20, shopService.getById(20L)); assertTrue(customer20.getCustomerId() > 0); assertFalse(customer20.getShops().isEmpty()); assertEquals(customer10.getEmail(), customer20.getEmail()); assertFalse(customer10.getCustomerId() == customer20.getCustomerId()); Customer customer20check = customerService.getCustomerByEmail(customer20.getEmail(), shopService.getById(20L)); assertNotNull(customer20check); assertEquals(customer20check.getCustomerId(), customer20.getCustomerId()); }