### Question:
FormatController extends BaseSelectedColumnObserver implements TableModelListener { private void saveCurrentFormat() { ColumnDefinitionRow selCol = getSelectedColumn(); if (selCol == null) { return; } String type = selCol.getDataType(); String fmt = selCol.getFormat(); if (type == null || type.isEmpty() || fmt == null || fmt.isEmpty()) { return; } CellFormatter formatter = new CellFormatterFactory().getFormatter(ColumnType.fromString(type), myPreferencesRegistry); if (formatter instanceof CellFormatSaver) { ((CellFormatSaver)formatter).saveNewFormat(fmt); } } FormatController(PreferencesRegistry preferencesRegistry, ColumnDefinitionModel model); @Override void close(); @Override void tableChanged(TableModelEvent e); @Override void update(Observable o, Object arg);  }### Answer:
@Test public void testSaveCurrentFormat() { String newFormat = "y"; DateFormatsConfig config = getDateFormats(); EasyMockSupport support = new EasyMockSupport(); PreferencesRegistry preferencesRegistry = createPreferencesRegistry(support, config, "yyyy"); support.replayAll(); BeforeAfterRow successRow = new BeforeAfterRow(); successRow.setAfterValue("05/20/2014"); BeforeAfterRow failRow1 = new BeforeAfterRow(); failRow1.setAfterValue("N/A"); BeforeAfterRow failRow2 = new BeforeAfterRow(); failRow2.setAfterValue(Constants.ERROR_LABEL); ColumnDefinitionModel model = new ColumnDefinitionModel(); ColumnDefinitionRow selectedColumn = new ColumnDefinitionRow(); selectedColumn.setDataType(ColumnType.DATE.toString()); selectedColumn.setFormat(newFormat); @SuppressWarnings("unused") FormatController controller = new FormatController(preferencesRegistry, model); model.setSelectedDefinition(selectedColumn); model.getBeforeAfterTableModel().addRows(New.list(failRow1)); model.getBeforeAfterTableModel().clear(); newFormat = "yy"; selectedColumn.setFormat(newFormat); model.getBeforeAfterTableModel().addRows(New.list(failRow2)); model.getBeforeAfterTableModel().clear(); newFormat = "yyy"; selectedColumn.setFormat(newFormat); model.getAvailableFormats().add(newFormat); model.getBeforeAfterTableModel().addRows(New.list(successRow)); model.getAvailableFormats().clear(); newFormat = "yyyy"; selectedColumn.setFormat(newFormat); model.getBeforeAfterTableModel().addRows(New.list(successRow)); support.verifyAll(); }