@Test public void update() throws TechnicalException { AccessPolicy accessPolicy = new AccessPolicy(); accessPolicy.setName("accessPolicyName"); AccessPolicy apCreated = repository.create(accessPolicy).blockingGet(); AccessPolicy toUpdate = new AccessPolicy(); toUpdate.setId(apCreated.getId()); toUpdate.setName("accessPolicyUpdatedName"); TestObserver<AccessPolicy> testObserver = repository.update(toUpdate).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(ap -> ap.getName().equals("accessPolicyUpdatedName")); }
@Override public Single<AccessPolicy> update(AccessPolicy item) { AccessPolicyMongo accessPolicy = convert(item); return Single.fromPublisher(accessPoliciesCollection.replaceOne(eq(FIELD_ID, accessPolicy.getId()), accessPolicy)).flatMap(success -> findById(accessPolicy.getId()).toSingle()); }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<AccessPolicy> update(AccessPolicy item) { AccessPolicyMongo accessPolicy = convert(item); return Single.fromPublisher(accessPoliciesCollection.replaceOne(eq(FIELD_ID, accessPolicy.getId()), accessPolicy)).flatMap(success -> findById(accessPolicy.getId()).toSingle()); } }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<AccessPolicy> update(AccessPolicy item) { AccessPolicyMongo accessPolicy = convert(item); return Single.fromPublisher(accessPoliciesCollection.replaceOne(eq(FIELD_ID, accessPolicy.getId()), accessPolicy)).flatMap(success -> findById(accessPolicy.getId()).toSingle()); }  }
MongoAccessPolicyRepository extends AbstractManagementMongoRepository implements AccessPolicyRepository { @Override public Single<AccessPolicy> update(AccessPolicy item) { AccessPolicyMongo accessPolicy = convert(item); return Single.fromPublisher(accessPoliciesCollection.replaceOne(eq(FIELD_ID, accessPolicy.getId()), accessPolicy)).flatMap(success -> findById(accessPolicy.getId()).toSingle()); }  @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<AccessPolicy> update(AccessPolicy item) { AccessPolicyMongo accessPolicy = convert(item); return Single.fromPublisher(accessPoliciesCollection.replaceOne(eq(FIELD_ID, accessPolicy.getId()), accessPolicy)).flatMap(success -> findById(accessPolicy.getId()).toSingle()); }  @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; }