@Test public void testFindById() throws TechnicalException { AccessPolicy accessPolicy = new AccessPolicy(); accessPolicy.setName("accessPolicyName"); AccessPolicy apCreated = repository.create(accessPolicy).blockingGet(); TestObserver<AccessPolicy> testObserver = repository.findById(apCreated.getId()).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(ap -> ap.getName().equals("accessPolicyName")); }
@Override public Maybe<AccessPolicy> findById(String id) { return Observable.fromPublisher(accessPoliciesCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Maybe<AccessPolicy> findById(String id) { return Observable.fromPublisher(accessPoliciesCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); } }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Maybe<AccessPolicy> findById(String id) { return Observable.fromPublisher(accessPoliciesCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Maybe<AccessPolicy> findById(String id) { return Observable.fromPublisher(accessPoliciesCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  @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 Maybe<AccessPolicy> findById(String id) { return Observable.fromPublisher(accessPoliciesCollection.find(eq(FIELD_ID, id)).first()).firstElement().map(this::convert); }  @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; }