@SuppressWarnings({"unchecked", "rawtypes"}) @Test void updateStreamUnchangedPassword() { User currentUser = mock(User.class); when(currentUser.getPassword()).thenReturn("currentPasswordHash"); when(userRepositoryDecorator.findOneById("1")).thenReturn(currentUser); User user = mock(User.class); when(user.getId()).thenReturn("1"); when(user.isActive()).thenReturn(true); when(user.getPassword()).thenReturn("currentPasswordHash"); Stream<User> entities = Stream.of(user); ArgumentCaptor<Stream<User>> captor = ArgumentCaptor.forClass(Stream.class); doNothing().when(delegateRepository).update(captor.capture()); userRepositoryDecorator.update(entities); assertEquals(singletonList(user), captor.getValue().collect(toList())); verify(user).setPassword("currentPasswordHash"); verify(user).setActivationCode(null); }
@Override public void update(User entity) { updatePassword(entity); updateActivationCode(entity); delegate().update(entity); }
UserRepositoryDecorator extends AbstractRepositoryDecorator<User> { @Override public void update(User entity) { updatePassword(entity); updateActivationCode(entity); delegate().update(entity); } }
UserRepositoryDecorator extends AbstractRepositoryDecorator<User> { @Override public void update(User entity) { updatePassword(entity); updateActivationCode(entity); delegate().update(entity); } UserRepositoryDecorator(Repository<User> delegateRepository, PasswordEncoder passwordEncoder); }
UserRepositoryDecorator extends AbstractRepositoryDecorator<User> { @Override public void update(User entity) { updatePassword(entity); updateActivationCode(entity); delegate().update(entity); } UserRepositoryDecorator(Repository<User> delegateRepository, PasswordEncoder passwordEncoder); @Override void add(User entity); @Override void update(User entity); @Override Integer add(Stream<User> entities); @Override void update(Stream<User> entities); @Override void delete(User entity); @Override void delete(Stream<User> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll(); }
UserRepositoryDecorator extends AbstractRepositoryDecorator<User> { @Override public void update(User entity) { updatePassword(entity); updateActivationCode(entity); delegate().update(entity); } UserRepositoryDecorator(Repository<User> delegateRepository, PasswordEncoder passwordEncoder); @Override void add(User entity); @Override void update(User entity); @Override Integer add(Stream<User> entities); @Override void update(Stream<User> entities); @Override void delete(User entity); @Override void delete(Stream<User> entities); @Override void deleteById(Object id); @Override void deleteAll(Stream<Object> ids); @Override void deleteAll();  }