Enhance error handling in getValue function and update test cases for recipe validation
This commit is contained in:
@ -1001,22 +1001,22 @@ public class AdaptationTesting : ISMTP
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation))
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation) && !fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation.Contains("10."))
|
||||
{
|
||||
if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation))
|
||||
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.ErrorTargetFileLocation);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.SourceFileLocation))
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.SourceFileLocation) && !fileConnectorConfigurationTuple.Item2.SourceFileLocation.Contains("10."))
|
||||
{
|
||||
if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.SourceFileLocation))
|
||||
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.SourceFileLocation);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.TargetFileLocation))
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.TargetFileLocation) && !fileConnectorConfigurationTuple.Item2.TargetFileLocation.Contains("10."))
|
||||
{
|
||||
if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.TargetFileLocation))
|
||||
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.TargetFileLocation);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder))
|
||||
if (!string.IsNullOrEmpty(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder) && !fileConnectorConfigurationTuple.Item2.AlternateTargetFolder.Contains("10."))
|
||||
{
|
||||
if (!Directory.Exists(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder.Split('|')[0]))
|
||||
_ = Directory.CreateDirectory(fileConnectorConfigurationTuple.Item2.AlternateTargetFolder.Split('|')[0]);
|
||||
|
||||
@ -6,52 +6,62 @@
|
||||
|
||||
function getValue(tool, patternSize, recipe, pattern, json) {
|
||||
let result;
|
||||
if (tool == undefined || tool.length === 0 || patternSize == undefined || patternSize.length === 0 || recipe == undefined || recipe.length === 0 || pattern == undefined || pattern.length === 0 || json == undefined || json.length === 0)
|
||||
result = 'A) Invalid input!';
|
||||
if (recipe.toUpperCase().EndsWith('RLOW_STD'))
|
||||
result = '1';
|
||||
else if (recipe.toUpperCase().EndsWith('RMID_STD'))
|
||||
result = '1';
|
||||
else if (recipe.toUpperCase().EndsWith('RHI_STD'))
|
||||
result = '1';
|
||||
else if (recipe.toUpperCase().EndsWith('THINSPC'))
|
||||
result = '1';
|
||||
else {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(json);
|
||||
} catch (error) {
|
||||
parsed = null;
|
||||
}
|
||||
if (parsed == null)
|
||||
result = 'B) Invalid input!';
|
||||
else if (parsed.rds == undefined || parsed.rds.prodSpec == undefined || parsed.rds.prodSpec.recipesAndPatterns == undefined)
|
||||
result = 'C) No Spec!';
|
||||
if (tool == undefined || tool.length === 0 || patternSize == undefined || patternSize.length === 0 || recipe == undefined || recipe.length === 0 || pattern == undefined || pattern.length === 0 || json == undefined || json.length === 0)
|
||||
result = 'A) Invalid input!';
|
||||
else {
|
||||
let toolMatches = [];
|
||||
for (let index = 0; index < parsed.rds.prodSpec.recipesAndPatterns.length; index++) {
|
||||
if (parsed.rds.prodSpec.recipesAndPatterns[index].tool === tool) {
|
||||
toolMatches.push(parsed.rds.prodSpec.recipesAndPatterns[index]);
|
||||
}
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(json);
|
||||
} catch (error) {
|
||||
parsed = null;
|
||||
}
|
||||
if (toolMatches == null || toolMatches.length === 0)
|
||||
result = 'Tool [' + tool + '] not found in OI API results!';
|
||||
if (parsed == null)
|
||||
result = 'B) Invalid input!';
|
||||
else if (parsed.rds == undefined || parsed.rds.prodSpec == undefined || parsed.rds.prodSpec.recipesAndPatterns == undefined)
|
||||
result = 'C) No Spec!';
|
||||
else {
|
||||
let debug = '';
|
||||
let matches = 0;
|
||||
for (let index = 0; index < toolMatches.length; index++) {
|
||||
debug += 'patternSize: ' + toolMatches[index].patternSize +
|
||||
'; recipe: ' + toolMatches[index].recipe +
|
||||
'; pattern: ' + toolMatches[index].pattern + ';~';
|
||||
if (toolMatches[index].patternSize == patternSize &&
|
||||
toolMatches[index].recipe.localeCompare(recipe, ['en-US'], { sensitivity: 'base' }) === 0 &&
|
||||
toolMatches[index].pattern.localeCompare(pattern, ['en-US'], { sensitivity: 'base' }) === 0) {
|
||||
matches++;
|
||||
let toolMatches = [];
|
||||
for (let index = 0; index < parsed.rds.prodSpec.recipesAndPatterns.length; index++) {
|
||||
if (parsed.rds.prodSpec.recipesAndPatterns[index].tool === tool) {
|
||||
toolMatches.push(parsed.rds.prodSpec.recipesAndPatterns[index]);
|
||||
}
|
||||
}
|
||||
if (matches > 0)
|
||||
result = '1';
|
||||
else
|
||||
result = 'Value not matched~Run~patternSize: ' + patternSize + '; recipe: ' + recipe + '; pattern: ' + pattern + ';~API~' + debug;
|
||||
if (toolMatches == null || toolMatches.length === 0)
|
||||
result = 'Tool [' + tool + '] not found in OI API results!';
|
||||
else {
|
||||
let debug = '';
|
||||
let matches = 0;
|
||||
for (let index = 0; index < toolMatches.length; index++) {
|
||||
debug += 'patternSize: ' + toolMatches[index].patternSize +
|
||||
';~recipe: ' + toolMatches[index].recipe +
|
||||
';~pattern: ' + toolMatches[index].pattern + ';~';
|
||||
if (toolMatches[index].patternSize == patternSize &&
|
||||
toolMatches[index].recipe.toLowerCase() == recipe.toLowerCase() &&
|
||||
toolMatches[index].pattern.toLowerCase() == pattern.toLowerCase()) {
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
if (matches > 0)
|
||||
result = '1';
|
||||
else
|
||||
result = 'Value not matched~Run~patternSize: ' + patternSize + ';~recipe: ' + recipe + ';~pattern: ' + pattern + ';~API~' + debug;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
getValue('4PP', 9, 'LSL_6IN', 'IRC6mm', '{"rds":{"prodSpec":{"recipesAndPatterns":[{"recipe":"LSL_6IN","pattern":"IRC6mm","patternSize":5,"tool":"4PP"}]}}}');
|
||||
getValue('4PP', 9, 'LSL_6IN', 'IRC6mm', '{"rds":{"prodSpec":{"recipesAndPatterns":[{"recipe":"LSL_6IN","pattern":"IRC6mm","patternSize":9,"tool":"4PP"}]}}}');
|
||||
|
||||
let json;
|
||||
let tool;
|
||||
@ -63,7 +73,7 @@ tool = '4PP'
|
||||
patternSize = 9;
|
||||
recipe = 'LSL_6IN';
|
||||
pattern = 'IRC6mm';
|
||||
json = '{"rds":{"prodSpec":{"recipesAndPatterns":[{"recipe":"LSL_6IN","pattern":"IRC6mm","patternSize":5,"tool":"4PP"}]}}}';
|
||||
json = '{"rds":{"prodSpec":{"recipesAndPatterns":[{"recipe":"LSL_6IN","pattern":"IRC6mm","patternSize":9,"tool":"4PP"}]}}}';
|
||||
const testA = getValue(tool, patternSize, recipe, pattern, json);
|
||||
if (testA !== '1')
|
||||
throw 'Test A failed: ' + testA;
|
||||
@ -115,3 +125,6 @@ json = '{"rds":{"prodSpec":{"recipesAndPatterns":[]}}}';
|
||||
const testN = getValue(tool, patternSize, recipe, pattern, json);
|
||||
if (testN !== 'Tool [4PP] not found in OI API results!')
|
||||
throw 'Test E failed: ' + testN;
|
||||
|
||||
if (testN !== 'Tool [HGCV] not found in OI API results!')
|
||||
throw 'Test E failed: ' + testN;
|
||||
Reference in New Issue
Block a user