@Test public void testFindByTimeFrame() throws TechnicalException { final long from = 1571214259000l; final long to = 1571214281000l; Event event = new Event(); event.setType(Type.DOMAIN); event.setCreatedAt(new Date(from)); event.setUpdatedAt(event.getCreatedAt()); eventRepository.create(event).blockingGet(); TestObserver<List<Event>> testObserver1 = eventRepository.findByTimeFrame(from, to).test(); testObserver1.awaitTerminalEvent(); testObserver1.assertComplete(); testObserver1.assertNoErrors(); testObserver1.assertValue(events -> events.size() == 1); }
@Override public Single<List<Event>> findByTimeFrame(long from, long to) { List<Bson> filters = new ArrayList<>(); filters.add(gte(FIELD_UPDATED_AT, new Date(from))); if (to > from) { filters.add(lte(FIELD_UPDATED_AT, new Date(to))); } return Flowable.fromPublisher(eventsCollection.find(and(filters))).map(this::convert).toList(); }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<List<Event>> findByTimeFrame(long from, long to) { List<Bson> filters = new ArrayList<>(); filters.add(gte(FIELD_UPDATED_AT, new Date(from))); if (to > from) { filters.add(lte(FIELD_UPDATED_AT, new Date(to))); } return Flowable.fromPublisher(eventsCollection.find(and(filters))).map(this::convert).toList(); } }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<List<Event>> findByTimeFrame(long from, long to) { List<Bson> filters = new ArrayList<>(); filters.add(gte(FIELD_UPDATED_AT, new Date(from))); if (to > from) { filters.add(lte(FIELD_UPDATED_AT, new Date(to))); } return Flowable.fromPublisher(eventsCollection.find(and(filters))).map(this::convert).toList(); }  }
MongoEventRepository extends AbstractManagementMongoRepository implements EventRepository { @Override public Single<List<Event>> findByTimeFrame(long from, long to) { List<Bson> filters = new ArrayList<>(); filters.add(gte(FIELD_UPDATED_AT, new Date(from))); if (to > from) { filters.add(lte(FIELD_UPDATED_AT, new Date(to))); } return Flowable.fromPublisher(eventsCollection.find(and(filters))).map(this::convert).toList(); }  @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<List<Event>> findByTimeFrame(long from, long to) { List<Bson> filters = new ArrayList<>(); filters.add(gte(FIELD_UPDATED_AT, new Date(from))); if (to > from) { filters.add(lte(FIELD_UPDATED_AT, new Date(to))); } return Flowable.fromPublisher(eventsCollection.find(and(filters))).map(this::convert).toList(); }  @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);  }