### Question:
GeoPackageLayerActivationHandler extends AbstractActivationListener { @Override public void handleCommit(boolean active, DataGroupInfo dgi, PhasedTaskCanceller canceller) { super.handleCommit(active, dgi, canceller); if (dgi == null) { return; } for (DataTypeInfo info : dgi.getMembers(false)) { if (info instanceof GeoPackageDataTypeInfo) { GeoPackageDataTypeInfo geopackageInfo = (GeoPackageDataTypeInfo)info; GeoPackageLayer layer = geopackageInfo.getLayer(); if (layer.getLayerType() == LayerType.TILE) { if (active) { myTileListener.layerActivated(geopackageInfo); } else { myTileListener.layerDeactivated(geopackageInfo); } } else if (layer.getLayerType() == LayerType.FEATURE && canceller != null) { if (active) { myFeatureLayerListener.layerActivated(geopackageInfo); } else { myFeatureLayerListener.layerDeactivated(geopackageInfo); } } } } } GeoPackageLayerActivationHandler(EventManager eventManager, LayerActivationListener tileLayerListener,
            LayerActivationListener featureLayerListener); void close(); LayerActivationListener getTileLayerListener(); @Override void handleCommit(boolean active, DataGroupInfo dgi, PhasedTaskCanceller canceller);  }### Answer:
@Test public void testFeatureActive() { EasyMockSupport support = new EasyMockSupport(); GeoPackageDataTypeInfo featureLayer = createFeatureLayer(); DataGroupInfo dataGroup = createDataGroup(support, featureLayer); LayerActivationListener featureListener = createListener(support, featureLayer); LayerActivationListener tileListener = support.createMock(LayerActivationListener.class); EventManager eventManager = createEventManager(support); support.replayAll(); GeoPackageLayerActivationHandler provider = new GeoPackageLayerActivationHandler(eventManager, tileListener, featureListener); provider.handleCommit(true, dataGroup, new PhasedTaskCanceller(null, new Phaser())); support.verifyAll(); }
@Test public void testFeatureInactive() { EasyMockSupport support = new EasyMockSupport(); GeoPackageDataTypeInfo featureLayer = createFeatureLayer(); DataGroupInfo dataGroup = createDataGroup(support, featureLayer); LayerActivationListener featureListener = support.createMock(LayerActivationListener.class); featureListener.layerDeactivated(EasyMock.same(featureLayer)); LayerActivationListener tileListener = support.createMock(LayerActivationListener.class); EventManager eventManager = createEventManager(support); support.replayAll(); GeoPackageLayerActivationHandler provider = new GeoPackageLayerActivationHandler(eventManager, tileListener, featureListener); provider.handleCommit(false, dataGroup, new PhasedTaskCanceller(null, new Phaser())); support.verifyAll(); }
@Test public void testHandleCommit() { EasyMockSupport support = new EasyMockSupport(); GeoPackageDataTypeInfo tileLayer = createTileLayer(); DataGroupInfo dataGroup = createDataGroup(support, tileLayer); LayerActivationListener listener = createListener(support, tileLayer); LayerActivationListener featureListener = support.createMock(LayerActivationListener.class); EventManager eventManager = createEventManager(support); support.replayAll(); GeoPackageLayerActivationHandler provider = new GeoPackageLayerActivationHandler(eventManager, listener, featureListener); provider.handleCommit(true, dataGroup, null); support.verifyAll(); }
@Test public void testHandleCommitInactive() { EasyMockSupport support = new EasyMockSupport(); GeoPackageDataTypeInfo tileLayer = createTileLayer(); DataGroupInfo dataGroup = createDataGroup(support, tileLayer); LayerActivationListener featureListener = support.createMock(LayerActivationListener.class); LayerActivationListener listener = support.createMock(LayerActivationListener.class); listener.layerDeactivated(EasyMock.eq(tileLayer)); EventManager eventManager = createEventManager(support); support.replayAll(); GeoPackageLayerActivationHandler provider = new GeoPackageLayerActivationHandler(eventManager, listener, featureListener); provider.handleCommit(false, dataGroup, null); support.verifyAll(); }