public void testTableRowParsing()
        {
            StagingTable table = new StagingTable();

            table.setId("test_table");
            table.setColumnDefinitions(new List <IColumnDefinition>()
            {
                new StagingColumnDefinition("key1", "Input 1", ColumnType.INPUT)
            });
            table.setRawRows(new List <List <String> >());
            table.getRawRows().Add(new List <String>()
            {
                ",1,2,3"
            });
            table.getRawRows().Add(new List <String>()
            {
                "1,2,3,"
            });

            StagingDataProvider.initTable(table);

            Assert.AreEqual(2, table.getTableRows().Count);


            //StagingTableRow
            List <ITableRow> tablerows = table.getTableRows();

            StagingTableRow row = (tablerows[0] as StagingTableRow);

            Assert.AreEqual(4, row.getInputs()["key1"].Count);

            row = (tablerows[1] as StagingTableRow);
            Assert.AreEqual(4, row.getInputs()["key1"].Count);
        }
        public void testRangeParsing()
        {
            StagingTable table = _STAGING.getTable("path_n_daj");

            Assert.IsNotNull(table);
            Assert.AreEqual("p0I-", table.getRawRows()[2][0]);

            StagingTableRow tablerow = (table.getTableRows()[2] as StagingTableRow);

            Assert.AreEqual("p0I-", tablerow.getInputs()["path_n"][0].getLow());

            tablerow = (table.getTableRows()[2] as StagingTableRow);
            Assert.AreEqual("p0I-", tablerow.getInputs()["path_n"][0].getHigh());
        }
        // Initialize a table.
        // @param table table entity
        // @return initialized table entity
        public static StagingTable initTable(StagingTable table)
        {
            HashSet <String> extraInputs = new HashSet <String>();

            List <List <String> > pTableRawRows = table.getRawRows();

            // empty out the parsed rows
            List <ITableRow> newTableRows = new List <ITableRow>();

            if (pTableRawRows != null)
            {
                newTableRows.Capacity = pTableRawRows.Count;
            }
            table.setTableRows(newTableRows);

            if (pTableRawRows != null)
            {
                foreach (List <String> row in pTableRawRows)
                {
                    StagingTableRow tableRowEntity = new StagingTableRow();

                    // make sure the number of cells in the row matches the number of columns defined
                    if (table.getColumnDefinitions().Count != row.Count)
                    {
                        throw new System.InvalidOperationException("Table '" + table.getId() + "' has a row with " + row.Count + " values but should have " + table.getColumnDefinitions().Count + ": " + row);
                    }

                    // loop over the column definitions in order since the data needs to be retrieved by array position
                    for (int i = 0; i < table.getColumnDefinitions().Count; i++)
                    {
                        StagingColumnDefinition col = (StagingColumnDefinition)(table.getColumnDefinitions()[i]);
                        String cellValue            = row[i];

                        switch (col.getType())
                        {
                        case ColumnType.INPUT:
                            // if there are no ranges in the list, that means the cell was "blank" and is not needed in the table row
                            List <Range> ranges = splitValues(cellValue);
                            if (!(ranges.Count == 0))
                            {
                                tableRowEntity.addInput(col.getKey(), ranges);

                                // if there are key references used (values that reference other inputs) like {{key}}, then add them to the extra inputs list
                                foreach (StagingRange range in ranges)
                                {
                                    if (DecisionEngineFuncs.isReferenceVariable(range.getLow()))
                                    {
                                        extraInputs.Add(DecisionEngineFuncs.trimBraces(range.getLow()));
                                    }
                                    if (DecisionEngineFuncs.isReferenceVariable(range.getHigh()))
                                    {
                                        extraInputs.Add(DecisionEngineFuncs.trimBraces(range.getHigh()));
                                    }
                                }
                            }
                            break;

                        case ColumnType.ENDPOINT:
                            StagingEndpoint endpoint = parseEndpoint(cellValue);
                            endpoint.setResultKey(col.getKey());
                            tableRowEntity.addEndpoint(endpoint);

                            // if there are key references used (values that reference other inputs) like {{key}}, then add them to the extra inputs list
                            if (EndpointType.VALUE == endpoint.getType() && DecisionEngineFuncs.isReferenceVariable(endpoint.getValue()))
                            {
                                extraInputs.Add(DecisionEngineFuncs.trimBraces(endpoint.getValue()));
                            }
                            break;

                        case ColumnType.DESCRIPTION:
                            // do nothing
                            break;

                        default:
                            throw new System.InvalidOperationException("Table '" + table.getId() + " has an unknown column type: '" + col.getType() + "'");
                        }
                    }

                    tableRowEntity.ConvertColumnInput();

                    newTableRows.Add(tableRowEntity);
                }
            }

            // add extra inputs, if any; do not include context variables since they are not user input
            foreach (String s in Staging.CONTEXT_KEYS)
            {
                extraInputs.Remove(s);
            }
            table.setExtraInput(extraInputs.Count == 0 ? null : extraInputs);

            table.GenerateInputColumnDefinitions();

            return(table);
        }