public void testIsContextValid() { TnmStagingData data = new TnmStagingData(); data.setInput(TNMStagingCSharp.Src.Staging.Staging.CTX_YEAR_CURRENT, "2016"); // test valid year data.setInput(TnmInput.DX_YEAR, "2016"); Assert.IsTrue(_STAGING.isContextValid("urethra", StagingData.YEAR_DX_KEY, data.getInput())); // test invalid year data.setInput(TnmInput.DX_YEAR, "2014"); Assert.IsFalse(_STAGING.isContextValid("urethra", StagingData.YEAR_DX_KEY, data.getInput())); }
public void testInputBuilder() { TnmStagingData data1 = new TnmStagingData(); data1.setInput(TnmInput.PRIMARY_SITE, "C680"); data1.setInput(TnmInput.HISTOLOGY, "8000"); data1.setInput(TnmInput.BEHAVIOR, "3"); data1.setInput(TnmInput.GRADE, "9"); data1.setInput(TnmInput.DX_YEAR, "2013"); data1.setInput(TnmInput.REGIONAL_NODES_POSITIVE, "99"); data1.setInput(TnmInput.AGE_AT_DX, "060"); data1.setInput(TnmInput.SEX, "1"); data1.setInput(TnmInput.RX_SUMM_SURGERY, "8"); data1.setInput(TnmInput.RX_SUMM_RADIATION, "9"); data1.setInput(TnmInput.CLIN_T, "1"); data1.setInput(TnmInput.CLIN_N, "2"); data1.setInput(TnmInput.CLIN_M, "3"); data1.setInput(TnmInput.PATH_T, "4"); data1.setInput(TnmInput.PATH_N, "5"); data1.setInput(TnmInput.PATH_M, "6"); data1.setSsf(1, "020"); TnmStagingData data2 = new TnmStagingData.TnmStagingInputBuilder() .withInput(TnmInput.PRIMARY_SITE, "C680") .withInput(TnmInput.HISTOLOGY, "8000") .withInput(TnmInput.BEHAVIOR, "3") .withInput(TnmInput.GRADE, "9") .withInput(TnmInput.DX_YEAR, "2013") .withInput(TnmInput.REGIONAL_NODES_POSITIVE, "99") .withInput(TnmInput.AGE_AT_DX, "060") .withInput(TnmInput.SEX, "1") .withInput(TnmInput.RX_SUMM_SURGERY, "8") .withInput(TnmInput.RX_SUMM_RADIATION, "9") .withInput(TnmInput.CLIN_T, "1") .withInput(TnmInput.CLIN_N, "2") .withInput(TnmInput.CLIN_M, "3") .withInput(TnmInput.PATH_T, "4") .withInput(TnmInput.PATH_N, "5") .withInput(TnmInput.PATH_M, "6") .withSsf(1, "020").build(); Assert.IsTrue(TNMStaging_UnitTestApp.Src.Staging.ComparisonUtils.CompareStringDictionaries(data1.getInput(), data2.getInput())); }
public void testStageUrethra() { TnmStagingData data = new TnmStagingData(); data.setInput(TnmInput.PRIMARY_SITE, "C680"); data.setInput(TnmInput.HISTOLOGY, "8000"); data.setInput(TnmInput.BEHAVIOR, "3"); data.setInput(TnmInput.DX_YEAR, "2016"); data.setInput(TnmInput.RX_SUMM_SURGERY, "2"); data.setInput(TnmInput.RX_SUMM_RADIATION, "4"); data.setInput(TnmInput.REGIONAL_NODES_POSITIVE, "02"); data.setInput(TnmInput.CLIN_T, "c0"); data.setInput(TnmInput.CLIN_N, "c1"); data.setInput(TnmInput.CLIN_M, "c0"); data.setInput(TnmInput.PATH_T, "p0"); data.setInput(TnmInput.PATH_N, "p1"); data.setInput(TnmInput.PATH_M, "p1"); // 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(25, data.getPath().Count); Assert.AreEqual(10, data.getOutput().Count); // check outputs Assert.AreEqual(TnmVersion.LATEST.getVersion(), data.getOutput(TnmOutput.DERIVED_VERSION)); Assert.AreEqual("3", data.getOutput(TnmOutput.CLIN_STAGE_GROUP)); Assert.AreEqual("4", data.getOutput(TnmOutput.PATH_STAGE_GROUP)); Assert.AreEqual("4", data.getOutput(TnmOutput.COMBINED_STAGE_GROUP)); Assert.AreEqual("c0", data.getOutput(TnmOutput.COMBINED_T)); Assert.AreEqual("1", data.getOutput(TnmOutput.SOURCE_T)); Assert.AreEqual("c1", data.getOutput(TnmOutput.COMBINED_N)); Assert.AreEqual("1", data.getOutput(TnmOutput.SOURCE_N)); Assert.AreEqual("p1", data.getOutput(TnmOutput.COMBINED_M)); Assert.AreEqual("2", data.getOutput(TnmOutput.SOURCE_M)); }
public void testBadLookupInStage() { TnmStagingData data = new TnmStagingData(); // if site/hist are not supplied, no lookup _STAGING.stage(data); Assert.AreEqual(StagingData.Result.FAILED_MISSING_SITE_OR_HISTOLOGY, data.getResult()); // add hist only and it should fail with same result data.setInput(TnmInput.PRIMARY_SITE, "C489"); _STAGING.stage(data); Assert.AreEqual(StagingData.Result.FAILED_MISSING_SITE_OR_HISTOLOGY, data.getResult()); // put a site/hist combo that doesn't match a schema data.setInput(TnmInput.HISTOLOGY, "9898"); _STAGING.stage(data); Assert.AreEqual(StagingData.Result.FAILED_NO_MATCHING_SCHEMA, data.getResult()); // now a site/hist that returns multiple results data.setInput(TnmInput.PRIMARY_SITE, "C111"); data.setInput(TnmInput.HISTOLOGY, "8200"); _STAGING.stage(data); Assert.AreEqual(StagingData.Result.FAILED_MULITPLE_MATCHING_SCHEMAS, data.getResult()); }
public static void MultiTask_TaskCompute(int id, Object task_data) { MultiTask_DataObj thisDataObj = (MultiTask_DataObj)task_data; try { // load up inputs TnmStagingData data = new TnmStagingData(); foreach (KeyValuePair <TnmInput, String> kp in thisDataObj.mInputValues) { data.setInput(kp.Key, kp.Value); } // save the expected outputs Dictionary <String, String> output = new Dictionary <String, String>(100, StringComparer.Ordinal); String sKeyValue = ""; foreach (KeyValuePair <TnmOutput, String> entry in thisDataObj.mOutputValues) { sKeyValue = entry.Key.toString(); output[sKeyValue] = entry.Value; } // run collaborative stage; if no schema found, set the output to empty SchemaLookup lookup = new SchemaLookup(data.getInput(TnmInput.PRIMARY_SITE), data.getInput(TnmInput.HISTOLOGY)); lookup.setInput(TnmStagingData.SEX_KEY, data.getInput(TnmInput.SEX)); lookup.setInput(TnmStagingData.SSF25_KEY, data.getInput(TnmInput.SSF25)); List <StagingSchema> schemas = mMultiTask_Staging.lookupSchema(lookup); if (schemas.Count == 1) { mMultiTask_Staging.stage(data); } else { Dictionary <String, String> outResult = new Dictionary <String, String>(2, StringComparer.Ordinal); outResult["schema_id"] = "<invalid>"; data.setOutput(outResult); } List <String> mismatches = new List <String>(); // compare results if (!thisDataObj.mbJSONFormat) { String sNewResultStr = ""; String sOldResultStr = thisDataObj.msExpectedResult.Trim(); if (data.getResult() == StagingData.Result.STAGED) { sNewResultStr = "STAGED"; } else if (data.getResult() == StagingData.Result.FAILED_MISSING_SITE_OR_HISTOLOGY) { sNewResultStr = "FAILED_MISSING_SITE_OR_HISTOLOGY"; } else if (data.getResult() == StagingData.Result.FAILED_NO_MATCHING_SCHEMA) { sNewResultStr = "FAILED_NO_MATCHING_SCHEMA"; } else if (data.getResult() == StagingData.Result.FAILED_MULITPLE_MATCHING_SCHEMAS) { sNewResultStr = "FAILED_MULITPLE_MATCHING_SCHEMAS"; } else if (data.getResult() == StagingData.Result.FAILED_INVALID_YEAR_DX) { sNewResultStr = "FAILED_INVALID_YEAR_DX"; } else if (data.getResult() == StagingData.Result.FAILED_INVALID_INPUT) { sNewResultStr = "FAILED_INVALID_INPUT"; } if (sNewResultStr != sOldResultStr) { mismatches.Add(" " + thisDataObj.miLineNum + " --> Result: EXPECTED '" + sOldResultStr + "' ACTUAL: '" + sNewResultStr + "'"); } } // compare output foreach (KeyValuePair <String, String> entry in output) { String expected = ""; output.TryGetValue(entry.Key, out expected); if (expected == null) { expected = ""; } expected = expected.Trim(); String actual = ""; data.getOutput().TryGetValue(entry.Key, out actual); if (actual == null) { actual = ""; } actual = actual.Trim(); if (expected != actual) { mismatches.Add(" " + thisDataObj.miLineNum + " --> " + entry.Key + ": EXPECTED '" + expected + "' ACTUAL: '" + actual + "'"); } } if (mismatches.Count != 0) { String sSchemaIDValue = data.getSchemaId(); IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> [" + sSchemaIDValue + "] Mismatches in " + thisDataObj.msFileName); foreach (String mismatch in mismatches) { IntegrationUtils.WritelineToLog(mismatch); } IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " *** RESULT: " + data.getResult()); IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> Input: " + IntegrationUtils.convertInputMap(data.getInput())); IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> Output: " + IntegrationUtils.convertInputMap(data.getOutput())); if (data.getErrors().Count > 0) { IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> ERRORS: "); foreach (Error e in data.getErrors()) { IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> (" + e.getTable() + ": " + e.getMessage() + ") "); } } Interlocked.Increment(ref miMultiTask_FailedCases); } } catch (Exception e) { IntegrationUtils.WritelineToLog(" " + thisDataObj.miLineNum + " --> Exception processing " + thisDataObj.msFileName + " : " + e.Message); Interlocked.Increment(ref miMultiTask_FailedCases); } Interlocked.Increment(ref miMultiTask_ThreadProcessedCases); }