AggregationRepository { public List<Aggregation> getGrouped(long campaignItemId, ChronoUnit chronoUnit, ZoneId timeZone, ZonedDateTime from, ZonedDateTime to, boolean desc) { return this.getGrouped(this.getAllByPeriod(campaignItemId,from,to), chronoUnit, timeZone, desc); } AggregationRepository(AmazonDynamoDB amazonDynamoDB, String tableName);  AggregationRepository(); List<Aggregation> getAll(long campaignItemId); List<Aggregation> getAllByPeriod(long campaignItemId, ZonedDateTime from, ZonedDateTime to); Aggregation total(long campaignItemId); List<Aggregation> getGrouped(long campaignItemId, ChronoUnit chronoUnit, ZoneId timeZone, ZonedDateTime from, ZonedDateTime to, boolean desc); List<Aggregation> getGrouped(long campaignItemId, ChronoUnit chronoUnit, ZoneId timeZone, boolean desc); List<Aggregation> getGrouped(List<Aggregation> aggregations, ChronoUnit chronoUnit, ZoneId timeZone, boolean desc);  }
@Test public void getGrouped() { AggregationRepository repository = new AggregationRepository(); List<Aggregation> aggregations = Arrays.asList( new Aggregation(-1987217790,1546068600,0L,0L,17986L) ); List<Aggregation> expected = Arrays.asList( new Aggregation(-1987217790,1546041600,0L,0L,17986L) ); List<Aggregation> result = repository.getGrouped(aggregations, ChronoUnit.DAYS, ZoneOffset.UTC, false); assertArrayEquals(expected.toArray(), result.toArray()); }