### Question:
DataElementProvider { public List<DataElement> provideElements(MetaColumnsTableModel tableModel, JTable table, int timePrecision) { List<DataElement> modified = New.list(); List<DataElement> elements = getDataElementsToExport(tableModel, table, false, myExportModel.isIncludeMetaColumns(), myColorFormatter); for (DataElement element : elements) { if (element.getVisualizationState().isSelected() || !myExportModel.isSelectedRowsOnly()) { Map<String, Object> extraValues = New.map(); addWkt(element, extraValues); separateDateAndTime(element, extraValues, timePrecision); formatLatLon(element, extraValues); if (!extraValues.isEmpty()) { element = createDelegateElement(element, new ExtraColumnsMetaDataProvider(element.getMetaData(), extraValues)); } modified.add(element); } } return modified; } DataElementProvider(ExportOptionsModel exportModel, DataElementCache elementCache); static List<DataElement> getDataElementsToExport(MetaColumnsTableModel tableModel, JTable table, boolean onlySelected); List<DataElement> provideElements(MetaColumnsTableModel tableModel, JTable table, int timePrecision);  }### Answer:
@Test public void testAllOptionsSelected() { EasyMockSupport support = new EasyMockSupport(); List<DataElement> elements = createTestData(support); MetaColumnsTableModel tableModel = createTableModel(support, elements); DataElementCache cache = createElementCache(support, elements.get(0).getDataTypeInfo()); support.replayAll(); JTable table = new JTable(); table.setModel(tableModel); ExportOptionsModel exportModel = new ExportOptionsModel(); exportModel.setAddWkt(true); exportModel.setIncludeMetaColumns(true); exportModel.setSelectedColorFormat(ColorFormat.RGB_CODED); exportModel.setSelectedLatLonFormat(LatLonFormat.DMS); exportModel.setSelectedRowsOnly(true); exportModel.setSeparateDateTimeColumns(true); DataElementProvider provider = new DataElementProvider(exportModel, cache); List<DataElement> actuals = provider.provideElements(tableModel, table, 2); assertEquals(2, actuals.size()); for (DataElement actual : actuals) { assertTrue(actual instanceof MapDataElement); assertDataElement(actual); } support.verifyAll(); }
@Test public void testDefaults() { EasyMockSupport support = new EasyMockSupport(); List<DataElement> elements = createTestData(support); MetaColumnsTableModel tableModel = createTableModel(support, elements); DataElementCache cache = createElementCache(support, elements.get(0).getDataTypeInfo()); support.replayAll(); JTable table = new JTable(); table.setModel(tableModel); ExportOptionsModel exportModel = new ExportOptionsModel(); DataElementProvider provider = new DataElementProvider(exportModel, cache); List<DataElement> actuals = provider.provideElements(tableModel, table, 2); int index = 0; for (DataElement expected : elements) { DataElement actual = actuals.get(index); assertTrue(actual instanceof MapDataElement); assertEquals(expected.getMetaData().getValues().size(), actual.getMetaData().getValues().size()); assertTrue(expected.getMetaData().getValues().containsAll(actual.getMetaData().getValues())); assertEquals(((MapDataElement)expected).getMapGeometrySupport(), ((MapDataElement)actual).getMapGeometrySupport()); index++; } support.verifyAll(); }