public void testInputTables() { HashSet <String> errors = new HashSet <String>(); foreach (String schemaId in _STAGING.getSchemaIds()) { StagingSchema schema = _STAGING.getSchema(schemaId); // build a list of input tables that should be excluded foreach (StagingSchemaInput input in schema.getInputs()) { if (input.getTable() != null) { HashSet <String> inputKeys = new HashSet <String>(); StagingTable table = _STAGING.getTable(input.getTable()); foreach (StagingColumnDefinition def in table.getColumnDefinitions()) { if (ColumnType.INPUT == def.getType()) { inputKeys.Add(def.getKey()); } } // make sure the input key matches the an input column if (!inputKeys.Contains(input.getKey())) { errors.Add("Input key " + schemaId + ":" + input.getKey() + " does not match validation table " + table.getId() + ": " + inputKeys.ToString()); } } } } assertNoErrors(errors, "input values and their assocated validation tables"); }
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"); } } }
// Initialize a schema. // @param schema schema entity // @return initialized schema entity public static StagingSchema initSchema(StagingSchema schema) { // parse the schema selection ranges if (schema.getSchemaSelectionTable() == null) { throw new System.InvalidOperationException("Schemas must have a schema selection table."); } // store the inputs in a Map that can searched more efficiently if (schema.getInputs() != null) { Dictionary <String, IInput> parsedInputMap = new Dictionary <String, IInput>(); foreach (StagingSchemaInput input in schema.getInputs()) { // verify that all inputs contain a key if (input.getKey() == null) { throw new System.InvalidOperationException("All input definitions must have a 'key' defined."); } parsedInputMap[input.getKey()] = input; } schema.setInputMap(parsedInputMap); } // store the outputs in a Map that can searched more efficiently if (schema.getOutputs() != null) { Dictionary <String, IOutput> parsedOutputMap = new Dictionary <String, IOutput>(); foreach (StagingSchemaOutput output in schema.getOutputs()) { // verify that all inputs contain a key if (output.getKey() == null) { throw new System.InvalidOperationException("All output definitions must have a 'key' defined."); } parsedOutputMap[output.getKey()] = output; } schema.setOutputMap(parsedOutputMap); } // make sure that the mapping initial context does not set a value for an input field if (schema.getMappings() != null) { foreach (StagingMapping mapping in schema.getMappings()) { if (mapping.getInitialContext() != null) { foreach (StagingKeyValue kv in mapping.getInitialContext()) { if (schema.getInputMap().ContainsKey(kv.getKey())) { throw new System.InvalidOperationException("The key '" + kv.getKey() + "' is defined in an initial context, but that is not allowed since it is also defined as an input."); } } } } } return(schema); }