UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { DateTime now = new DateTime(); List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3)); for (User user : users) { log.debug("Deleting not activated user {}", user.getLogin()); userRepository.delete(user); } }  Optional<User> activateRegistration(final String key); Optional<User> completePasswordReset(final String newPassword, final String key); Optional<User> requestPasswordReset(final String mail); User createUserInformation(final String login, final String password, final String firstName, final String lastName, final String email, final String langKey); void updateUserInformation(final String firstName, final String lastName, final String email, final String langKey); void changePassword(final String password); @Transactional(readOnly = true) Optional<User> getUserWithAuthoritiesByLogin(final String login); @Transactional(readOnly = true) User getUserWithAuthorities(final Long id); @Transactional(readOnly = true) User getUserWithAuthorities(); @Scheduled(cron = "0 0 0 * * ?") void removeOldPersistentTokens(); @Scheduled(cron = "0 0 1 * * ?") void removeNotActivatedUsers();  }
@Test public void testFindNotActivatedUsersByCreationDateBefore() { userService.removeNotActivatedUsers(); DateTime now = new DateTime(); List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3)); assertThat(users).isEmpty(); }