@Test public void testUpdate() throws TechnicalException { Tag tag = new Tag(); tag.setName("testName"); Tag tagCreated = tagRepository.create(tag).blockingGet(); Tag updatedTag = new Tag(); updatedTag.setId(tagCreated.getId()); updatedTag.setName("testUpdatedName"); TestObserver<Tag> testObserver = tagRepository.update(updatedTag).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(t -> t.getName().equals(updatedTag.getName())); }
@Override public Single<Tag> update(Tag item) { TagMongo tag = convert(item); return Single.fromPublisher(tagsCollection.replaceOne(eq(FIELD_ID, tag.getId()), tag)).flatMap(updateResult -> findById(tag.getId()).toSingle()); }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> update(Tag item) { TagMongo tag = convert(item); return Single.fromPublisher(tagsCollection.replaceOne(eq(FIELD_ID, tag.getId()), tag)).flatMap(updateResult -> findById(tag.getId()).toSingle()); } }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> update(Tag item) { TagMongo tag = convert(item); return Single.fromPublisher(tagsCollection.replaceOne(eq(FIELD_ID, tag.getId()), tag)).flatMap(updateResult -> findById(tag.getId()).toSingle()); }  }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> update(Tag item) { TagMongo tag = convert(item); return Single.fromPublisher(tagsCollection.replaceOne(eq(FIELD_ID, tag.getId()), tag)).flatMap(updateResult -> findById(tag.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Tag> findById(String id, String organizationId); @Override Maybe<Tag> findById(String id); @Override Flowable<Tag> findAll(String organizationId); @Override Single<Tag> create(Tag item); @Override Single<Tag> update(Tag item); @Override Completable delete(String id); }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> update(Tag item) { TagMongo tag = convert(item); return Single.fromPublisher(tagsCollection.replaceOne(eq(FIELD_ID, tag.getId()), tag)).flatMap(updateResult -> findById(tag.getId()).toSingle()); }  @PostConstruct void init(); @Override Maybe<Tag> findById(String id, String organizationId); @Override Maybe<Tag> findById(String id); @Override Flowable<Tag> findAll(String organizationId); @Override Single<Tag> create(Tag item); @Override Single<Tag> update(Tag item); @Override Completable delete(String id);  }