AbstractMongoRepository { public List<V> findAll() { return findAll(mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS); } AbstractMongoRepository(final MongoProperties mongoProperties); @PostConstruct void postConstruct(); Optional<V> findOne(final K key); Optional<V> findOne(final K key, final long maxTime, final TimeUnit timeUnit); Stream<V> findAllAsStream(); Stream<V> findAllAsStream(final long maxTime, final TimeUnit timeUnit); List<V> findAll(); List<V> findAll(final long maxTime, final TimeUnit timeUnit); Stream<V> findAllAsStream(final int skip, final int limit); Stream<V> findAllAsStream(final int skip, final int limit, final long maxTime, final TimeUnit timeUnit); List<V> findAll(final int skip, final int limit); List<V> findAll(final int skip, final int limit, final long maxTime, final TimeUnit timeUnit); V createOrUpdate(final V value); V createOrUpdate(final V value, final long maxTime, final TimeUnit timeUnit); void createOrUpdateBulk(final Collection<V> values); void createOrUpdateBulk(final Collection<V> values, final long maxTime, final TimeUnit timeUnit); V create(final V value); V create(final V value, final long maxTime, final TimeUnit timeUnit); boolean update(final V value); boolean update(final V value, final long maxTime, final TimeUnit timeUnit); UpdateIfMatchResult updateIfMatch(final V value, final String eTag); UpdateIfMatchResult updateIfMatch(final V value,
                                             final String eTag,
                                             final long maxTime,
                                             final TimeUnit timeUnit); long size(); long size(final long maxTime, final TimeUnit timeUnit); void delete(final K key); void delete(final K key, final long maxTime, final TimeUnit timeUnit); void deleteAll(); void deleteAll(final long maxTime, final TimeUnit timeUnit); static final String ID; static final String ETAG; }
@Test public void shouldFindAllEntries() { createTestObjects("testObject01", "testObject02", "testObject03", "testObject04", "testObject05", "testObject06"); final List<TestObject> foundObjects = testee.findAll(); assertThat(foundObjects, hasSize(6)); assertThat(foundObjects.get(0).value, is("testObject01")); assertThat(foundObjects.get(1).value, is("testObject02")); assertThat(foundObjects.get(2).value, is("testObject03")); assertThat(foundObjects.get(3).value, is("testObject04")); assertThat(foundObjects.get(4).value, is("testObject05")); assertThat(foundObjects.get(5).value, is("testObject06")); }
@Test public void shouldFindAllEntriesWithSkipAndLimit() { createTestObjects("testObject01", "testObject02", "testObject03", "testObject04", "testObject05", "testObject06"); final List<TestObject> foundObjects = testee.findAll(2, 3); assertThat(foundObjects, hasSize(3)); assertThat(foundObjects.get(0).value, is("testObject03")); assertThat(foundObjects.get(1).value, is("testObject04")); assertThat(foundObjects.get(2).value, is("testObject05")); }