### Question:
AtlasRegistry extends AbstractRegistry implements AutoCloseable { synchronized List<RollupPolicy.Result> getBatches(long t) { List<RollupPolicy.Result> batches = new ArrayList<>(); publishTaskTimer("getBatches").record(() -> { int n = atlasMeasurements.size(); debugRegistry.distributionSummary("spectator.registrySize").record(n); List<Measurement> input = new ArrayList<>(n); Iterator<Map.Entry<Id, Consolidator>> it = atlasMeasurements.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Id, Consolidator> entry = it.next(); Consolidator consolidator = entry.getValue(); consolidator.update(t, Double.NaN); double v = consolidator.value(t); if (!Double.isNaN(v)) { input.add(new Measurement(entry.getKey(), t, v)); } if (consolidator.isEmpty()) { it.remove(); } } List<RollupPolicy.Result> results = rollupPolicy.apply(input); int rollupSize = results.stream().mapToInt(r -> r.measurements().size()).sum(); debugRegistry.distributionSummary("spectator.rollupResultSize").record(rollupSize); for (RollupPolicy.Result result : results) { List<Measurement> ms = result.measurements(); for (int i = 0; i < ms.size(); i += batchSize) { List<Measurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(new RollupPolicy.Result(result.commonTags(), batch)); } } }); return batches; } @Inject  AtlasRegistry(Clock clock, AtlasConfig config); void start(); void stop(); @Override void close(); @SuppressWarnings("PMD.UselessOverridingMethod") @Override void removeExpiredMeters(); @Override Stream<Measurement> measurements();  }### Answer:
@Test public void batchesEmpty() { Assertions.assertEquals(0, getBatches().size()); }
@Test public void batchesExact() { for (int i = 0; i < 9; ++i) { registry.counter("" + i).increment(); } Assertions.assertEquals(3, getBatches().size()); for (List<Measurement> batch : getBatches()) { Assertions.assertEquals(3, batch.size()); } }
@Test public void batchesLastPartial() { for (int i = 0; i < 7; ++i) { registry.counter("" + i).increment(); } List<List<Measurement>> batches = getBatches(); Assertions.assertEquals(3, batches.size()); for (int i = 0; i < batches.size(); ++i) { Assertions.assertEquals((i < 2) ? 3 : 1, batches.get(i).size()); } }