@Test public void whenRemoveNotActivatedUsers() { User user = this.createUser(); user.setRegisterDate(ZonedDateTime.now().minus(30, ChronoUnit.DAYS)); this.userRepository.save(user); assertTrue(this.userRepository.findByLogin("testtest").isPresent()); this.userService.removeNotActivatedUsers(); assertFalse(this.userRepository.findByLogin("testtest").isPresent()); }
@Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { this.userRepository .findAllByActivatedIsFalseAndRegisterDateBefore( ZonedDateTime.now().minus(3, ChronoUnit.DAYS) ) .forEach(this.userRepository::delete); }
UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { this.userRepository .findAllByActivatedIsFalseAndRegisterDateBefore( ZonedDateTime.now().minus(3, ChronoUnit.DAYS) ) .forEach(this.userRepository::delete); } }
UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { this.userRepository .findAllByActivatedIsFalseAndRegisterDateBefore( ZonedDateTime.now().minus(3, ChronoUnit.DAYS) ) .forEach(this.userRepository::delete); } UserService(UserRepository userRepository, AuthorityRepository authorityRepository, PasswordEncoder passwordEncoder); }
UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { this.userRepository .findAllByActivatedIsFalseAndRegisterDateBefore( ZonedDateTime.now().minus(3, ChronoUnit.DAYS) ) .forEach(this.userRepository::delete); } UserService(UserRepository userRepository, AuthorityRepository authorityRepository, PasswordEncoder passwordEncoder); User register(UserRegister user); void update(UserDTO userDTO); void update(String id, String login, String firstName, String lastName, String email, String langKey); void delete(String login); Optional<User> activateRegistration(String key); Page<UserDTO> search(Pageable pageable, String query); Page<UserDTO> getAll(Pageable pageable); Optional<User> getById(String id); Optional<User> getByLogin(String login); Optional<User> getByEmail(String email); void changePassword(String id, String password); Optional<User> requestPasswordReset(String mail); Optional<User> completePasswordReset(String password, String key); @Scheduled(cron = "0 0 1 * * ?") void removeNotActivatedUsers(); }
UserService { @Scheduled(cron = "0 0 1 * * ?") public void removeNotActivatedUsers() { this.userRepository .findAllByActivatedIsFalseAndRegisterDateBefore( ZonedDateTime.now().minus(3, ChronoUnit.DAYS) ) .forEach(this.userRepository::delete); } UserService(UserRepository userRepository, AuthorityRepository authorityRepository, PasswordEncoder passwordEncoder); User register(UserRegister user); void update(UserDTO userDTO); void update(String id, String login, String firstName, String lastName, String email, String langKey); void delete(String login); Optional<User> activateRegistration(String key); Page<UserDTO> search(Pageable pageable, String query); Page<UserDTO> getAll(Pageable pageable); Optional<User> getById(String id); Optional<User> getByLogin(String login); Optional<User> getByEmail(String email); void changePassword(String id, String password); Optional<User> requestPasswordReset(String mail); Optional<User> completePasswordReset(String password, String key); @Scheduled(cron = "0 0 1 * * ?") void removeNotActivatedUsers();  }