### Question:
ComponentRefreshable implements ComponentUpdater, HandlerListener, LayerableListener { @Override public void update(double extrp, Handlables featurables) { for (final Integer layer : indexs) { for (final Refreshable refreshable : layers.get(layer)) { refreshable.update(extrp); } } if (updateRequested) { for (final LayerUpdate update : toUpdate) { getLayer(update.layerOld).remove(update.refreshable); getLayer(update.layerNew).add(update.refreshable); indexs.add(update.layerNew); } toUpdate.clear(); updateRequested = false; } } ComponentRefreshable(); @Override void update(double extrp, Handlables featurables); @Override void notifyHandlableAdded(Featurable featurable); @Override void notifyHandlableRemoved(Featurable featurable); @Override void notifyLayerChanged(FeatureProvider provider,
                                   Integer layerRefreshOld,
                                   Integer layerRefreshNew,
                                   Integer layerDisplayOld,
                                   Integer layerDisplayNew);  }### Answer:
@Test void testComponentLayer() { final ComponentRefreshable component = new ComponentRefreshable(); services.add(component); final AtomicInteger last = new AtomicInteger(); final Layerable object1 = createObject(component, last); final Layerable object2 = createObject(component, last); final Layerable object3 = createObject(component, last); final Layerable object4 = createObject(component, last); object1.setLayer(Integer.valueOf(4), Integer.valueOf(4)); object2.setLayer(Integer.valueOf(6), Integer.valueOf(6)); object3.setLayer(Integer.valueOf(5), Integer.valueOf(5)); object4.setLayer(Integer.valueOf(4), Integer.valueOf(4)); last.set(-1); component.update(1.0, null); assertEquals(4, object1.getLayerDisplay().intValue()); assertEquals(6, object2.getLayerDisplay().intValue()); assertEquals(5, object3.getLayerDisplay().intValue()); assertEquals(4, object4.getLayerDisplay().intValue()); assertEquals(-1, last.get()); component.update(1.0, null); assertEquals(object2.getFeature(Identifiable.class).getId().intValue(), last.get()); object2.getFeature(Identifiable.class).notifyDestroyed(); object4.getFeature(Identifiable.class).notifyDestroyed(); last.set(-1); component.update(1.0, null); assertEquals(object3.getFeature(Identifiable.class).getId().intValue(), last.get()); }
@Test void testWithHandler() { final FeaturableModel object = new FeaturableModel(services, setup); final Layerable layerable = new LayerableModel(services, setup); object.addFeature(layerable); object.addFeature(new RefreshableModel(extrp -> { })); final Handler handler = new Handler(services); handler.addComponent(new ComponentRefreshable()); handler.add(object); handler.update(1.0); assertEquals(0, layerable.getLayerRefresh().intValue()); }