Associating a schema with MongoDB

After you establish the connection between HCL® OneTest Data and MongoDB, you must associate a schema with a database of MongoDB. You must select the schema that you want to use to generate the test data.

Before you begin

You must have created a collection in the selected MongoDB database.

For more information, refer to db.createCollection() section of Database Methods.

About this task

You can associate any schema with the MongoDB database that can generate the test data in the JSON format.

The following schema formats support the output format in JSON:

  • Excel
  • JDBC
  • XSD
  • CSV

Procedure

  1. Select your project in Rational® Test Automation Server and go to the Data Fabrication page.
  2. Click the Connections tab and select the MongoDB connection name that you created.
  3. Click the menu and select New Action.
  4. Select Target as the Action Type in the New Action dialog box, and then click Next.
  5. Click Fetch to extract a list of all the collections of the selected database, and then select a collection from the Collection drop-down list.
    Note:

    You can retain the default property settings for all other boxes.

  6. Click Next to provide the schema details.
  7. Click the Schema drop-down list to select the schema that you want to use to generate the test data.
  8. Click the Schema Type drop-down list to select the group type for which you want to generate the test data, and then click Next.
  9. Provide the identification details of the new action, and then click OK.

    The new action is created and listed under the MongoDB connection.

Results

You have successfully associated the schema with the database.

Tip: If you want to associate any other schema in the same database, then you must click New Action on the existing MongoDB connection. You need not create a new connection.

What to do next

You can generate the test data from the schema that you associated with the database of MongoDB. The generated test data is directly inserted into the database. See Inserting the generated test data in a database.