### Question:
StatelessRegistry extends AbstractRegistry { List<List<Measurement>> getBatches() { List<List<Measurement>> batches = new ArrayList<>(); List<Measurement> ms = getMeasurements(); for (int i = 0; i < ms.size(); i += batchSize) { List<Measurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches.add(batch); } return batches; } StatelessRegistry(Clock clock, StatelessConfig config); void start(); void stop();  }### Answer:
@Test public void batchesEmpty() { Assertions.assertEquals(0, registry.getBatches().size()); }
@Test public void batchesExact() { for (int i = 0; i < 9; ++i) { registry.counter("" + i).increment(); } Assertions.assertEquals(3, registry.getBatches().size()); for (List<Measurement> batch : registry.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 = registry.getBatches(); Assertions.assertEquals(3, batches.size()); for (int i = 0; i < batches.size(); ++i) { Assertions.assertEquals((i < 2) ? 3 : 1, batches.get(i).size()); } }
@Test public void batchesExpiration() { for (int i = 0; i < 9; ++i) { registry.counter("" + i).increment(); } Assertions.assertEquals(3, registry.getBatches().size()); for (List<Measurement> batch : registry.getBatches()) { Assertions.assertEquals(3, batch.size()); } clock.setWallTime(Duration.ofMinutes(15).toMillis() + 1); Assertions.assertEquals(0, registry.getBatches().size()); }