@Test public void shouldBeAbleToConverAPaginatedListIntoAPaginatedListRepresentation() { Criteria criteria = Criteria.criteria().from(new Date()).to(new Date()).limit(10).page(1); PaginatedList<?> list = new PaginatedList<>(new ArrayList<>(), 100, criteria); PaginatedListRepresentation<AccountRepresentation> representation = paginatedListConversionService.convert(list, AccountRepresentation.class); assertThat(representation.getPayload()).isEmpty(); assertThat(representation.getCriteria()).isEqualToComparingFieldByField(criteriaConversionService.convert(criteria)); assertThat(representation.getPages()).isEqualTo(10); assertThat(representation.getTotal()).isEqualTo(100); assertThat(representation.getRemaining()).isEqualTo(90); }
public <C> PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type) { PaginatedListRepresentation<C> representation = new PaginatedListRepresentation<>(); representation.setCriteria(criteriaConversionService.convert(list.getCriteria())); representation.setTotal(list.getTotal()); representation.setRemaining(list.getRemainingResults()); representation.setPages(list.getTotalPages()); return representation; }
PaginatedListConversionService { public <C> PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type) { PaginatedListRepresentation<C> representation = new PaginatedListRepresentation<>(); representation.setCriteria(criteriaConversionService.convert(list.getCriteria())); representation.setTotal(list.getTotal()); representation.setRemaining(list.getRemainingResults()); representation.setPages(list.getTotalPages()); return representation; } }
PaginatedListConversionService { public <C> PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type) { PaginatedListRepresentation<C> representation = new PaginatedListRepresentation<>(); representation.setCriteria(criteriaConversionService.convert(list.getCriteria())); representation.setTotal(list.getTotal()); representation.setRemaining(list.getRemainingResults()); representation.setPages(list.getTotalPages()); return representation; } @Autowired  PaginatedListConversionService(CriteriaConversionService criteriaConversionService); }
PaginatedListConversionService { public <C> PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type) { PaginatedListRepresentation<C> representation = new PaginatedListRepresentation<>(); representation.setCriteria(criteriaConversionService.convert(list.getCriteria())); representation.setTotal(list.getTotal()); representation.setRemaining(list.getRemainingResults()); representation.setPages(list.getTotalPages()); return representation; } @Autowired  PaginatedListConversionService(CriteriaConversionService criteriaConversionService); PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type); }
PaginatedListConversionService { public <C> PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type) { PaginatedListRepresentation<C> representation = new PaginatedListRepresentation<>(); representation.setCriteria(criteriaConversionService.convert(list.getCriteria())); representation.setTotal(list.getTotal()); representation.setRemaining(list.getRemainingResults()); representation.setPages(list.getTotalPages()); return representation; } @Autowired  PaginatedListConversionService(CriteriaConversionService criteriaConversionService); PaginatedListRepresentation<C> convert(PaginatedList<?> list, Class<C> type);  }