### Question:
TileImporter { public void importTiles(GeoPackage geopackage, List<GeoPackageLayer> layers, CancellableTaskActivity ta, ProgressModel model) { for (GeoPackageLayer layer : layers) { if (layer instanceof GeoPackageTileLayer) { importLayer(geopackage, (GeoPackageTileLayer)layer, ta, model); } if (ta.isCancelled()) { break; } } } TileImporter(TileRowImporter rowImporter); void importTiles(GeoPackage geopackage, List<GeoPackageLayer> layers, CancellableTaskActivity ta, ProgressModel model);  }### Answer:
@Test public void test() { EasyMockSupport support = new EasyMockSupport(); myPreviousCount = 0; GeoPackageTileLayer tileLayer = new GeoPackageTileLayer("package", "c:\\somefile.gpkg", ourTileLayerName, 4); GeoPackageLayer featureLayer = new GeoPackageLayer(tileLayer.getPackageName(), tileLayer.getPackageFile(), "testFeature", LayerType.FEATURE, 10); MockTileDao dao = createDao(support, 4); BoundingBox boundingBox = new BoundingBox(10, 10, 11, 11); TileRowImporter rowImporter = createImporter(support, tileLayer, dao, boundingBox, New.list(dao.getRows().get(0), dao.getRows().get(1))); GeoPackage geopackage = createGeoPackage(support, dao); CancellableTaskActivity ta = new CancellableTaskActivity(); ProgressModel model = new ProgressModel(); Observer observer = createObserver(support, 2, model, null); model.addObserver(observer); support.replayAll(); TileImporter importer = new TileImporter(rowImporter); importer.importTiles(geopackage, New.list(featureLayer, tileLayer), ta, model); assertEquals(2, model.getCompletedCount()); support.verifyAll(); }
@Test public void testCancel() { EasyMockSupport support = new EasyMockSupport(); myPreviousCount = 0; GeoPackageTileLayer tileLayer = new GeoPackageTileLayer("package", "c:\\somefile.gpkg", ourTileLayerName, 4); GeoPackageLayer featureLayer = new GeoPackageLayer(tileLayer.getPackageName(), tileLayer.getPackageFile(), "testFeature", LayerType.FEATURE, 10); MockTileDao dao = createDao(support, 4); BoundingBox boundingBox = new BoundingBox(10, 10, 11, 11); TileRowImporter rowImporter = createImporter(support, tileLayer, dao, boundingBox, New.list(dao.getRows().get(0))); GeoPackage geopackage = createGeoPackage(support, dao); CancellableTaskActivity ta = new CancellableTaskActivity(); ProgressModel model = new ProgressModel(); Observer observer = createObserver(support, 1, model, ta); model.addObserver(observer); support.replayAll(); TileImporter importer = new TileImporter(rowImporter); importer.importTiles(geopackage, New.list(featureLayer, tileLayer), ta, model); assertEquals(model.getCompletedCount(), 1); support.verifyAll(); }