@Test public void testUpdate() throws TechnicalException { Certificate certificate = new Certificate(); certificate.setName("testName"); Certificate certificateCreated = certificateRepository.create(certificate).blockingGet(); Certificate updatedCertificate = new Certificate(); updatedCertificate.setId(certificateCreated.getId()); updatedCertificate.setName("testUpdatedName"); TestObserver<Certificate> testObserver = certificateRepository.update(updatedCertificate).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(d -> d.getName().equals(updatedCertificate.getName())); }
@Override public Single<Certificate> update(Certificate item) { CertificateMongo certificate = convert(item); return Single.fromPublisher(certificatesCollection.replaceOne(eq(FIELD_ID, certificate.getId()), certificate)).flatMap(updateResult -> findById(certificate.getId()).toSingle()); }
MongoCertificateRepository extends AbstractManagementMongoRepository implements CertificateRepository { @Override public Single<Certificate> update(Certificate item) { CertificateMongo certificate = convert(item); return Single.fromPublisher(certificatesCollection.replaceOne(eq(FIELD_ID, certificate.getId()), certificate)).flatMap(updateResult -> findById(certificate.getId()).toSingle()); } }
MongoCertificateRepository extends AbstractManagementMongoRepository implements CertificateRepository { @Override public Single<Certificate> update(Certificate item) { CertificateMongo certificate = convert(item); return Single.fromPublisher(certificatesCollection.replaceOne(eq(FIELD_ID, certificate.getId()), certificate)).flatMap(updateResult -> findById(certificate.getId()).toSingle()); }  }
MongoCertificateRepository extends AbstractManagementMongoRepository implements CertificateRepository { @Override public Single<Certificate> update(Certificate item) { CertificateMongo certificate = convert(item); return Single.fromPublisher(certificatesCollection.replaceOne(eq(FIELD_ID, certificate.getId()), certificate)).flatMap(updateResult -> findById(certificate.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<Certificate>> findByDomain(String domain); @Override Single<Set<Certificate>> findAll(); @Override Maybe<Certificate> findById(String certificateId); @Override Single<Certificate> create(Certificate item); @Override Single<Certificate> update(Certificate item); @Override Completable delete(String id); }
MongoCertificateRepository extends AbstractManagementMongoRepository implements CertificateRepository { @Override public Single<Certificate> update(Certificate item) { CertificateMongo certificate = convert(item); return Single.fromPublisher(certificatesCollection.replaceOne(eq(FIELD_ID, certificate.getId()), certificate)).flatMap(updateResult -> findById(certificate.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<Set<Certificate>> findByDomain(String domain); @Override Single<Set<Certificate>> findAll(); @Override Maybe<Certificate> findById(String certificateId); @Override Single<Certificate> create(Certificate item); @Override Single<Certificate> update(Certificate item); @Override Completable delete(String id);  }