FilteredTableModel extends AbstractTableModel { public int convertModelToView(int row) { return modelToView[row]; } FilteredTableModel(LogDataTableModel logDataTableModel); @Override int getRowCount(); @Override int getColumnCount(); int convertModelToView(int row); int convertViewToModel(int row); @Override Object getValueAt(int rowIndex, int columnIndex); void addFilter(LogFilter filter); void removeFilter(LogFilter filter); void filterChanged(); String getColumnName(int columnIndex); Class<?> getColumnClass(int columnIndex); boolean isCellEditable(int rowIndex, int columnIndex); void setValueAt(Object aValue, int rowIndex, int columnIndex); void addTableModelListener(TableModelListener l); void removeTableModelListener(TableModelListener l);  }
@Test public void testConvertModelToView() { filteredTableModel.addFilter(new AbstractLogFilter("A", "B") { @Override public JComponent getGUI() { return null; } @Override public boolean accept(LogData logData, int row) { return row % 2 == 0; } }); filteredTableModel.doFiltering(); int rowIndex = 0; for (int i = 0; i < dataTableModel.getRowCount(); i++) { if (i % 2 == 0) { assertEquals(rowIndex, filteredTableModel.convertModelToView(i)); rowIndex++; } else { assertEquals(-1, filteredTableModel.convertModelToView(i)); } } }