### Question:
FormatController extends BaseSelectedColumnObserver implements TableModelListener { @Override public void update(Observable o, Object arg) { super.update(o, arg); if (ColumnDefinitionModel.SELECTED_DEFINITION_PROPERTY.equals(arg)) { setPreviousDataType(); myModel.setAvailableFormats(populateFormats()); } else if (ColumnDefinitionRow.DATA_TYPE_PROPERTY.equals(arg)) { resetFormatIfNeeded(); setPreviousDataType(); myModel.setAvailableFormats(populateFormats()); } } FormatController(PreferencesRegistry preferencesRegistry, ColumnDefinitionModel model); @Override void close(); @Override void tableChanged(TableModelEvent e); @Override void update(Observable o, Object arg);  }### Answer:
@Test public void testUpdate() { DateFormatsConfig config = getDateFormats(); EasyMockSupport support = new EasyMockSupport(); PreferencesRegistry preferencesRegistry = createPreferencesRegistry(support, config, null); support.replayAll(); ColumnDefinitionModel model = new ColumnDefinitionModel(); model.setSampleData(New.<List<String>>list()); ColumnDefinitionRow selectedColumn = new ColumnDefinitionRow(); selectedColumn.setDataType(ColumnType.DATE.toString()); model.getDefinitionTableModel().addRows(New.list(selectedColumn)); @SuppressWarnings("unused") FormatController controller = new FormatController(preferencesRegistry, model); model.setSelectedDefinition(selectedColumn); List<String> actualAvailableFormats = model.getAvailableFormats(); Set<String> actuals = New.set(actualAvailableFormats); assertEquals(actuals.size(), actualAvailableFormats.size()); assertTrue(model.getDefinitionTableModel().isCellEditable(0, 3)); Set<String> expected = New.set(); for (DateFormat format : config.getFormats()) { if (format.getType() == Type.DATE) { expected.add(format.getSdf()); } } assertEquals(expected.size(), actuals.size()); for (String anExpected : expected) { assertTrue(actuals.contains(anExpected)); } selectedColumn.setDataType(ColumnType.TIMESTAMP.toString()); actualAvailableFormats = model.getAvailableFormats(); actuals = New.set(actualAvailableFormats); assertEquals(actuals.size(), actualAvailableFormats.size()); expected = New.set(); for (DateFormat format : config.getFormats()) { if (format.getType() == Type.TIMESTAMP) { expected.add(format.getSdf()); } } assertEquals(expected.size(), actuals.size()); for (String anExpected : expected) { assertTrue(actuals.contains(anExpected)); } support.verifyAll(); }