### Question:
ColumnDefinitionTableModel extends AbstractTableModel { public void clear() { int lastIndex = myRows.size() - 1; myRows.clear(); if (lastIndex >= 0) { fireTableRowsDeleted(0, lastIndex); } }  void addRows(List<ColumnDefinitionRow> rows); void clear(); @Override Class<?> getColumnClass(int columnIndex); @Override int getColumnCount(); @Override String getColumnName(int column); ColumnDefinitionRow getRow(int rowIndex); @Override int getRowCount(); @Override Object getValueAt(int rowIndex, int columnIndex); @Override boolean isCellEditable(int rowIndex, int columnIndex); boolean isImportAllColumns(); void setFormatEditable(boolean isEditable); @Override void setValueAt(Object aValue, int rowIndex, int columnIndex);  }### Answer:
@Test public void testClear() { EasyMockSupport support = new EasyMockSupport(); final List<ColumnDefinitionRow> rows = createTestRows(); TableModelListener listener = support.createMock(TableModelListener.class); listener.tableChanged(EasyMock.isA(TableModelEvent.class)); EasyMock.expectLastCall().andAnswer(new IAnswer<Void>() { @Override public Void answer() { TableModelEvent event = (TableModelEvent)EasyMock.getCurrentArguments()[0]; assertEquals(0, event.getFirstRow()); assertEquals(rows.size() - 1, event.getLastRow()); assertEquals(TableModelEvent.DELETE, event.getType()); return null; } }); support.replayAll(); ColumnDefinitionTableModel model = new ColumnDefinitionTableModel(); model.addTableModelListener(listener); model.clear(); model.removeTableModelListener(listener); model.addRows(rows); model.addTableModelListener(listener); model.clear(); assertEquals(0, model.getRowCount()); support.verifyAll(); }