Creates and activates a copy of the original model in the HANA repository with the dependencies to other views/tables being replaced. At least one dependency
substitution must be applied.
Supported HANA model types:
- Graphic Calculation/Analytic/Attribute Views
- Scripted Views
- Stored Procedures
Supported dependency types that can be replaced with test tables:
- Graphic Calculation/Analytic/Attribute Views
- Scripted Views
- Tables
In HANA, "_SYS_REPO" needs select permission (with grant option) to the test schema in order to activate the generated test model with its
underlying catalog objects. Therefore make sure that "_SYS_REPO" has select permission to the schema of the test tables. Its recommended to take the user
schema as test schema. That allows the parallel execution of the same test by different users. Either you can execute the following SQL statements once per
system while you create the test schema:
create schema MY_TEST_SCHEMA;
grant select on schema MY_TEST_SCHEMA to _SYS_REPO with grant option;
... or you can do it even programmatically within your test.
var testSchema = $.session.getUsername().toUpperCase();
function grantSelectUserSchemaToSysRepo() {
var connection = $.db.getConnection();
var sqlExecutor = new sap.hana.testtools.unit.util.sqlExecutor.SqlExecutor(connection);
sqlExecutor.execSingle('grant select on schema ' + testSchema + ' to _SYS_REPO with grant option');
connection.close();
}
var testPackage = 'tmp.' + $.session.getUsername().toLowerCase();
var mockstar = $.import("sap.hana.testtools.mockstar", "apiFacade");
var dependencySubstitutions = [ {
original : {
schema : 'SCHEMA',
name : 'ORDERS'
},
substitute : {
schema : 'D123456',
name : 'ORDERS'
}
}, {
original : 'package.subpackage/OTHER_VIEW',
substitute : '"D123456"."OTHER_VIEW"'
} ];
var testModel = mockstar.createTestModel('package/MY_VIEW', testPackage, dependencySubstitutions, mockstar.TruncOptions.FULL);