@Test public void testFindByDomainAndKey() { Scope scope = new Scope(); scope.setName("firstOne"); scope.setKey("one"); scope.setDomain("testDomain"); scopeRepository.create(scope).blockingGet(); scope.setName("anotherOne"); scope.setDomain("another"); scopeRepository.create(scope).blockingGet(); TestObserver<Scope> testObserver = scopeRepository.findByDomainAndKey("testDomain","one").test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(result -> "firstOne".equals(result.getName())); }
@Override public Maybe<Scope> findByDomainAndKey(String domain, String key) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_KEY, key))).first()).firstElement().map(this::convert); }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Maybe<Scope> findByDomainAndKey(String domain, String key) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_KEY, key))).first()).firstElement().map(this::convert); } }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Maybe<Scope> findByDomainAndKey(String domain, String key) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_KEY, key))).first()).firstElement().map(this::convert); }  }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Maybe<Scope> findByDomainAndKey(String domain, String key) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_KEY, key))).first()).firstElement().map(this::convert); }  @PostConstruct void init(); @Override Maybe<Scope> findById(String id); @Override Single<Scope> create(Scope item); @Override Single<Scope> update(Scope item); @Override Completable delete(String id); @Override Single<Set<Scope>> findByDomain(String domain); @Override Maybe<Scope> findByDomainAndKey(String domain, String key); @Override Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys); }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Maybe<Scope> findByDomainAndKey(String domain, String key) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_KEY, key))).first()).firstElement().map(this::convert); }  @PostConstruct void init(); @Override Maybe<Scope> findById(String id); @Override Single<Scope> create(Scope item); @Override Single<Scope> update(Scope item); @Override Completable delete(String id); @Override Single<Set<Scope>> findByDomain(String domain); @Override Maybe<Scope> findByDomainAndKey(String domain, String key); @Override Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys);  }