@Test public void shouldNotFindToken() { TestObserver<AccessToken> observer = accessTokenRepository.findByToken("unknown-token").test(); observer.awaitTerminalEvent(); observer.assertComplete(); observer.assertValueCount(0); observer.assertNoErrors(); }
@Override public Maybe<AccessToken> findByToken(String token) { return Observable .fromPublisher(accessTokenCollection.find(eq(FIELD_TOKEN, token)).limit(1).first()) .firstElement() .map(this::convert); }
MongoAccessTokenRepository extends AbstractOAuth2MongoRepository implements AccessTokenRepository { @Override public Maybe<AccessToken> findByToken(String token) { return Observable .fromPublisher(accessTokenCollection.find(eq(FIELD_TOKEN, token)).limit(1).first()) .firstElement() .map(this::convert); } }
MongoAccessTokenRepository extends AbstractOAuth2MongoRepository implements AccessTokenRepository { @Override public Maybe<AccessToken> findByToken(String token) { return Observable .fromPublisher(accessTokenCollection.find(eq(FIELD_TOKEN, token)).limit(1).first()) .firstElement() .map(this::convert); }  }
MongoAccessTokenRepository extends AbstractOAuth2MongoRepository implements AccessTokenRepository { @Override public Maybe<AccessToken> findByToken(String token) { return Observable .fromPublisher(accessTokenCollection.find(eq(FIELD_TOKEN, token)).limit(1).first()) .firstElement() .map(this::convert); }  @PostConstruct void init(); @Override Maybe<AccessToken> findByToken(String token); @Override Single<AccessToken> create(AccessToken accessToken); @Override Completable bulkWrite(List<AccessToken> accessTokens); @Override Completable delete(String token); @Override Observable<AccessToken> findByClientIdAndSubject(String clientId, String subject); @Override Observable<AccessToken> findByClientId(String clientId); @Override Observable<AccessToken> findByAuthorizationCode(String authorizationCode); @Override Single<Long> countByClientId(String clientId); @Override Completable deleteByUserId(String userId); @Override Completable deleteByDomainIdClientIdAndUserId(String domainId, String clientId, String userId); @Override Completable deleteByDomainIdAndUserId(String domainId, String userId); }
MongoAccessTokenRepository extends AbstractOAuth2MongoRepository implements AccessTokenRepository { @Override public Maybe<AccessToken> findByToken(String token) { return Observable .fromPublisher(accessTokenCollection.find(eq(FIELD_TOKEN, token)).limit(1).first()) .firstElement() .map(this::convert); }  @PostConstruct void init(); @Override Maybe<AccessToken> findByToken(String token); @Override Single<AccessToken> create(AccessToken accessToken); @Override Completable bulkWrite(List<AccessToken> accessTokens); @Override Completable delete(String token); @Override Observable<AccessToken> findByClientIdAndSubject(String clientId, String subject); @Override Observable<AccessToken> findByClientId(String clientId); @Override Observable<AccessToken> findByAuthorizationCode(String authorizationCode); @Override Single<Long> countByClientId(String clientId); @Override Completable deleteByUserId(String userId); @Override Completable deleteByDomainIdClientIdAndUserId(String domainId, String clientId, String userId); @Override Completable deleteByDomainIdAndUserId(String domainId, String userId);  }