### Question:
SimpleFeatureActionsAdapter implements ListChangeListener<SimpleFeatureActionGroup> { public void close() { myActions.getFeatureGroups().removeListener(this); for (SimpleFeatureActionGroupAdapter adapter : myAdapters.values()) { adapter.close(); } } SimpleFeatureActionsAdapter(SimpleFeatureActions actions); void close(); @Override void onChanged(Change<? extends SimpleFeatureActionGroup> c);  }### Answer:
@Test public void testAdd() { FeatureAction action = new FeatureAction(); SimpleFeatureAction simpleAction = new SimpleFeatureAction(action); SimpleFeatureActionGroup group = new SimpleFeatureActionGroup(); group.getActions().add(simpleAction); SimpleFeatureActions actions = new SimpleFeatureActions(ourLayerId); SimpleFeatureActionsAdapter adapter = new SimpleFeatureActionsAdapter(actions); actions.getFeatureGroups().add(group); group.setGroupName(ourNewGroupName); assertEquals(ourNewGroupName, action.getGroupName()); adapter.close(); }
@Test public void testClose() { FeatureAction action = new FeatureAction(); SimpleFeatureAction simpleAction = new SimpleFeatureAction(action); SimpleFeatureActionGroup group = new SimpleFeatureActionGroup(); group.getActions().add(simpleAction); SimpleFeatureActions actions = new SimpleFeatureActions(ourLayerId); SimpleFeatureActionsAdapter adapter = new SimpleFeatureActionsAdapter(actions); actions.getFeatureGroups().add(group); group.setGroupName(ourNewGroupName); assertEquals(ourNewGroupName, action.getGroupName()); adapter.close(); group.setGroupName("another"); assertEquals(ourNewGroupName, action.getGroupName()); actions.getFeatureGroups().remove(group); actions.getFeatureGroups().add(group); group.setGroupName("yet another"); assertEquals(ourNewGroupName, action.getGroupName()); }
@Test public void testExisting() { FeatureAction action = new FeatureAction(); SimpleFeatureAction simpleAction = new SimpleFeatureAction(action); SimpleFeatureActionGroup group = new SimpleFeatureActionGroup(); group.getActions().add(simpleAction); SimpleFeatureActions actions = new SimpleFeatureActions(ourLayerId); actions.getFeatureGroups().add(group); SimpleFeatureActionsAdapter adapter = new SimpleFeatureActionsAdapter(actions); group.setGroupName(ourNewGroupName); assertEquals(ourNewGroupName, action.getGroupName()); adapter.close(); }
@Test public void testRemove() { FeatureAction action = new FeatureAction(); SimpleFeatureAction simpleAction = new SimpleFeatureAction(action); SimpleFeatureActionGroup group = new SimpleFeatureActionGroup(); group.getActions().add(simpleAction); SimpleFeatureActions actions = new SimpleFeatureActions(ourLayerId); SimpleFeatureActionsAdapter adapter = new SimpleFeatureActionsAdapter(actions); actions.getFeatureGroups().add(group); group.setGroupName(ourNewGroupName); assertEquals(ourNewGroupName, action.getGroupName()); actions.getFeatureGroups().remove(group); group.setGroupName("another"); assertEquals(ourNewGroupName, action.getGroupName()); adapter.close(); }