@Test(expected = DataAccessException.class) public void getOldPasswordShouldDelegateDataAccessExceptionFromUserRepository() { given(this.userRepository.findOne(USER_ID)).willThrow(DataIntegrityViolationException.class); this.passwordChangeService.getOldPasswords(USER_ID); }
@Transactional(readOnly = true) @Override public List<String> getOldPasswords(Long userId) { Assert.notNull(userId); List<PasswordHistoryEntity> oldPasswords = passwordHistoryRepository.findByUserEntity(userRepository.findOne(userId)); List<String> passwords = new ArrayList<>(); for (PasswordHistoryEntity pass : oldPasswords) { passwords.add(pass.getPassword()); } return passwords; }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional(readOnly = true) @Override public List<String> getOldPasswords(Long userId) { Assert.notNull(userId); List<PasswordHistoryEntity> oldPasswords = passwordHistoryRepository.findByUserEntity(userRepository.findOne(userId)); List<String> passwords = new ArrayList<>(); for (PasswordHistoryEntity pass : oldPasswords) { passwords.add(pass.getPassword()); } return passwords; } }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional(readOnly = true) @Override public List<String> getOldPasswords(Long userId) { Assert.notNull(userId); List<PasswordHistoryEntity> oldPasswords = passwordHistoryRepository.findByUserEntity(userRepository.findOne(userId)); List<String> passwords = new ArrayList<>(); for (PasswordHistoryEntity pass : oldPasswords) { passwords.add(pass.getPassword()); } return passwords; }  }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional(readOnly = true) @Override public List<String> getOldPasswords(Long userId) { Assert.notNull(userId); List<PasswordHistoryEntity> oldPasswords = passwordHistoryRepository.findByUserEntity(userRepository.findOne(userId)); List<String> passwords = new ArrayList<>(); for (PasswordHistoryEntity pass : oldPasswords) { passwords.add(pass.getPassword()); } return passwords; }  @Transactional @Override Long saveOrUpdate(PasswordHistoryDTO passwordHistoryDTO); @Transactional(readOnly = true) @Override List<String> getOldPasswords(Long userId); @Transactional @Override void deleteOldestPassword(Long userId); }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional(readOnly = true) @Override public List<String> getOldPasswords(Long userId) { Assert.notNull(userId); List<PasswordHistoryEntity> oldPasswords = passwordHistoryRepository.findByUserEntity(userRepository.findOne(userId)); List<String> passwords = new ArrayList<>(); for (PasswordHistoryEntity pass : oldPasswords) { passwords.add(pass.getPassword()); } return passwords; }  @Transactional @Override Long saveOrUpdate(PasswordHistoryDTO passwordHistoryDTO); @Transactional(readOnly = true) @Override List<String> getOldPasswords(Long userId); @Transactional @Override void deleteOldestPassword(Long userId);  }