new MockstarEnvironment()
Creates a mockstarEnvironment object with model description and initial definition. Instances of MockstarEnvironment are created by
define.
Members
-
onDataInserted
-
This event is triggered every time data is inserted into a test table, which is known to mockstarEnvironment.
Methods
-
addProcedureSubstitution(id, substitution)
-
Describe a table dependency that should be substituted in the copied test model hierarchy.
Parameters:
Name Type Description id
String identifier of the procedure to be substituted substitution
Object the original procedure with the following properties: Properties
Name Type Argument Default Description schema
String <optional>
mockstarEnvironment.schema schema of the procedure to be substituted name
String name of the procedure to be substituted without schema e.g. "package.subpackage::procedure" testProcedure
String the full test procedure name including the schema that should be used as procedure substitution e.g. '"TESTSCHEMA"."package.subpackage::procedure"' Throws:
-
an error when parameter 'id' is not unique
-
an error when a substitution exists already
-
an error when 'create' function was already called
-
-
addTableSubstitution(id, substitution)
-
Describe a table dependency that should be substituted in the copied test model hierarchy. If no 'testTable' property was specified, a copy of the origin table will be created in the user's schema using tableUtils.copyIntoUserSchema.
Parameters:
Name Type Description id
String identifier of the table to be substituted substitution
String | Object the name of the original table without schema e.g. "package.subpackage::context.entity" | the original table with the following properties: Properties
Name Type Argument Description schema
String <optional>
schema of the table to be substituted name
String name of the table to be substituted without schema data
String <optional>
data to be inserted into the test table tableUtils.insertData csvFile
String <optional>
name of the .csv file to be uploaded into the test table. In that case you need to specify definition.csvPackage testTable
String <optional>
the full test table name including the schema that should be used as table substitution e.g. '"TESTSCHEMA"."MY_TEST_TABLE"' - See:
Throws:
-
addViewSubstitution(id, substitution)
-
Describe a view dependency that should be substituted in the copied test model hierarchy. If no 'testTable' property was specified, it will try to create a test table on the base of the origin view in the user's schema using tableUtils.createTestTableFromView.
Parameters:
Name Type Description id
String identifier of the view to be substituted substitution
String | Object the name of the original view without schema e.g."package.subpackage/ca_view" | the original view with the following properties: Properties
Name Type Argument Default Description schema
String <optional>
mockstarEnvironment.schema|'_SYS_BIC' schema of the view to be substituted name
String name of the view to be substituted without schema data
String <optional>
data to be inserted into the test table tableUtils.insertData csvFile
String <optional>
name of the .csv file to be uploaded into the test table. In that case you need to specify definition.csvPackage testTable
String <optional>
the full test table name including the schema that should be used as table substitution e.g. '"TESTSCHEMA"."MY_TEST_TABLE"' - See:
Throws:
-
clearAllTestTables()
-
Clears the test tables for all given dependency substitutions. Note that all test tables need to be located in the userSchema.
Throws:
-
an error when create function was not yet called
-
an error when an error happens in the underlying tableUtils.clearTableInUserSchema function
-
-
clearTestTables(ids)
-
Clears the test tables for some given dependency substitutions. Note that the test tables need to be located in the userSchema.
Parameters:
Name Type Description ids
Array list of identifiers of the table to be substituted Throws:
-
an error when create function was not yet called
-
an error when no dependency substitution is specified for one of the given 'ids'
-
an error when an error happens in the underlying tableUtils.clearTableInUserSchema function
-
-
commitData()
-
Commits the current database connection (jasmine.dbConnection), which will store all data modifications, which were done to the database tables. This might be relevant, if you insert data into the test tables within the beforeOnce function, which should be available within the test specification (i.e. test case). The managed database connection (jasmine.dbConnection) is ... ... opened before the execution of each beforeOnce and each afterOnce and closed after the execution. ... opened before the first of each test specification (i.e. test case), stays open while the test spec and its corresponding beforeEach and afterEach functions are executed and it's closed after the last afterEach.
- See:
-
create() → {MockstarEnvironment}
-
This function
- creates a test table into the user schema as copy of each table dependency to be substituted - unless an existing testTable was defined (tableUtils.copyIntoUserSchema)
- creates a test table into the user schema for each view dependency to be substituted - unless an existing testTable was defined (tableUtils.createTestTableFromView
- creates a copy of the original model into the target package where all specified dependencies were replaced by the test tables (mockstar.createTestModel)
- inserts the specified data into the created test tables (tableUtils.insertData)
- uploads data from the specified csvFile into the created test tables (tableUtils.fillFromCsvFile).
Throws:
-
an error when for any table/view name the schema is missing
-
an error when create function was already called
-
an error when an error occurs in one of the underlying utility functions
Returns:
- Type
- MockstarEnvironment
-
fillTestTable(id, data)
-
Inserts the specified data into the created test tables.
Parameters:
Name Type Description id
String identifier of the view/table to be substituted data
Object specify column specific values Throws:
-
an error when create function was not yet called
-
an error when no dependency substitution is specified for the given 'id'
-
an error when an error happens in the underlying tableUtils.insertData function
Example
var singleEntry = { Id : "1", col2 : "A", COL3 : 10.1 }; var multEntries = { Id : [ "1", "2" ], col2 : [ "A", "B" ], COL3 : [ 10.1, 20.2 ] }; testEnvironment.fillTestTable("tableId", singleEntry); testEnvironment.fillTestTable("tableId", multEntries);
-
-
fillTestTableFromCsv(id, csvFile)
-
Uploads data from the specified csvFile into the created test tables.
Parameters:
Name Type Description id
String identifier of the view/table to be substituted csvFile
String name of the .csv file Throws:
-
an error when create function was not yet called
-
an error when no dependency substitution is specified for the given 'id'
-
an error when an error happens in the underlying tableUtils.fillFromCsvFile function
-
-
getModelName() → {String}
-
Returns the name of the model to be tested.
Returns:
the name of the model to be tested e.g. "_SYS_BIC"."package.subpackage/ca_view"- Type
- String
-
getProcedureName(id) → {String}
-
Returns the name of the procedure dependency you have defined within addProcedureSubstitution.
Parameters:
Name Type Description id
String identifier of the procedure to be substituted Throws:
an error if no procedure substitution is defined for the given 'id'Returns:
fully qualified procedure name e.g. "SCHEMA"."package::any_procedure"- Type
- String
-
getTableName(id) → {String}
-
Returns the name of the table dependency you have defined within define or addTableSubstitution.
Parameters:
Name Type Description id
String identifier of the table to be substituted Throws:
an error when no table substitution is defined for the given 'id'Returns:
fully qualified table name e.g. "USERSCHEMA"."MY_TEST_TABLE"- Type
- String
-
getTestModelName(suffix) → {String}
-
Returns the full name of the test model that was created into the target package.
Parameters:
Name Type Argument Description suffix
String <optional>
suffix to be appended to the name Returns:
fully qualified name of the created test model (including schema)- Type
- String
-
getTestProcedureName(id) → {String}
-
Returns the full name of the test procedure for a given dependency substitution.
Parameters:
Name Type Description id
String identifier of the procedure to be substituted Throws:
-
an error when create function was not yet called
-
an error when no dependency substitution is specified for the given 'id'
Returns:
fully qualified name of the test procedure e.g. '"TESTSCHEMA"."package::procedure"'- Type
- String
-
-
getTestTableName(id) → {String}
-
Returns the full name of the test table for a given dependency substitution.
Parameters:
Name Type Description id
String identifier of the table/view to be substituted Throws:
-
an error when create function was not yet called
-
an error when no dependency substitution is specified for the given 'id'
Returns:
fully qualified name of the test table e.g. '"USERSCHEMA"."T2"'- Type
- String
-
-
getTestTableNames() → {Array}
-
Returns the names of all test tables.
Throws:
an error when create function was not yet calledReturns:
list of test tables e.g. ['"USERSCHEMA"."T1"', '"USERSCHEMA"."T2"']- Type
- Array
-
getViewName(id) → {String}
-
Returns the name of the view dependency you have defined within define or addViewSubstitution.
Parameters:
Name Type Description id
String identifier of the view to be substituted Throws:
an error if no view substitution is defined for the given 'id'Returns:
fully qualified view name e.g. "_SYS_BIC"."package/any_view"- Type
- String