Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space FUNCTDEV and version SVC2022.1

...

The Data Repository CRUD tool is intended to help you automate actions that require data in the repository to be modified, such as changing the value of account balances in a banking application. It can perform the following operations on records in your data repository:

  • create new data set records
  • read existing delete  data set records
  • update existing data set records
  • create new delete data set records

The primary use-case is to add the tool as an output to your Message Responder and configure operations to perform on the data when a message is sent to the virtual asset. You can manually configure the tool operation settings or script changes to record values before updating the data repository.

...

  1. Right-click on your responder and choose Add Output...

  2. Select an incoming request type in the wizard and choose Data Repository CRUD Tool. 
  3. Click Finish and specify a name for the tool (optional).
  4. Click Add in the Configuration tab and specify name for the operation (optional).
  5. Enable the Create, Read, Update, or Delete option.
  6. Choose the data repository data source you want to perform the operation on from the Data Source drop-down menu.
  7. Click Add in the Correlation section and specify the correlation columns and values of the data set records that you want to manipulate. See Data Source Correlation Tab for details on how to configure data source correlation criteria.  

  8. Configure the specific settings for Create, Read, Update, or Delete operations and save your changes.
  9. You can add additional configurations so that you can perform multiple operations on multiple fields in the same execution.
  10. Deploy your responder and execute your client to perform the operations you configured on the connected repository.

...

Specify your method for creating new records in the Create settings section. 

Image RemovedImage Added

Complex Values

...

Enable the Replace existing correlation match option to update an existing record if a matched correlation is found.

Read Configuration

You can configure a Read action in order to copy or extract request or response data and pass it to other actions. This enables you to modify records in the data repository based on the test scenario. 

  1. Click Add in the Read section and choose the element selector type.
    1. Choose Record to specify the XPath of the record value you want to read.
      Image Added
    2. Choose Key to specify the key column containing the key value you want to read. In the following example, the repository contains a key column called "catsKeyCol." 
      Image Added

      The repository contains two rows of selectable records.
      Image Added
      In this example, a wildcard is set in the data source correlation section, which indicates that the CRUD tool should read from all records. At runtime, the CRUD tool should return values 1 and 2.
      Image Added
  2. Specify a custom column name in which to store the value.
  3. If you are using the tool with a SOAtest client, you can also choose a column from a writable data source column.
  4. If your suite contains variables, you can specify a column name matching a variable value
  5.  Click OK and enable any additional operation settings you want to apply:
    • Enable the Fail if no correlation match option to prevent the tool from reading the repository if errors are reported. This option is enabled by default.
    • Enable the Return the first correlation match only to stop reading after the first match. This option is enabled by default.
    • Enable the Extract empty elements as: option and specify a value or parameterized value to use if the elements are empty.
    • Enable the Extract missing elements as: option and specify a value or parameterized value to use if the elements are missing.

Update Configuration

Specify the location of the record you want to update using an XPath-like selector for accessing records in the data repository.

...

You can enable or disable the Fail if no correlation match option. 

CRUD Example Workflow

In this example, we will attach a CRUD tool to a JSON message responder and manipulate a connected data repository. In this example, we'll create a new repository based on a sample response, so you will need access to a functional API endpoint if you want to perform the following procedure.

Setting Up the Project

In this phase, we will set up the project, add the responder, and associate a data repository. You can skip this step if you have an existing responder or SOAtest client connected to a data repository.

  1. Right-click on a project folder and add a new .pva file.
    Image Added
  2. Specify a name and click Next.
    Image Added
  3. We'll create an empty project in this example. Choose Empty and click Finish.
  4. Right-click the empty responder suite node and choose Add New > Responder.
  5. Choose JSON Message Responder or another responder type if you are adapting this example to your project and click Finish.
  6. In this tutorial, we will create a new repository from example responder traffic. Click the Response tab and switch the Form input mode to Literal.
    Image Added
  7. Paste your sample response in the field and switch the Input mode to the Form input mode suitable for your traffic. In this example, we will switch to Form JSON mode.
    Image Added
  8. Right-click the root node of the data tree and choose Generate Data Repository Data Source to begin creating the repository.
    Image Added
  9. Configure your data repository connection settings and click OK to create the repository.
    Image Added
  10. The new repository in this example does not have a key column, which is necessary to for identifying records. Click on the new data set in the Data Repository view. You may need to open or refresh the view (see Exploring the UI).
    Image Added
  11. Right-click inside the data repository editor and choose Add Key Column.
    Image Added
  12. Specify a name and click OK and save all your changes.

You should have a responder connected to a new repository with at least one key column.

Image Added

Adding and Configuring the CRUD Tool

In this step, we will add and configure the CRUD tool to perform several operations.

  1. Right-click on the responder and choose Add Output.
  2. For this example, we want the CRUD tool execute when a request is sent to the responder. Choose Payload from the Incoming Request menu.
  3.  Choose Data Repository CRUD Tool and click Finish.
  4. In the CRUD tool interface, click Add and rename the operation to "read".
  5. Choose the Read operation and verify that the data source you created is selected. 
  6. Click Add in the Correlation table and specify the name of the key column. 
  7. The repository in this example only has one row, but we will use a wildcard to correlate all rows.
    Image Added
  8. Click OK and click Add in the Read table. 
  9. In this example, we will select the record to ready by specifying the XPath. Choose Record from the Selected Element menu and click XPath.
  10. Choose which element to read when prompted. In this example, we'll choose the root element to read the entire record.
    Image Added
  11. Click OK to close the XPath selector and click OK to finish adding configuring the element selection.
  12. Leave the default settings for all other Read options and click Add in the tool configuration section to add another operation.
  13. Rename this operation to "create" and choose the Create option.
  14. Click Add in the Correlation table specify the key column and enter 2 as the value to create another row.
  15. Click OK and choose Parameterized from the Value field in the Create section and specify the root element. If the root element is not available from the drop-down menu, you may need to save your changes, close the CRUD tool editor, and reopen it. 
    Image Added
  16. The CRUD tool is now configured to read all stored records correlated with key column and create another record (row 2) containing all values under the root element. Save your changes and execute the .pva by calling its endpoint. 

A copy of the record will be created in the repository.

Image Added

Extending the Repository

You can add more operations to the CRUD tool to modify or delete existing records.

  1. Open the CRUD tool and click Add to create another operation.
  2.  Rename the operation to "update" and choose the Update option.
  3. Click Add in the Correlation table and enter catsKeyCol for the Key column field.
  4. Specify the a fixed value of 2 and click OK. This directs the operation to be performed on the record we created in the previous step.
  5. Click Add in the Update table and choose the Replace Element(s) mode.
  6. Click Location and choose an element for which to update a value
  7. Choose Simple from the Value menu and specify the new value for the field. In this example, the first item element under the root will be updated. To update all items at the same level, you could replace the 1 in the path with a * wildcard.
    Image Added
  8. Click OK and save your changes.
  9. Call the .pva and the record will be updated in the repository.

Image Added