@Test public void deleteOldestPasswordShouldDeleteHistoryEntity() { given(this.passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(USER_ID)) .willReturn(EMPTY_PASSWORD_HISTORY_ENTITY); this.passwordChangeService.deleteOldestPassword(USER_ID); then(this.passwordHistoryRepository).should().findTop1ByUserEntityIdOrderByChangeDate(USER_ID); then(this.passwordHistoryRepository).should().delete(EMPTY_PASSWORD_HISTORY_ENTITY); verifyNoMoreInteractions(this.passwordHistoryRepository); verifyZeroInteractions(this.userRepository); }
@Transactional @Override public void deleteOldestPassword(Long userId) { Assert.notNull(userId); PasswordHistoryEntity entity = passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(userId); passwordHistoryRepository.delete(entity); }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional @Override public void deleteOldestPassword(Long userId) { Assert.notNull(userId); PasswordHistoryEntity entity = passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(userId); passwordHistoryRepository.delete(entity); } }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional @Override public void deleteOldestPassword(Long userId) { Assert.notNull(userId); PasswordHistoryEntity entity = passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(userId); passwordHistoryRepository.delete(entity); }  }
PasswordChangeServiceImpl implements PasswordChangeService { @Transactional @Override public void deleteOldestPassword(Long userId) { Assert.notNull(userId); PasswordHistoryEntity entity = passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(userId); passwordHistoryRepository.delete(entity); }  @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 @Override public void deleteOldestPassword(Long userId) { Assert.notNull(userId); PasswordHistoryEntity entity = passwordHistoryRepository.findTop1ByUserEntityIdOrderByChangeDate(userId); passwordHistoryRepository.delete(entity); }  @Transactional @Override Long saveOrUpdate(PasswordHistoryDTO passwordHistoryDTO); @Transactional(readOnly = true) @Override List<String> getOldPasswords(Long userId); @Transactional @Override void deleteOldestPassword(Long userId);  }