### Question:
DomainTreeModel implements TreeModel { public int getIndexOfChild(Object parent, Object child) { if (parent.equals(d_root)) { return d_domain.getCategories().indexOf(child); } else { ObservableList<? extends Entity> contents = d_domain.getCategoryContents(getCategoryNode(parent)); if (contents != null) { return contents.indexOf(child); } } return -1; } DomainTreeModel(Domain domain); Object getChild(Object parent, int childIndex); int getChildCount(Object parent); int getIndexOfChild(Object parent, Object child); Object getRoot(); boolean isLeaf(Object node); TreePath getPathTo(Object node); void addTreeModelListener(TreeModelListener listener); void removeTreeModelListener(TreeModelListener listener); void valueForPathChanged(TreePath path, Object node);  }### Answer:
@Test public void testGetIndexOfChild() { assertEquals(0, d_treeModel.getIndexOfChild(d_treeModel.getRoot(), d_domain.getCategory(Unit.class))); for (EntityCategory cat : d_domain.getCategories()) { assertEquals(d_domain.getCategories().indexOf(cat), d_treeModel.getIndexOfChild(d_treeModel.getRoot(), cat)); } assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(Unit.class), Domain.GRAM)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(Indication.class), d_firstIndication)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(Endpoint.class), d_firstEndpoint)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(AdverseEvent.class), d_firstADE)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(PopulationCharacteristic.class), d_firstPopChar)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(Study.class), d_firstStudy)); assertEquals(0, d_treeModel.getIndexOfChild(d_domain.getCategory(Drug.class), d_firstDrug)); assertEquals(-1, d_treeModel.getIndexOfChild(d_domain.getCategory(Endpoint.class), new Object())); }