MeasurementTableModel extends AbstractTableModel { public Object getValueAt(int row, int col) { int i = findStudyIndex(row); if (i < 0) { return null; } Study s = d_studies.get(i); if (row == d_studyIndex.get(i)) { if (col == 0) { return s; } else { return null; } } else { Treatment t = s.getMeasurements().get(row - d_studyIndex.get(i) - 1).getTreatment(); if (col == 0) { return t; } else { return getValue(s, t, col); } } } MeasurementTableModel(
			ObservableList<Study> studies,
			ObservableList<Treatment> treatments,
			ValueModel measurementType);  MeasurementTableModel(DataSetModel model); int getRowCount(); int getColumnCount(); @Override Class<?> getColumnClass(int col); @Override String getColumnName(int col); Object getValueAt(int row, int col); @Override boolean isCellEditable(int row, int col); @Override void setValueAt(Object val, int row, int col); static final String COLNAME_STDDEV; static final String COLNAME_MEAN; static final String COLNAME_SAMPLESIZE; static final String COLNAME_RESPONDERS; static final String COLNAME_ID; }
@Test public void testInitialValues() { assertEquals(d_studies.get(0), d_model.getValueAt(0, 0)); assertEquals(null, d_model.getValueAt(0, 1)); assertEquals(null, d_model.getValueAt(0, 2)); assertEquals(d_studies.get(1), d_model.getValueAt(3, 0)); assertEquals(null, d_model.getValueAt(3, 1)); assertEquals(null, d_model.getValueAt(3, 2)); assertEquals(d_treatments.get(0), d_model.getValueAt(1, 0)); assertEquals(0, d_model.getValueAt(1, 1)); assertEquals(0, d_model.getValueAt(1, 2)); assertEquals(d_treatments.get(2), d_model.getValueAt(2, 0)); assertEquals(0, d_model.getValueAt(2, 1)); assertEquals(0, d_model.getValueAt(2, 2)); }
@Test public void testAddTreatmentMiddleEventChaining() { TableModelEvent event = new TableModelEvent(d_model, 2, 2, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT); TableModelListener mock = createStrictMock(TableModelListener.class); d_model.addTableModelListener(mock); mock.tableChanged(TableModelEventMatcher.eqTableModelEvent(event)); replay(mock); d_studies.get(0).getMeasurements().add(1, new Measurement(d_treatments.get(1))); verify(mock); assertEquals(d_treatments.get(0), d_model.getValueAt(1, 0)); assertEquals(d_treatments.get(1), d_model.getValueAt(2, 0)); assertEquals(d_treatments.get(2), d_model.getValueAt(3, 0)); assertEquals(d_studies.get(1), d_model.getValueAt(4, 0)); }
@Test public void testRemoveTreatmentMiddleEventChaining() { TableModelEvent event = new TableModelEvent(d_model, 2, 2, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE); TableModelListener mock = createStrictMock(TableModelListener.class); d_model.addTableModelListener(mock); mock.tableChanged(TableModelEventMatcher.eqTableModelEvent(event)); replay(mock); d_studies.get(0).getMeasurements().remove(1); verify(mock); assertEquals(d_studies.get(0), d_model.getValueAt(0, 0)); assertEquals(d_treatments.get(0), d_model.getValueAt(1, 0)); assertEquals(d_studies.get(1), d_model.getValueAt(2, 0)); }