public void testBasicInputs() { // all inputs for all schemas will have null unit and decimal places foreach (String id in _STAGING.getSchemaIds()) { StagingSchema schema = _STAGING.getSchema(id); foreach (StagingSchemaInput input in schema.getInputs()) { Assert.IsNull(input.getUnit(), "No schemas should have units"); Assert.IsTrue(input.getDecimalPlaces() == 0, "No schemas should have decimal places"); } } }
public void testGetInputsWithContext() { InMemoryDataProvider provider = new InMemoryDataProvider("test", "1.0"); StagingTable table = new StagingTable(); table.setId("table_input1"); StagingColumnDefinition def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 1"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "1" }); table.getRawRows().Add(new List <String>() { "2" }); provider.addTable(table); table = new StagingTable(); table.setId("table_input2"); def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 2"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "" }); table.getRawRows().Add(new List <String>() { "A" }); table.getRawRows().Add(new List <String>() { "B" }); provider.addTable(table); table = new StagingTable(); table.setId("table_selection"); def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 1"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "*" }); provider.addTable(table); table = new StagingTable(); table.setId("table_mapping"); def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 1"); def1.setType(ColumnType.INPUT); StagingColumnDefinition def2 = new StagingColumnDefinition(); def2.setKey("input2"); def2.setName("Input 2"); def2.setType(ColumnType.INPUT); StagingColumnDefinition def3 = new StagingColumnDefinition(); def3.setKey("mapped_field"); def3.setName("Temp value"); def3.setType(ColumnType.INPUT); StagingColumnDefinition def4 = new StagingColumnDefinition(); def4.setKey("final_output"); def4.setName("Output"); def4.setType(ColumnType.ENDPOINT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1, def2, def3, def4 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "*", "*", "*", "VALUE:ABC" }); provider.addTable(table); StagingSchema schema = new StagingSchema(); schema.setId("schema_test"); schema.setSchemaSelectionTable("table_selection"); List <StagingSchemaInput> inputs = new List <StagingSchemaInput>(); inputs.Add(new StagingSchemaInput("input1", "Input 1", "table_input1")); inputs.Add(new StagingSchemaInput("input2", "Input 2", "table_input2")); schema.setInputs(inputs); List <StagingSchemaOutput> outputs = new List <StagingSchemaOutput>(); outputs.Add(new StagingSchemaOutput("final_output", "Final Output")); schema.setOutputs(outputs); StagingMapping mapping = new StagingMapping(); mapping.setId("m1"); List <IKeyValue> mapInitialContext = new List <IKeyValue>(); mapInitialContext.Add(new StagingKeyValue("tmp_field", null)); mapping.setInitialContext(mapInitialContext); StagingTablePath path = new StagingTablePath(); path.setId("table_mapping"); HashSet <IKeyMapping> pathInputMap = new HashSet <IKeyMapping>(); pathInputMap.Add(new StagingKeyMapping("tmp_field", "mapped_field")); path.setInputMapping(pathInputMap); HashSet <String> pathInputs = new HashSet <String>(); pathInputs.Add("input1"); pathInputs.Add("input2"); pathInputs.Add("tmp_field"); path.setInputs(pathInputs); HashSet <String> pathOutputs = new HashSet <String>(); pathOutputs.Add("final_output"); path.setOutputs(pathOutputs); List <ITablePath> mapTablePaths = new List <ITablePath>(); mapTablePaths.Add(path); mapping.setTablePaths(mapTablePaths); List <IMapping> schemaMappings = new List <IMapping>(); schemaMappings.Add(mapping); schema.setMappings(schemaMappings); provider.addSchema(schema); TNMStagingCSharp.Src.Staging.Staging staging = TNMStagingCSharp.Src.Staging.Staging.getInstance(provider); HashSet <String> testSet1 = staging.getInputs(staging.getSchema("schema_test")); HashSet <String> testSet2 = new HashSet <String>(); testSet2.Add("input1"); testSet2.Add("input2"); // should only return the "real" inputs and not the temp field set in initial context Assert.IsTrue(testSet1.SetEquals(testSet2)); }
public void testBlankInputs() { InMemoryDataProvider provider = new InMemoryDataProvider("test", "1.0"); StagingTable table = new StagingTable(); table.setId("table_input1"); StagingColumnDefinition def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 1"); def1.setType(ColumnType.INPUT); StagingColumnDefinition def2 = new StagingColumnDefinition(); def2.setKey("result1"); def2.setName("Result1"); def2.setType(ColumnType.DESCRIPTION); table.setColumnDefinitions(new List <IColumnDefinition>() { def1, def2 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "1", "ONE" }); table.getRawRows().Add(new List <String>() { "2", "TWO" }); provider.addTable(table); table = new StagingTable(); table.setId("table_input2"); def1 = new StagingColumnDefinition(); def1.setKey("input2"); def1.setName("Input 2"); def1.setType(ColumnType.INPUT); def2 = new StagingColumnDefinition(); def2.setKey("result2"); def2.setName("Result2"); def2.setType(ColumnType.DESCRIPTION); table.setColumnDefinitions(new List <IColumnDefinition>() { def1, def2 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "", "Blank" }); table.getRawRows().Add(new List <String>() { "A", "Letter A" }); table.getRawRows().Add(new List <String>() { "B", "Letter B" }); provider.addTable(table); table = new StagingTable(); table.setId("table_selection"); def1 = new StagingColumnDefinition(); def1.setKey("input1"); def1.setName("Input 1"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "*" }); provider.addTable(table); table = new StagingTable(); table.setId("primary_site"); def1 = new StagingColumnDefinition(); def1.setKey("site"); def1.setName("Site"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "C509" }); provider.addTable(table); table = new StagingTable(); table.setId("histology"); def1 = new StagingColumnDefinition(); def1.setKey("hist"); def1.setName("Histology"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "8000" }); provider.addTable(table); table = new StagingTable(); table.setId("table_year_dx"); def1 = new StagingColumnDefinition(); def1.setKey("year_dx"); def1.setName("Year DX"); def1.setType(ColumnType.INPUT); table.setColumnDefinitions(new List <IColumnDefinition>() { def1 }); table.setRawRows(new List <List <String> >()); table.getRawRows().Add(new List <String>() { "1900-2100" }); provider.addTable(table); StagingSchema schema = new StagingSchema(); schema.setId("schema_test"); schema.setSchemaSelectionTable("table_selection"); List <StagingSchemaInput> inputs = new List <StagingSchemaInput>(); inputs.Add(new StagingSchemaInput("site", "Primary Site", "primary_site")); inputs.Add(new StagingSchemaInput("hist", "Hist", "histology")); inputs.Add(new StagingSchemaInput("year_dx", "Year DX", "table_year_dx")); inputs.Add(new StagingSchemaInput("input1", "Input 1", "table_input1")); inputs.Add(new StagingSchemaInput("input2", "Input 2", "table_input2")); schema.setInputs(inputs); provider.addSchema(schema); TNMStagingCSharp.Src.Staging.Staging staging = TNMStagingCSharp.Src.Staging.Staging.getInstance(provider); Assert.AreEqual("schema_test", staging.getSchema("schema_test").getId()); // check case where required input field not supplied (i.e. no default); since there are is no workflow defined, this should // not cause an error StagingData data = new StagingData("C509", "8000"); data.setInput("year_dx", "2018"); data.setInput("input1", "1"); staging.stage(data); Assert.AreEqual(StagingData.Result.STAGED, data.getResult()); // pass in blank for "input2" data = new StagingData("C509", "8000"); data.setInput("year_dx", "2018"); data.setInput("input1", "1"); data.setInput("input2", ""); staging.stage(data); Assert.AreEqual(StagingData.Result.STAGED, data.getResult()); // pass in null for "input2" data = new StagingData("C509", "8000"); data.setInput("year_dx", "2018"); data.setInput("input1", "1"); data.setInput("input2", null); staging.stage(data); Assert.AreEqual(StagingData.Result.STAGED, data.getResult()); }
public void testExternalLoad() { Assert.AreEqual("testing", _STAGING.getAlgorithm()); Assert.AreEqual("99.99", _STAGING.getVersion()); Assert.AreEqual(1, _STAGING.getSchemaIds().Count); Assert.AreEqual(62, _STAGING.getTableIds().Count); StagingSchema schema = _STAGING.getSchema("urethra"); Assert.IsNotNull(schema); Assert.AreEqual("testing", schema.getAlgorithm()); Assert.AreEqual("99.99", schema.getVersion()); StagingTable table = _STAGING.getTable("ajcc_descriptor_codes"); Assert.IsNotNull(table); Assert.AreEqual("testing", table.getAlgorithm()); Assert.AreEqual("99.99", table.getVersion()); Assert.AreEqual(6, table.getTableRows().Count); HashSet <String> involved = _STAGING.getInvolvedTables("urethra"); Assert.AreEqual(62, involved.Count); Assert.IsTrue(involved.Contains("mets_eval_ipa")); StagingData data = new StagingData(); data.setInput("site", "C680"); data.setInput("hist", "8000"); data.setInput("behavior", "3"); data.setInput("grade", "9"); data.setInput("year_dx", "2013"); data.setInput("cs_input_version_original", "020550"); data.setInput("extension", "100"); data.setInput("extension_eval", "9"); data.setInput("nodes", "100"); data.setInput("nodes_eval", "9"); data.setInput("mets", "10"); data.setInput("mets_eval", "9"); // perform the staging _STAGING.stage(data); Assert.AreEqual(StagingData.Result.STAGED, data.getResult()); Assert.AreEqual("urethra", data.getSchemaId()); Assert.AreEqual(0, data.getErrors().Count); Assert.AreEqual(37, data.getPath().Count); // check output Assert.AreEqual("129", data.getOutput("schema_number")); Assert.AreEqual("020550", data.getOutput("csver_derived")); // AJCC 6 Assert.AreEqual("70", data.getOutput("stor_ajcc6_stage")); // AJCC 7 Assert.AreEqual("700", data.getOutput("stor_ajcc7_stage")); // Summary Stage Assert.AreEqual("7", data.getOutput("stor_ss77")); Assert.AreEqual("7", data.getOutput("stor_ss2000")); }