GeneralSpatialBinCollector implements SpatialBinCollector { @Override public void consumeSpatialBins(BinningContext ctx, List<SpatialBin> spatialBins) throws Exception { if (consumingCompleted) { throw new IllegalStateException("Consuming of bins has already been completed."); } mapBinCollector.consumeSpatialBins(ctx, spatialBins); if (mapBinCollector.getSpatialBinCollection().size() > 12000) { moveBinsToFile(ctx); } } GeneralSpatialBinCollector(long numBins); @Override void consumeSpatialBins(BinningContext ctx, List<SpatialBin> spatialBins); @Override SpatialBinCollection getSpatialBinCollection(); @Override void consumingCompleted(); @Override void close();  }
@Test public void testConsumeSpatialBins() throws Exception { final SEAGrid seaGrid = new SEAGrid(10); GeneralSpatialBinCollector store = new GeneralSpatialBinCollector(seaGrid.getNumBins()); try { BinningContext ctx = Mockito.mock(BinningContext.class); Mockito.when(ctx.getPlanetaryGrid()).thenReturn(seaGrid); ArrayList<SpatialBin> spatialBins = new ArrayList<SpatialBin>(); spatialBins.add(createSpatialBin(23)); store.consumeSpatialBins(ctx, spatialBins); store.consumingCompleted(); SpatialBinCollection binMap = store.getSpatialBinCollection(); Iterable<List<SpatialBin>> actualBinLists = binMap.getBinCollection(); List<SpatialBin> binList = actualBinLists.iterator().next(); assertEquals(23, binList.get(0).getIndex()); } finally { store.close(); } }