CustomerServiceImpl extends BaseGenericServiceImpl<Customer> implements CustomerService { @Override public Customer update(final String email, final String shopCode) { final Shop shop = shopService.getShopByCode(shopCode); if (shop != null) { final Customer customer = getCustomerByEmail(email, shop); for (final CustomerShop customerShop : customer.getShops()) { if (shop.getShopId() == customerShop.getShop().getShopId()) { return customer; } } final CustomerShop customerShop = getGenericDao().getEntityFactory().getByIface(CustomerShop.class); customerShop.setCustomer(customer); customerShop.setShop(shop); customer.getShops().add(customerShop); return super.update(customer); } return null; } 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 testUpdate() { Customer customer = getCustomer(getTestName()); customer = customerService.create(customer, shopService.getById(10L)); assertTrue(customer.getCustomerId() > 0); customer.setFirstname("Gordon"); customer.setLastname("Freeman"); customer.setPassword("rawpassword"); customer = customerService.update(customer); assertEquals("Gordon", customer.getFirstname()); assertEquals("Freeman", customer.getLastname()); }