AccountVerificationServiceImpl implements
		AccountVerificationService { @Override public void enableAccount(AccountVerificationDto accountVerificationDto, String linkUrl) throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { if (accountVerificationDto == null) { throw new IllegalArgumentException( "Account verification dto is required."); } String token = accountVerificationDto.getToken(); EmailToken emailToken = findToken(token); Boolean isExpired = emailToken.isTokenExpired(); if (isExpired) { throw new TokenExpiredException("Email token is expired."); } emailToken.setIsTokenUsed(true); emailTokenRepository.save(emailToken); String username = emailToken.getUsername(); Users user = null; try { user = usersRepository.loadUserByUsername(username); } catch (UsernameNotFoundException e) { logger.warn(String.format(e.getMessage()), e); throw new UsernameNotExistException(e.getMessage()); } Users updatedUser = new Users(user.getFailedLoginAttempts(), username, user.getPassword(), true, user.isAccountNonExpired(), user.isCredentialsNonExpired(), user.getAuthorities()); usersRepository.updateUser(updatedUser); Patient patient = patientRepository.findByUsername(username); emailSender.sendMessage( patient.getFirstName() + " " + patient.getLastName(), patient.getEmail(), EmailType.SIGNUP_CONFIRMATION, linkUrl, null); } AccountVerificationServiceImpl(UsersRepository usersRepository,
			PatientRepository patientRepository,
			EmailTokenRepository emailTokenRepository, EmailSender emailSender); @Override Boolean isAccountVerificationTokenExpired(String token); @Override void enableAccount(AccountVerificationDto accountVerificationDto,
			String linkUrl);  }
@Test(expected = IllegalArgumentException.class) public void testEnableAccount_When_Account_Verification_Dto_Is_Null() throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { sut.enableAccount(null, "linkUrl"); }
@Test(expected = TokenNotExistException.class) public void testEnableAccount_Expired_Token() throws TokenNotExistException, TokenExpiredException, UsernameNotExistException, MessagingException { AccountVerificationDto accountVerificationDto = mock(AccountVerificationDto.class); sut.enableAccount(accountVerificationDto, "linkUrl"); }