@Test public void testFindByDomainAndKeys() { Scope scope = new Scope(); scope.setName("firstOne"); scope.setKey("one"); scope.setDomain("testDomain"); Scope scopeCreated1 = scopeRepository.create(scope).blockingGet(); scope.setName("anotherOne"); scope.setDomain("another"); scopeRepository.create(scope).blockingGet(); scope.setName("secondOne"); scope.setKey("two"); scope.setDomain("testDomain"); Scope scopeCreated2 = scopeRepository.create(scope).blockingGet(); TestObserver<List<Scope>> testObserver = scopeRepository.findByDomainAndKeys("testDomain", Arrays.asList("one","two","three")).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(scopes -> scopes.size()==2 && scopes.stream() .map(Scope::getId) .collect(Collectors.toList()) .containsAll(Arrays.asList(scopeCreated1.getId(), scopeCreated2.getId())) ); }
@Override public Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), in(FIELD_KEY, keys)))).map(this::convert).toList(); }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), in(FIELD_KEY, keys)))).map(this::convert).toList(); } }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), in(FIELD_KEY, keys)))).map(this::convert).toList(); }  }
MongoScopeRepository extends AbstractManagementMongoRepository implements ScopeRepository { @Override public Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), in(FIELD_KEY, keys)))).map(this::convert).toList(); }  @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 Single<List<Scope>> findByDomainAndKeys(String domain, List<String> keys) { return Observable.fromPublisher(scopesCollection.find(and(eq(FIELD_DOMAIN, domain), in(FIELD_KEY, keys)))).map(this::convert).toList(); }  @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);  }