@Test public void when_emailadress_not_found_no_exception_is_thrown() throws Exception { when(mockedUserRepository.findByEmailAdress("user@test.com")).thenReturn(Optional.empty()); serviceToTest.anonymousRequestToGetNewApiTokenForUserMailAdress("user@test.com"); }
public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) { LOG.info("New api token requested for email address: {})",logSanitizer.sanitize(userEmail,50)); assertion.isValidEmailAddress(userEmail); Optional<User> found = userRepository.findByEmailAdress(userEmail); if (! found.isPresent()) { LOG.warn("Anonymous request to get new api token, but user unknown: {})",logSanitizer.sanitize(userEmail,50)); return; } User user = saveUserWithNewOneTimeToken(found); sendUserNewApiTokenRequested(userEmail, user); }
AnonymousUserRequestsNewApiTokenService { public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) { LOG.info("New api token requested for email address: {})",logSanitizer.sanitize(userEmail,50)); assertion.isValidEmailAddress(userEmail); Optional<User> found = userRepository.findByEmailAdress(userEmail); if (! found.isPresent()) { LOG.warn("Anonymous request to get new api token, but user unknown: {})",logSanitizer.sanitize(userEmail,50)); return; } User user = saveUserWithNewOneTimeToken(found); sendUserNewApiTokenRequested(userEmail, user); } }
AnonymousUserRequestsNewApiTokenService { public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) { LOG.info("New api token requested for email address: {})",logSanitizer.sanitize(userEmail,50)); assertion.isValidEmailAddress(userEmail); Optional<User> found = userRepository.findByEmailAdress(userEmail); if (! found.isPresent()) { LOG.warn("Anonymous request to get new api token, but user unknown: {})",logSanitizer.sanitize(userEmail,50)); return; } User user = saveUserWithNewOneTimeToken(found); sendUserNewApiTokenRequested(userEmail, user); }  }
AnonymousUserRequestsNewApiTokenService { public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) { LOG.info("New api token requested for email address: {})",logSanitizer.sanitize(userEmail,50)); assertion.isValidEmailAddress(userEmail); Optional<User> found = userRepository.findByEmailAdress(userEmail); if (! found.isPresent()) { LOG.warn("Anonymous request to get new api token, but user unknown: {})",logSanitizer.sanitize(userEmail,50)); return; } User user = saveUserWithNewOneTimeToken(found); sendUserNewApiTokenRequested(userEmail, user); }  void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail); }
AnonymousUserRequestsNewApiTokenService { public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) { LOG.info("New api token requested for email address: {})",logSanitizer.sanitize(userEmail,50)); assertion.isValidEmailAddress(userEmail); Optional<User> found = userRepository.findByEmailAdress(userEmail); if (! found.isPresent()) { LOG.warn("Anonymous request to get new api token, but user unknown: {})",logSanitizer.sanitize(userEmail,50)); return; } User user = saveUserWithNewOneTimeToken(found); sendUserNewApiTokenRequested(userEmail, user); }  void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail);  }