See mockstarEnvironment.define function or
mockstarEnvironment.defineAndCreate to create a dedicated MockstarEnvironment Object.
- Since:
- 1.9.2
Classes
Methods
-
<inner> define(definition, connection) → {module:mockstarEnvironment~MockstarEnvironment}
-
Creates a MockstarEnvironment object with an initial definition. MockstarEnvironment offers functions that helps you to test a model (e.g. view or procedure) in an isolated way. It offers functions to:
- define the test model
- define the dependent tables/views that should be replaced in the test model by test tables
- fill those test tables with data/from csv file.
Parameters:
Name Type Argument Description definitionObject Properties
Name Type Argument Default Description schemaString <optional>
the schema, that should be used, when no schema is explicitly specified modelString | Object the name of the original model without schema or the original model with the properties as described below Properties
Name Type Argument Default Description schemaString <optional>
automatically determined, definition.schema on failure the schema of the original model nameString <optional>
the name of the original model (without schema), e.g. "package.subpackage/ca_view" targetPackageString <optional>
"tmp.unittest.<username>" the package name where the test model should be created into mockstarPropertiesObject <optional>
defines the options for mockstar.createTestModel Properties
Name Type Argument Default Description truncOptionString <optional>
TruncOptions.NONE per default the target package gets prefixed with the package of the original model useHdbConnectionString <optional>
false if true, jasmine.hdbConnection is used instead of jasmine.dbConnection. The flag is ignored when the connection parameter is filled. The flag is also ignored if the $.hdb API is not available csvPackageString <optional>
the package name of the .csv files csvPropertiesObject <optional>
defines the options for tableUtils.fillFromCsvFile Properties
Name Type Argument Default Description separatorString <optional>
";" overwrites the value separator headersBoolean <optional>
true indicates whether the data contains a header line decSeparatorString <optional>
"." overwrites the decimal separator substituteTablesObject <optional>
list of table dependencies that should be substituted within the copied test model hierarchy Properties
Name Type Description <id>String | Object the name of the original table without schema "tableId": "package.subpackage::context.entity"
or a substitution rule with the properties as described below"tableId": {...}Properties
Name Type Argument Default Description schemaString <optional>
definition.schema schema of the table to be substituted nameString name of the table to be substituted (without schema) dataString <optional>
data to be inserted into the test table tableUtils.insertData csvFileString <optional>
name of the .csv file to be uploaded into the test table. In that case you need to specify definition.csvPackage testTableString <optional>
the full test table name including the schema that should be used as table substitution e.g. '"TESTSCHEMA"."MY_TEST_TABLE"' substituteViewsObject <optional>
list of view dependencies that should be substituted within the copied test model hierarchy Properties
Name Type Description <id>String | Object the name of the original view without schema "viewId": "package.subpackage/ca_view"
or a substitution rule with the properties as described below"viewId": {...}Properties
Name Type Argument Default Description schemaString <optional>
definition.schema|"_SYS_BIC" schema of the view to be substituted nameString name of the view to be substituted (without schema) dataString <optional>
data to be inserted into the test table tableUtils.insertData csvFileString <optional>
name of the .csv file to be uploaded into the test table. In that case you need to specify definition.csvPackage testTableString <optional>
the full test table name including the schema that should be used as table substitution e.g. '"TESTSCHEMA"."MY_TEST_TABLE"' substituteProceduresObject <optional>
list of procedure dependencies that should be substituted within the copied test model hierarchy Properties
Name Type Description <id>Object a substitution rule with the properties as described below "viewId": {...}Properties
Name Type Argument Description schemaString <optional>
schema of the procedure to be substituted nameString name of the procedure to be substituted (without schema) testProcedureString the full test procedure name including the schema that should be used as substitution e.g. '"TESTSCHEMA"."MY_PROCEDURE_STUB"' substituteFunctionsObject <optional>
list of table function dependencies that should be substituted within the copied test model hierarchy Properties
Name Type Description <id>String | Object the name of the original function without schema "functionId": "package.subpackage/table_function"
or a substitution rule with the properties as described below"viewId": {...}Properties
Name Type Argument Description schemaString <optional>
schema of the function to be substituted nameString name of the function to be substituted (without schema) dataString <optional>
data to be inserted into the test table tableUtils.insertData csvFileString <optional>
name of the .csv file to be uploaded into the test table. In that case you need to specify definition.csvPackage testTableString <optional>
the full test table name including the schema that should be used as function substitution e.g. '"TESTSCHEMA"."MY_TEST_TABLE"' connection$.db.Connection <optional>
Connection to database. If not specified, jasmine.hdbConnection or jasmine.dbConnection is used depending on whether definition.mockstarProperties.useHdbConnection is true or false, respectively. Do not pass jasmine.dbConnection or jasmine.hdbConnection explicitly, as this might cause errors! - Since:
- 1.10.10 (connection parameter)
1.10.12 (useHdbConnection flag)
- 1.10.10 (connection parameter)
- See:
Returns:
Mockstar environment object that contains several definition methods to create a test model and test tables in order to test a model in an isolated way.Example
var mockstarEnvironment = $.import("sap.hana.testtools.mockstar", "mockstarEnvironment"); var testData = { Id: "1", col2: "A", COL3: 10.1 }; var definition = { schema: "SCHEMA", model: { schema : "_SYS_BIC", name: "package.subpackage/calculationview", }, substituteTables: { "table_id": { name: "package.db::basis.t_table", csvFile: "table.csv" } }, substituteViews: { "view_id": { name: "package.db::basis.v_item", testTable: '"USER"."v_item_table"', data: testData } }, substituteProcedures: { "proc_id": { name: "package.db::basis.p_proc", testProcedure: '"USER"."p_proc_stub"' } } }; var testEnvironment = mockstarEnvironment.define(definition); -
<inner> defineAndCreate(definition, connection) → {module:mockstarEnvironment~MockstarEnvironment}
-
Creates a MockstarEnvironment Object with a given definition. After calling this function the test model as well as the defined test tables are created (mockstarEnvironment.create).
Equivalent todefine(definition).create()
Parameters:
Name Type Argument Description definitionObject like in mockstarEnvironment.define connection$.db.Connection <optional>
like in mockstarEnvironment.define - See:
Returns:
mockstarEnvironment that contains several definition methods to fill test tables in order to test a model in an isolated way.