public Iterable<M> getAll() { return this.repo.findAll(); }
@Override public Iterable<Object> invokeFindAll(Sort sort) { return customFindAllMethod ? super.invokeFindAll(sort) : repository.findAll(); }
public default Iterable<T> findAll() { return getRepository().findAll(); }
@Override public Iterable<Object> invokeFindAll(Pageable pageable) { return customFindAllMethod ? super.invokeFindAll(pageable) : repository.findAll(); }
@Override public void afterPropertiesSet() throws Exception { registerFilters(filterConfiguration.getConfiguredEventFilters(), true); registerFilters(filterRepository.findAll(), false); contractEventFilterFactories.ifPresent((factories) -> { factories.forEach(factory -> registerFilters(factory.build(), true)); }); }
@Test public void test_findall_no_filter() { //Given there is some entity in database List<String> ids = Arrays.asList("testFindAll1", "testFindAll2"); dao.save(ids.stream() .map(this::build) .collect(Collectors.toList())); //when we iterate on all objects int count = 0; for (Iterator<T> itElements = dao.findAll().iterator(); itElements.hasNext(); itElements.next()) { count++; } //Then we find the good number of objects assertThat("Retrieving all elements should return the same quantity", count, is(equalTo(ids.size()))); }
@Test public void test_delete_in_mass() { //Given db has some ids List<String> ids = Arrays.asList("deleteId1", "deleteId2", "deleteId3", "deleteId4"); ids.forEach(id -> dao.save(build(id))); //When we request the deletion giving two existing ids Iterable<T> entities = dao.findAll(ids.subList(0, 2)); dao.delete(entities); //Then the count is decremented assertThat(countEntities(), is(equalTo(ids.size() - 2))); }
@Test public void test_findall_filtered() { //Given there is some entity in database List<String> ids = Arrays.asList("testFindAll1", "testFindAll2"); dao.save(ids.stream() .map(this::build) .collect(Collectors.toList())); dao.save(build("testFindAll3")); //when we iterate on filtered objects //then we have objects that existed int count = 0; for (Iterator<T> itElements = dao.findAll(ids).iterator(); itElements.hasNext(); itElements.next()) { count++; } //and we find the good number of objects assertThat("Retrieving filtered elements should return the same quantity", count, is(equalTo(ids.size()))); }