Manipulate objects

TDM objects in an existing TDM repository are manipulated by using specific Modules which can be downloaded from the Tosca Exchange Portal.

A data record for the defined attributes is referred to as TDM object. This is for instance a person (object type) with a first name (attribute), last name (attribute), etc.

TDM objects in the TestStep are named by using variable names (ObjectName) whenever TDM objects are created or edited. These variables are used to access the TDM objects during test execution and must be unique.

When TestSteps are specified, there is no need to specify an ActionMode because these values are automatically selected.

Test data management example

Module - TDM Create Object

This Module serves to create a new TDM object for a certain object type. The new TDM object is created without any values.

The values of a TDM object are defined using the Module TDMSetAttribute.

TDM objects are saved using the Module TDM Save.

ModuleAttributes

TypeName

Name of the object type for which a new TDM object should be created.

A TDM object with values and associations can also be created by using XML Notation or JavaScript Object Notation (JSON).

ObjectName

This defines the variable name for a new TDM object.

In this example, a new TDM object with the variable name MyCustomer is created for the object type Customer.

Example of TDM object creation

An example of a JSON notation can be found here.

Module - TDM Set Attribute

This Module serves to specify values for existing TDM objects.

The TDM object for which values should be defined must be created in the same TestCase using the Modules TDM Create Object and TDM Find Single Object.

The object values are saved using the Module TDM Save.

ModuleAttributes

ObjectName

Variable name of the TDM object for which values should be defined.

AttributeName

Name of the attribute for which a value should be defined.

AttributeValue

Value to be defined for the specified TDM object attribute.

In this example, the TDM object with the variable name MyCustomer is created for the object type Customer. AA is defined as the value for the attribute CustomerData_Rating

Editing the TDM object

Module - TDM Find Single Object

This Module serves to search for a TDM object in the TDM repository.

The access to all the TDM objects from the test data repository which have been used is denied for other users that have access to the test data repository. This guarantees that data quality is retained.

ModuleAttributes

ObjectName

Variable name to be assigned to the found TDM object. This name can be used to access the TDM object later on.

BaseObjectName

Variable name of the base object from which the search should be started (optional). A TDM object, which is linked to an association, is referred to as base object.

Query

A string is specified for the query. The string is created analogous to the TQL query.

If a base object has been specified, the query is triggered by a leading arrow operator: -> or =>. The arrow is not required if there is no base object since no starting point has not been specified for the search.
Exception: the search for a partner object (association) without specifying a base object requires the leading prefix ->All:.

If an object which has at least one partner object of the specified object type is searched for, the query requires the leading prefix ->Return All:.

The search starts from the object type.

If the query is not unique (for instance because a search criterion applies to several TDM objects), any matching TDM object is returned.

Creating a TQL search query using drag & drop

As an alternative to manual entries, a TQL search query can also be created by using drag and drop. The objects Tosca TestCase-Design Sheet, Class or Instance can be dragged onto the TestStep TDM Find Single Object.

All attributes that fulfill the following requirements are included:

If no variable name has been defined in the TestStepValue ObjectName, a default name is created from the syntax My<Objectname>. It may be necessary to change this variable name manually.

In the example below, a search query is created from the instance PrivateCustomer. The Customer, which contains the attributes CheckingAccount_Type and CheckingAccount_Status with the values Checking and New is searched for. The value MyCustomer is specified as the value for the ObjectName.

Creating a TQL query via drag & drop

Sample TestCases

The following examples show TQL queries for searching for a TDM object in the repository. Please also see the Test data management: an example article for further information.

  • Example 1 Use case: a specific customer is required.

    A customer with the value AA for the attribute CustomerData_Rating is searched for.

  • Example 2 Use case: a specific customer is required.

    A customer with the value AA for the attribute CustomerData_Rating and the value PrivateCustomer for the attribute CustomerData_Type is searched for.

  • Example 3 Use case: a checking account which belongs to a certain customer is required.

    In the first TestStep a customer with the value AA for the attribute CustomerData_Rating is searched for. In the next TestStep, an associated checking account with a Status attribute with the value New is searched for, starting from the search result.

  • Example 4 Use case: a checking account which belongs to a certain customer is required.

    An associated CheckingAccount with a Status attribute with the value New is searched for by using all customers.

  • Example 5 Use case: a random customer with a specific CheckingAccount is searched for.

    A random customer with an associated CheckingAccount with the status New is searched for.

  • Example 6 Use case: a random checking account is required which belongs to a specific customer.

    An associated checking account with a CustomerData_Rating attribute with the value AA is searched for, starting from the customer.

Module - TDM Find Single Object

Module - TDM Set State

This Module serves to create values and associations for an existing TDM object.

A new TDM object is first created via the Module TDM Create Object, or the Module TDM Find Single Object is used to search for the required TDM object.

The values must be saved via the Module TDM Save.

ModuleAttributes

ObjectName

Name of the TDM object for which new values or associations should be defined.

NewState

Definition of values and associations. This is done via XML Notation or JavaScript Object Notation (JSON).

TDM attributes for which no values have been specified are deleted.

Sample TestCase

In the first TestStep, a TDM object with the variable name MyCustomer is generated for the object type Customer.

