BatchTinyTablesTripleProvider implements TinyTablesTripleProvider { @Override public synchronized TinyTablesTriple getNextTriple() { if (triples.isEmpty()) { generateNewTriples(); } return triples.poll(); } BatchTinyTablesTripleProvider(TinyTablesTripleGenerator generator, int batchSize); @Override synchronized TinyTablesTriple getNextTriple(); @Override void close();  }
@Test public void testNextTriple() { TinyTablesTripleGenerator fac = new TinyTablesTripleGenerator(0, null, null) { @Override public List<TinyTablesTriple> generate(int amount) { List<TinyTablesTriple> triples = new ArrayList<>(); for (int i = 0; i < amount; i++) { triples.add(TinyTablesTriple.fromShares(true, true, true)); } return triples; } }; BatchTinyTablesTripleProvider gen = new BatchTinyTablesTripleProvider(fac, 10); for (int i = 0; i < 20; i++) { assertThat(gen.getNextTriple(), is(TinyTablesTriple.fromShares(true, true, true))); } }