TokenService { public Account getCredentialsForToken(String token) { Account account = checkToken(token); account.setValid(true); return account; }  void generateNewToken(Account account); void reinitTokenValidity(Account account); Account checkToken(String token); Account getCredentialsForToken(String token); Member tryToLinkWithActualMember(Account account);  }
@Test public void should_get_credentials_for_token() { Account account = new Account().setTokenExpiration(LocalDateTime.now().plus(Duration.ofHours(1))); when(accountRepository.findByToken("token")).thenReturn(account); assertThat(account.isValid()).isFalse(); assertThat(tokenService.getCredentialsForToken("token")).isNotNull(); assertThat(account.isValid()).isTrue(); }