@SuppressWarnings("unchecked")
@Test
public void testDrainOutputToDataSetHandle() {

	ExecutionContext executionContext = buildExecutionContext();
	
	Function function = newFunction(FUNCTION_ID_SUCCESS);
	((InMemoryFunctionAccessorImpl)executionContext.get(FunctionAccessor.class)).save(function);
	
	CallFunctionHandler handler = new CallFunctionHandler();
	handler.init(executionContext);
	
	List<Object> addedRows = new ArrayList<>();
	DataSetHandle dataSetHandle = new DataSetHandle() {
		@Override
		public Object next() {
			return null;
		}
		@Override
		public void addRow(Object row) {
			addedRows.add(row);
		}
		
	};
	executionContext.getVariablesManager().putVariable(executionContext.getReport(),"dataSet", dataSetHandle);
	
	CallFunction callFunction = new CallFunction();
	callFunction.setFunctionId(function.getId().toString());
	callFunction.setResultMap(new DynamicValue<String>("dataSet"));
	
	CallFunctionReportNode node = (CallFunctionReportNode) execute(callFunction);
	Assert.assertEquals(ReportNodeStatus.PASSED, node.getStatus());
	
	Assert.assertEquals("Value1", ((Map<String, String>)addedRows.get(0)).get("Output1"));
}