@Test public void testCreate() throws TechnicalException { Event event = new Event(); event.setType(Type.DOMAIN); TestObserver<Event> testObserver = eventRepository.create(event).test(); testObserver.awaitTerminalEvent(); testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValue(e -> e.getType().equals(Type.DOMAIN)); }
@Override public Single<Event> create(Event item) { EventMongo event = convert(item); event.setId(event.getId() == null ? RandomString.generate() : event.getId()); return Single.fromPublisher(eventsCollection.insertOne(event)).flatMap(success -> findById(event.getId()).toSingle()); }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<Event> create(Event item) { EventMongo event = convert(item); event.setId(event.getId() == null ? RandomString.generate() : event.getId()); return Single.fromPublisher(eventsCollection.insertOne(event)).flatMap(success -> findById(event.getId()).toSingle()); } }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<Event> create(Event item) { EventMongo event = convert(item); event.setId(event.getId() == null ? RandomString.generate() : event.getId()); return Single.fromPublisher(eventsCollection.insertOne(event)).flatMap(success -> findById(event.getId()).toSingle()); }  }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<Event> create(Event item) { EventMongo event = convert(item); event.setId(event.getId() == null ? RandomString.generate() : event.getId()); return Single.fromPublisher(eventsCollection.insertOne(event)).flatMap(success -> findById(event.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<List<Event>> findByTimeFrame(long from, long to); @Override Maybe<Event> findById(String id); @Override Single<Event> create(Event item); @Override Single<Event> update(Event item); @Override Completable delete(String id); }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<Event> create(Event item) { EventMongo event = convert(item); event.setId(event.getId() == null ? RandomString.generate() : event.getId()); return Single.fromPublisher(eventsCollection.insertOne(event)).flatMap(success -> findById(event.getId()).toSingle()); }  @PostConstruct void init(); @Override Single<List<Event>> findByTimeFrame(long from, long to); @Override Maybe<Event> findById(String id); @Override Single<Event> create(Event item); @Override Single<Event> update(Event item); @Override Completable delete(String id);  }