@Test public void testUpdate() { Organization organization = new Organization(); organization.setName("testName"); Organization organizationCreated = organizationRepository.create(organization).blockingGet(); Organization organizationUpdated = new Organization(); organizationUpdated.setId(organizationCreated.getId()); organizationUpdated.setName("testNameUpdated"); TestObserver<Organization> obs = organizationRepository.update(organizationUpdated).test(); obs.awaitTerminalEvent(); obs.assertComplete(); obs.assertNoErrors(); obs.assertValue(o -> o.getName().equals(organizationUpdated.getName()) && o.getId().equals(organizationCreated.getId())); }
@Override public Single<Organization> update(Organization organization) { return Single.fromPublisher(collection.replaceOne(eq(FIELD_ID, organization.getId()), convert(organization))) .flatMap(updateResult -> findById(organization.getId()).toSingle()); }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> update(Organization organization) { return Single.fromPublisher(collection.replaceOne(eq(FIELD_ID, organization.getId()), convert(organization))) .flatMap(updateResult -> findById(organization.getId()).toSingle()); } }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> update(Organization organization) { return Single.fromPublisher(collection.replaceOne(eq(FIELD_ID, organization.getId()), convert(organization))) .flatMap(updateResult -> findById(organization.getId()).toSingle()); }  }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> update(Organization organization) { return Single.fromPublisher(collection.replaceOne(eq(FIELD_ID, organization.getId()), convert(organization))) .flatMap(updateResult -> findById(organization.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Organization> findById(String id); @Override Single<Organization> create(Organization organization); @Override Single<Organization> update(Organization organization); @Override Completable delete(String id); @Override Single<Long> count(); }
MongoOrganizationRepository extends AbstractManagementMongoRepository implements OrganizationRepository { @Override public Single<Organization> update(Organization organization) { return Single.fromPublisher(collection.replaceOne(eq(FIELD_ID, organization.getId()), convert(organization))) .flatMap(updateResult -> findById(organization.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Organization> findById(String id); @Override Single<Organization> create(Organization organization); @Override Single<Organization> update(Organization organization); @Override Completable delete(String id); @Override Single<Long> count(); static final String FIELD_ID; }