AccessTokenManagerImpl implements AccessTokenManager { @Override public Mono<Boolean> isValid(AccessToken token) throws InvalidAccessToken { try { return getUsernameFromToken(token) .thenReturn(true); } catch (InvalidAccessToken e) { return Mono.just(false); } } @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 isValidShouldThrowOnNullToken() { assertThatNullPointerException() .isThrownBy(() -> accessTokenManager.isValid(null)); }
@Test void isValidShouldReturnFalseOnUnknownToken() { assertThat(Mono.from(accessTokenManager.isValid(AccessToken.generate())).block()).isFalse(); }