@Test public void testUpdate() throws TechnicalException { Credential credential = new Credential(); credential.setCredentialId("credentialId"); Credential credentialCreated = credentialRepository.create(credential).blockingGet(); Credential updateCredential = new Credential(); updateCredential.setId(credentialCreated.getId()); updateCredential.setCredentialId("updateCredentialId"); TestObserver<Credential> testObserver = credentialRepository.update(updateCredential).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(c -> c.getCredentialId().equals(updateCredential.getCredentialId())); }
@Override public Single<Credential> update(Credential item) { CredentialMongo credential = convert(item); return Single.fromPublisher(credentialsCollection.replaceOne(eq(FIELD_ID, credential.getId()), credential)).flatMap(updateResult -> findById(credential.getId()).toSingle()); }
MongoCredentialRepository extends AbstractManagementMongoRepository implements CredentialRepository { @Override public Single<Credential> update(Credential item) { CredentialMongo credential = convert(item); return Single.fromPublisher(credentialsCollection.replaceOne(eq(FIELD_ID, credential.getId()), credential)).flatMap(updateResult -> findById(credential.getId()).toSingle()); } }
MongoCredentialRepository extends AbstractManagementMongoRepository implements CredentialRepository { @Override public Single<Credential> update(Credential item) { CredentialMongo credential = convert(item); return Single.fromPublisher(credentialsCollection.replaceOne(eq(FIELD_ID, credential.getId()), credential)).flatMap(updateResult -> findById(credential.getId()).toSingle()); }  }
MongoCredentialRepository extends AbstractManagementMongoRepository implements CredentialRepository { @Override public Single<Credential> update(Credential item) { CredentialMongo credential = convert(item); return Single.fromPublisher(credentialsCollection.replaceOne(eq(FIELD_ID, credential.getId()), credential)).flatMap(updateResult -> findById(credential.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<List<Credential>> findByUserId(ReferenceType referenceType, String referenceId, String userId); @Override Single<List<Credential>> findByUsername(ReferenceType referenceType, String referenceId, String username); @Override Single<List<Credential>> findByCredentialId(ReferenceType referenceType, String referenceId, String credentialId); @Override Maybe<Credential> findById(String id); @Override Single<Credential> create(Credential item); @Override Single<Credential> update(Credential item); @Override Completable delete(String id); }
MongoCredentialRepository extends AbstractManagementMongoRepository implements CredentialRepository { @Override public Single<Credential> update(Credential item) { CredentialMongo credential = convert(item); return Single.fromPublisher(credentialsCollection.replaceOne(eq(FIELD_ID, credential.getId()), credential)).flatMap(updateResult -> findById(credential.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<List<Credential>> findByUserId(ReferenceType referenceType, String referenceId, String userId); @Override Single<List<Credential>> findByUsername(ReferenceType referenceType, String referenceId, String username); @Override Single<List<Credential>> findByCredentialId(ReferenceType referenceType, String referenceId, String credentialId); @Override Maybe<Credential> findById(String id); @Override Single<Credential> create(Credential item); @Override Single<Credential> update(Credential item); @Override Completable delete(String id);  }