AnalysesModel implements TreeModel { public void clear() { final ArrayList<ModelType> nodes = new ArrayList<ModelType>(d_nodes.keySet()); d_nodes.clear(); fireTreeNodesRemoved(nodes); }  void add(ModelType type, MCMCPresentation model); void replace(ModelType type, MCMCPresentation oldPresentation, MCMCPresentation newPresentation); void clear(); @Override Object getRoot(); @Override Object getChild(Object parent, int index); @Override int getChildCount(Object parent); @Override boolean isLeaf(Object node); @Override int getIndexOfChild(Object parent, Object child); @Override void valueForPathChanged(TreePath path, Object newValue); @Override void addTreeModelListener(TreeModelListener l); @Override void removeTreeModelListener(TreeModelListener l); SortedSet<MCMCPresentation> getModels(ModelType type);  }
@Test public void testClear() { final AnalysesModel model = new AnalysesModel(); final MCMCPresentation inco1 = new MCMCPresentation(d_wrapper, "inco1"); final MCMCPresentation cons1 = new MCMCPresentation(d_wrapper, "cons1"); final MCMCPresentation splt1 = new MCMCPresentation(d_wrapper, "splt1"); final MCMCPresentation splt2 = new MCMCPresentation(d_wrapper, "splt2"); model.add(ModelType.Inconsistency, inco1); model.add(ModelType.Consistency, cons1); model.add(ModelType.NodeSplit, splt2); model.add(ModelType.NodeSplit, splt1); model.clear(); assertTrue(model.isLeaf(model.getRoot())); assertEquals(0, model.getChildCount(model.getRoot())); model.add(ModelType.NodeSplit, splt1); assertFalse(model.isLeaf(model.getRoot())); assertEquals(1, model.getChildCount(model.getRoot())); assertEquals(1, model.getChildCount(ModelType.NodeSplit)); }