@Test public void testUpdate() throws TechnicalException { Factor factor = new Factor(); factor.setName("testName"); Factor factorCreated = factorRepository.create(factor).blockingGet(); Factor updateFactor = new Factor(); updateFactor.setId(factorCreated.getId()); updateFactor.setName("testUpdatedName"); TestObserver<Factor> testObserver = factorRepository.update(updateFactor).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(f -> f.getName().equals(updateFactor.getName())); }
@Override public Single<Factor> update(Factor item) { FactorMongo authenticator = convert(item); return Single.fromPublisher(factorsCollection.replaceOne(eq(FIELD_ID, authenticator.getId()), authenticator)).flatMap(updateResult -> findById(authenticator.getId()).toSingle()); }
MongoFactorRepository extends AbstractManagementMongoRepository implements FactorRepository { @Override public Single<Factor> update(Factor item) { FactorMongo authenticator = convert(item); return Single.fromPublisher(factorsCollection.replaceOne(eq(FIELD_ID, authenticator.getId()), authenticator)).flatMap(updateResult -> findById(authenticator.getId()).toSingle()); } }
MongoFactorRepository extends AbstractManagementMongoRepository implements FactorRepository { @Override public Single<Factor> update(Factor item) { FactorMongo authenticator = convert(item); return Single.fromPublisher(factorsCollection.replaceOne(eq(FIELD_ID, authenticator.getId()), authenticator)).flatMap(updateResult -> findById(authenticator.getId()).toSingle()); }  }
MongoFactorRepository extends AbstractManagementMongoRepository implements FactorRepository { @Override public Single<Factor> update(Factor item) { FactorMongo authenticator = convert(item); return Single.fromPublisher(factorsCollection.replaceOne(eq(FIELD_ID, authenticator.getId()), authenticator)).flatMap(updateResult -> findById(authenticator.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<Factor>> findAll(); @Override Single<Set<Factor>> findByDomain(String domain); @Override Maybe<Factor> findByDomainAndFactorType(String domain, String factorType); @Override Maybe<Factor> findById(String factorId); @Override Single<Factor> create(Factor item); @Override Single<Factor> update(Factor item); @Override Completable delete(String id); }
MongoFactorRepository extends AbstractManagementMongoRepository implements FactorRepository { @Override public Single<Factor> update(Factor item) { FactorMongo authenticator = convert(item); return Single.fromPublisher(factorsCollection.replaceOne(eq(FIELD_ID, authenticator.getId()), authenticator)).flatMap(updateResult -> findById(authenticator.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<Factor>> findAll(); @Override Single<Set<Factor>> findByDomain(String domain); @Override Maybe<Factor> findByDomainAndFactorType(String domain, String factorType); @Override Maybe<Factor> findById(String factorId); @Override Single<Factor> create(Factor item); @Override Single<Factor> update(Factor item); @Override Completable delete(String id);  }