LanguageTreeModel extends AbstractTreeTableModel { @Override public int getIndexOfChild(final Object parentNode, final Object childNode) { if (parentNode == this.getRoot()) { return CollectionUtil.indexOfInstance(this.languageModels.keySet(), childNode); } throw new IllegalArgumentException(); } LanguageTreeModel(final ILanguageOptionHandler options); @Override int getColumnCount(); @Override UUID getChild(final Object parentNode, final int index); @Override int getChildCount(final Object parentNode); @Override int getIndexOfChild(final Object parentNode, final Object childNode); @Override boolean isCellEditable(final Object node, final int columnIndex); @Override Object getValueAt(final Object node, final int columnIndex);  }
@Test public void testGetIndexOfChild() { Assert.assertEquals(-1, this.model.getIndexOfChild(this.root, null)); Assert.assertEquals(0, this.model.getIndexOfChild(this.root, this.model.getChild(this.root, 0))); Assert.assertEquals(1, this.model.getIndexOfChild(this.root, this.model.getChild(this.root, 1))); Assert.assertEquals(2, this.model.getIndexOfChild(this.root, this.model.getChild(this.root, 2))); Assert.assertEquals(3, this.model.getIndexOfChild(this.root, this.model.getChild(this.root, 3))); Assert.assertEquals(4, this.model.getIndexOfChild(this.root, this.model.getChild(this.root, 4))); }
@Test(expected = IllegalArgumentException.class) public void testGetIndexOfChild_ParentNull() { this.model.getIndexOfChild(null, null); }