AccessTokenManagerImpl implements AccessTokenManager { @Override public Mono<AccessToken> grantAccessToken(Username username) { Preconditions.checkNotNull(username); AccessToken accessToken = AccessToken.generate(); return accessTokenRepository.addToken(username, accessToken) .thenReturn(accessToken); } @Inject  AccessTokenManagerImpl(AccessTokenRepository accessTokenRepository); @Override Mono<AccessToken> grantAccessToken(Username username); @Override Mono<Username> getUsernameFromToken(AccessToken token); @Override Mono<Boolean> isValid(AccessToken token); @Override Mono<Void> revoke(AccessToken token);  }
@Test void grantShouldThrowOnNullUsername() { assertThatNullPointerException() .isThrownBy(() -> accessTokenManager.grantAccessToken(null)); }
@Test void grantShouldGenerateATokenOnUsername() { assertThat(accessTokenManager.grantAccessToken(USERNAME)).isNotNull(); }