@Test public void testCreate() throws TechnicalException { Tag tag = new Tag(); tag.setName("testName"); TestObserver<Tag> testObserver = tagRepository.create(tag).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(tagCreated -> tagCreated.getName().equals(tag.getName())); }
@Override public Single<Tag> create(Tag item) { TagMongo tag = convert(item); tag.setId(tag.getId() == null ? RandomString.generate() : tag.getId()); return Single.fromPublisher(tagsCollection.insertOne(tag)).flatMap(success -> findById(tag.getId()).toSingle()); }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> create(Tag item) { TagMongo tag = convert(item); tag.setId(tag.getId() == null ? RandomString.generate() : tag.getId()); return Single.fromPublisher(tagsCollection.insertOne(tag)).flatMap(success -> findById(tag.getId()).toSingle()); } }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> create(Tag item) { TagMongo tag = convert(item); tag.setId(tag.getId() == null ? RandomString.generate() : tag.getId()); return Single.fromPublisher(tagsCollection.insertOne(tag)).flatMap(success -> findById(tag.getId()).toSingle()); }  }
MongoTagRepository extends AbstractManagementMongoRepository implements TagRepository { @Override public Single<Tag> create(Tag item) { TagMongo tag = convert(item); tag.setId(tag.getId() == null ? RandomString.generate() : tag.getId()); return Single.fromPublisher(tagsCollection.insertOne(tag)).flatMap(success -> 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> create(Tag item) { TagMongo tag = convert(item); tag.setId(tag.getId() == null ? RandomString.generate() : tag.getId()); return Single.fromPublisher(tagsCollection.insertOne(tag)).flatMap(success -> 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);  }