SpreadsheetImportActivity extends AbstractAsynchronousActivity<JsonNode> { @Override public void configure(JsonNode configurationBean) throws ActivityConfigurationException { this.configurationBean = configurationBean; rowRange = SpreadsheetUtils.getRange(configurationBean.get("rowRange")); logger.debug("Setting row range to " + rowRange); columnRange = SpreadsheetUtils.getRange(configurationBean.get("columnRange")); logger.debug("Setting column range to " + columnRange); ignoreBlankRows = configurationBean.get("ignoreBlankRows").booleanValue(); missingCellValue = configurationBean.get("emptyCellValue").textValue(); logger.debug("Setting empty cell value to '" + missingCellValue + "'"); emptyCellPolicy = SpreadsheetEmptyCellPolicy.valueOf(configurationBean.get("emptyCellPolicy").textValue()); logger.debug("Setting empty cell policy to " + emptyCellPolicy); outputFormat = SpreadsheetOutputFormat.valueOf(configurationBean.get("outputFormat").textValue()); logger.debug("Setting output format to " + outputFormat); csvDelimiter = configurationBean.get("csvDelimiter").textValue(); logger.debug("Setting csv delimiter to '" + csvDelimiter + "'"); } SpreadsheetImportActivity(); @Override void configure(JsonNode configurationBean); @Override JsonNode getConfiguration(); @Override void executeAsynch(final Map<String, T2Reference> data,
			final AsynchronousActivityCallback callback); static final String URI; static final String INPUT_PORT_NAME; static final String OUTPUT_PORT_NAME; }
@Test public void testExecuteAsynchMapOfStringT2ReferenceAsynchronousActivityCallback() throws Exception { configuration.put("columnRange", configuration.objectNode().put("start", 0).put("end", 3)); activity.configure(configuration); for (ActivityInputPort activityInputPort : activityFactory.getInputPorts(configuration)) { edits.getAddActivityInputPortEdit(activity, activityInputPort).doEdit(); } for (ActivityOutputPort activityOutputPort : activityFactory.getOutputPorts(configuration)) { edits.getAddActivityOutputPortEdit(activity, activityOutputPort).doEdit(); } Map<String, Class<?>> outputs = new HashMap<String, Class<?>>(); outputs.put("A", String.class); outputs.put("B", String.class); outputs.put("C", String.class); outputs.put("D", String.class); Map<String, Object> results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl", (Object) "src/test/resources/test-spreadsheet.xls"), outputs); assertEquals(4, results.size()); assertTrue(results.get("A") instanceof List<?>); assertEquals(15, ((List<?>) results.get("A")).size()); results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl", (Object) "src/test/resources/test-spreadsheet.ods"), outputs); assertEquals(4, results.size()); assertTrue(results.get("A") instanceof List<?>); assertEquals(15, ((List<?>) results.get("A")).size()); results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl", (Object) "src/test/resources/test-spreadsheet.csv"), outputs); assertEquals(4, results.size()); assertTrue(results.get("A") instanceof List<?>); assertEquals(15, ((List<?>) results.get("A")).size()); configuration.put("outputFormat", SpreadsheetOutputFormat.SINGLE_PORT.name()); activity.configure(configuration); outputs = new HashMap<String, Class<?>>(); outputs.put("output", String.class); results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl", (Object) "src/test/resources/test-spreadsheet.xls"), outputs); assertEquals(1, results.size()); assertTrue(results.get("output") instanceof String); assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length); configuration.put("csvDelimiter", "\t"); activity.configure(configuration); results = ActivityInvoker.invokeAsyncActivity(activity, Collections.singletonMap("fileurl", (Object) "src/test/resources/test-spreadsheet.csv"), outputs); assertEquals(1, results.size()); assertTrue(results.get("output") instanceof String); assertEquals(15, ((String) results.get("output")).split(System.getProperty("line.separator")).length); }