Creating data model-driven stubs
Data models provide an alternative way to store data for a stub. This method creates stubs from recorded events, and such stubs can reuse the data across multiple operations.
Basic (hardcoded) and parameterized (data-driven) stubs are examples of simple stub-types because the data that is provided when the stub is run is either hardcoded in the stub itself or is taken from a simple data source. In each case, the same data is used each time when the stub is started.
However, the testing of complex systems might require persistent storage of data so that a stub can save information across multiple operations. By doing so, you can virtualize services that create data, for example, a customer, and then use that data in a GetCustomer service without having to know a design time the data will be used. It is this capability that distinguishes simple stubs from those that are coordinated to provide a virtualized application.
In cases where you require multiple operations within a stub, or multiple stubs to share data to provide a virtualized application, consider using a data model to hold such data. Data models can be shared across stubs. In addition, data models can hold data about multiple entities and their relationships, such as customers and orders.
Therefore, a data model is a simple view of entities and their relationships that can be used by stubs to persist information. Data models exist as assets within a project. A stubs properties define which data model it is using. Stubs can read and modify data held in a data model. You can use the Stub Editor to specify whether an operation is trying to create, update, or delete data based on the received message, and thus reduce the time and effort you need to create rich stubs.
In IBM® DevOps Test Integrations and APIs (Test Integrations and APIs), you can create a data model by using the Ecore Editor . Alternatively, you can create a data model while creating a data model-driven stub from recorded events. This second method analyzes the message in recorded events and creates a data model and entities within that data model based on the messages. Operations that are created will be connected to the data model automatically.
To create a data model-driven stub from recorded events:
After you click Finish on the Summary screen, the following actions happen:
- The Test Integrations and APIs Test Factory perspective is displayed, and the newly created stub is displayed under the relevant logical resource on the component tree. If you created a stub for multiple operations, the stub is displayed under each applicable operation.
- If you selected the Open resource after finish check box on the Summary screen, the stub is also opened in the Stub Editor. You can edit any of the details; see Modifying message-based stubs.
- If you open the Data Models window in the Architecture School perspective, the newly created data model is listed on the upper left of the window. To display the data models details in the window, select the model.