In the next TestStep, the value Rating AA is set for the attribute CustomerData_Rating, the value PrivateCustomer is set for the attribute CustomerData_Type and the value 11111111 for the attribute CustomerData_CustomerNumber.

Example with JSON notation

Module - TDM Add Association

This Module serves to define an association between two TDM objects which then receives an individual role name. This role name allows associations to be mapped.

These values must be saved via the Module TDM Save.

The association must first be defined during the TDM schema creation.

For more information on TDM schema creation, see chapter "Create a TDM database schema from a TestCase-Design TestSheet or Class".

ModuleAttibutes

ObjectName

Variable name of the TDM object to be linked with the TDM partner object (association).

RoleName

Role name to be assigned to the association.

PartnerObjectName

Variable name of the TDM partner object (association) which is to be assigned accordingly.

Sample TestCase

In this example, the TDM object with the variable name MyCustomer is linked to the TDM object with the variable name MyAccount. The role name CheckingAccount is entered for the link.

Module - TDM Add Association

Module - TDM Remove Association

This Module serves to remove associations between TDM objects.

Prior to using the Module TDM Remove Association, the TDM objects with associations to be removed must be found with the Module TDM Find Single Object.

Changes must be saved using the Module TDM Save.

ModuleAttributes

ObjectName

Variable name of the TDM object which contains a link to be removed.

RoleName

Role name of the link to be removed.

PartnerObjectName

Variable name of the TDM partner object (association) with the link to be removed. This value is optional. If no value has been specified, links to all existing partner objects are removed.

  • In the first TestStep, a customer with an attribute CustomerData_Rating with the value AA is searched for.

  • In the next TestStep, an account with the attribute Type with the value Checking is searched for.

  • The next TestStep removes the association between TDM objects by entering the role name.

Removing associations of TDM objects

Module - TDM Delete Object

This Module serves to delete TDM objects from the TDM repository.

Changes are saved with the Module TDM Save.

ModuleAttribute

ObjectName

Variable name of the TDM object to be deleted.

  • In the first TestStep, a customer with an attribute CustomerData_Rating with the value AA is searched for.

  • In the next TestStep the customer with the variable name MyCustomer is deleted from the TDM repository.

TDM Delete Object

Module - TDM Save

This Module serves to save TDM objects to the TDM repository.

ModuleAttribute

KeepLocks

If the value of this ModuleAttribute is True, the TDM objects used in the TestCase remain locked in the TDM repository for all other users. Any locked objects will be released once the TestCase has been executed.

If the value is either False or blank, the objects used in the TestCase are released.

Sample TestCase

JSON and XML expressions

The following JSON and XML expressions can be used to create TDM objects with the Modules TDM Create Object and TDM Set State:

Creating a TDM object

The expression _type serves to create a new TDM object for a specific object type.

JSON:

Syntax:

"_type":"<Objectname>"

XML:

Syntax:

_type="<Objectname>"

Example

In this example, a new TDM object with attribute values is created for the object type Customer.

JSON: {

"_type":"Customer",

"CustomerData_Rating":"AA",

"CustomerData_Type":"PrivateCustomer",

"CustomerData_CustomerNumber":"11111111"

}

<?xml version="1.0" encoding="utf-8"?>

<Object _type="Customer" CustomerData_Rating="AA" CustomerData_Type="PrivateCustomer" CustomerData_CustomerNumber="11111111">

</Object>

Example: JSON notation using the expression _type

Using existing TDM objects

The expression _ can be used to edit an existing TDM object.

The TDM object must either be newly created beforehand or searched for in the same TestCase. The ObjectName (variable name) must be equal.

XML:

Syntax:

_="<Objectname>"

JSON:

Syntax:

"_":"<Objectname>"

Example

In this example, a new customer is created and linked with the existing account MyAccount.

JSON: {

"_type":"Customer",

"CustomerData_Type":"PrivateCustomer",

"CustomerData_Rating":"AAA",

"CheckingAccount":

{

"_":"MyAccount"

}

}

<?xml version="1.0" encoding="utf-8"?>

<Object _type="Customer" CustomerData_Type="PrivateCustomer" CustomerData_Rating="AAA">

<CheckingAccount _="MyAccount"> </Object>

Example: JSON notation using the expression _

Creating a JSON notation by using drag & drop

As an alternative to manual entries, JSON notations can also be created by using drag and drop. The objects Tosca TestCase-Design Sheet, Class, or Instance can be dragged onto a TestStep, a TestCase or a TestCase template.

All attributes that fulfill the following requirements are included:

  • The attributes must have values.

  • The attributes must be relevant to test data management - the TDM property must have the value True (see chapter "Test Data Management in TestCase-Design").

  • JSON notations from Tosca TestCase-Design Sheets or Classes can only be created for TestCase templates that are linked to data sources.

If no ObjectName has been specified for the TestStep, a default name is created from the syntax My<Objectname>. It may be necessary to change this ObjectName manually.

In this example, the instance PrivateCustomer is dragged onto the TestStep TDM Create Object. The attributes CustomerData_Rating and CustomerData_Type are entered along with the corresponding values into the TestStepValue TypeName as JSON notations. The value MyCustomer is indicated as the ObjectName.

Generating JSON notations by using drag & drop