@Test public void testFindByDomainAndResource() throws TechnicalException { AccessPolicy accessPolicy = new AccessPolicy(); accessPolicy.setName("accessPolicyName"); accessPolicy.setDomain(DOMAIN_ID); accessPolicy.setResource(RESOURCE_ID); repository.create(accessPolicy).blockingGet(); AccessPolicy accessPolicy2 = new AccessPolicy(); accessPolicy2.setName("accessPolicyName"); accessPolicy2.setDomain(DOMAIN_ID); accessPolicy2.setResource(RESOURCE_ID); repository.create(accessPolicy2).blockingGet(); TestObserver<List<AccessPolicy>> testObserver = repository.findByDomainAndResource(DOMAIN_ID, RESOURCE_ID).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(accessPolicies -> accessPolicies.size() == 2); }
@Override public Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource) { return Observable.fromPublisher(accessPoliciesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_RESOURCE, resource)))).map(this::convert).toList(); }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource) { return Observable.fromPublisher(accessPoliciesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_RESOURCE, resource)))).map(this::convert).toList(); } }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource) { return Observable.fromPublisher(accessPoliciesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_RESOURCE, resource)))).map(this::convert).toList(); }  }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource) { return Observable.fromPublisher(accessPoliciesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_RESOURCE, resource)))).map(this::convert).toList(); }  @PostConstruct void init(); @Override Single<Page<AccessPolicy>> findByDomain(String domain, int page, int size); @Override Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource); @Override Single<List<AccessPolicy>> findByResources(List<String> resources); @Override Single<Long> countByResource(String resource); @Override Maybe<AccessPolicy> findById(String id); @Override Single<AccessPolicy> create(AccessPolicy item); @Override Single<AccessPolicy> update(AccessPolicy item); @Override Completable delete(String id); }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource) { return Observable.fromPublisher(accessPoliciesCollection.find(and(eq(FIELD_DOMAIN, domain), eq(FIELD_RESOURCE, resource)))).map(this::convert).toList(); }  @PostConstruct void init(); @Override Single<Page<AccessPolicy>> findByDomain(String domain, int page, int size); @Override Single<List<AccessPolicy>> findByDomainAndResource(String domain, String resource); @Override Single<List<AccessPolicy>> findByResources(List<String> resources); @Override Single<Long> countByResource(String resource); @Override Maybe<AccessPolicy> findById(String id); @Override Single<AccessPolicy> create(AccessPolicy item); @Override Single<AccessPolicy> update(AccessPolicy item); @Override Completable delete(String id); static final String COLLECTION_NAME; }