Creating the test data mockup process

From PegaWiki
This is the approved revision of this page, as well as being the most recent.
Jump to navigation Jump to search

Creating the test data mockup process

Description Creating the process to populate mock-up data in a sample multi-level structure and covers a few methods for testing service and strategies using the generated mockup data.
Version as of 8.6
Application Pega Customer Decision Hub
Capability/Industry Area Testing and Simulation



Test data mock-up process[edit]

It is important to quickly generate sample data and test an application after setting up the implementation layer for Pega Customer Decision Hub™ to ensure that the configurations are made correctly. This article will show you how to populate mock-up data in a sample multi-level (customer and account) structure and cover a few methods for testing service and strategies using the generated mockup data.

Note: This is not a guide for creating a Monte Carlo data set but to represent a process for creating sample data.

Pre-requisites[edit]

  • An implementation layer for Customer Decision Hub is setup.
  • Customer and Account classes are setup.
  • An association between Customer and Account is created.
  • Context Dictionary setup is completed.
  • Next Best Action Designer has at least one action and treatment, and an active real-time container.
  • A framework is installed (optional but recommended).

Assumptions[edit]

  • For this article, Customer class is named UBank-Data-Customer and Account class is named UBank-Data-Account.
  • One customer may have multiple accounts..
  • Customer and Accounts classes are inheriting from the Customer and Account classes shipped in the Financial services accelerator component.
  • The following screenshots were taken for the Financial Services industry.
  • The channel invoking NextBestAction container is U+ Bank website, with a Tile as placement
  • Real Time Container is named NextBestAction and is active

Creating mock-up data[edit]

Creating mock-up data from scratch[edit]

As a best practice, Pega recommends that industry frameworks should be leveraged during the initial setup of an application. These accelerator components can jump start application development from day one as it includes various artifacts that can be reused. If possible, please skip this section and reuse the SampleCustomerDataRecord Monte Carlo data set provided with the accelerator. Otherwise, continue by creating everything from the beginning.

(For help creating Monte Carlo data sets, consider completing the Pega Academy challenge: Creating Monte Carlo Data sets)

  1. Create a new Monte Carlo data set in your implementation customer class (UBank-Data-Customer).
  2. Start by entering the sample size of the dataset (number of customers that will be generated as a result).
  3. Add all properties that will be populated in customer and account classes, by selecting them from various methods. (For more information about each function and usage, see Monte Carlo Data set on Pega Documentation). Consider adding Account pages into the Monte Carlo data set.
    • Some common methods are :
      • For generating consecutive IDs, use → ConsecutiveIds.nextRowID(Text,Text)
      • For personal information, use → Name.prefix, Name.firstName, Name.lastName, Address.streetAddress, Address.city, Address.country
      • Random decimal → Number.randomGaussian(Double,Double)
      • Random integer → Number.digits(Integer)
      • Random text → Options.options(Text,Text,Text,Text)
      • Random true or false → Bool.bool
      • Date-time difference → @DateTimeDifference(------A DATE PROPERTY------,@(Pega-RULES:DateTime).CurrentDateTime(),D)
  4. After completing all fields, click Actions > Run.
  5. Choose Browse operation to review the data.
  6. Skip next section and move to section on “Inserting the Data

Creating mock-up data by leveraging the accelerator[edit]

As a best practice, Pega recommends that industry frameworks should be leveraged during the initial setup of an application. These accelerator components can start application development from day one, as it includes various artifacts that can be reused.

Use the SampleCustomerDataRecord Monte Carlo data set to get started.

  1. Download the accelerator component for the industry from marketplace.
    Pega Marketplace page showing necessary components to be downloaded.
    Accelerator components for industry in Pega Marketplace
  2. In the application definition, install the accelerator component by clicking Manage Components.
    Manage components button used to install accelerators in the Edit application page.
    Installing accelerator components in the application definition
    (For more information about the installation, see Implementation Guide.)
  3. After installing the component successfully, search for the SampleCustomerDataRecord Monte Carlo data set and save it into your implementation customer class.
    SampleCustomerDataRecord page highlighting the data set type - Monte Carlo.
    Saving the SampleCustomerDataRecord data set into implementation customer class
  4. Tailor it appropriately with the sample size and property values.
  5. Click Actions > Run.
  6. Choose Browse operation to review the data.

Inserting the Data[edit]

Create a new data flow to insert the sample data into corresponding database tables.

To begin with, create a new data flow in the customer class and name it CreateCustomerAndAccounts.

Data flow window showing a sample data flow to insert the data into database tables.
Data flow for inserting sample data
  1. Choose the Monte Carlo data set that was created in the initial step.
  2. Choose the provided Customer data set to insert into customer class. When saving, select Insert new and overwrite existing records.
  3. Click Add branch to define the Account destination.
  4. In the data flow, add a Convert shape.
  5. In the convert shape, choose Embedded and select the .Accounts page list property.
  6. Choose the out-of-the-box Account data set to insert into account class. When saving, select Insert new and overwrite existing records.
  7. Click Actions > Run.
  8. Click Submit.
  9. Start the data flow run.
  10. Verify that the data is generated in the Customer and Account classes by running the Customer and Account data sets.

Manipulating the sample data[edit]

It is possible to make changes to the customer or account data directly from Pega Customer Decision Hub or by exporting the data to a CSV file and update or import the CSV back. This helps users to manipulate the data as necessary.

  • Make sure that your access group has the your implementation application name:DataAdmin role.
  • Launch Pega Customer Decision Hub, and go to Data > Profile Data Sources.
  • Select Customer data set.
  • Click on the Records tab.
  • Click on any record to customize.
  • Alternately click on the Export button to export the records, make necessary changes then Import it back using the wizard.

Testing the Container Service[edit]

The first test functionality that can be leveraged within Pega Customer Decision Hub can be done from the Container service itself.

  1. Select CustomerID from the customer table for testing. (Simply run the Customer data set to preview records or review the customer data source in the Profile Data Sources landing page in Pega Customer Decision Hub.)
  2. Search for the Container service. (Container V3 after 8.5+ ) (If using V2 Container then please update the following JSON with the sample shared in the user guide.)
    Service REST: Container editing window showing the necessary information needed to test functionality of the service.
    Testing the Container service
  3. Click Action > Run and select POST HTTP method. Enter following JSON into the Message buffer, and Execute the service:
    {
    
    "SubjectID":"CUST1",
    
    "ContextName":"Customer",
    
    "ContainerName": "NextBestAction",
    
    "Channel": "Web",
    
    "Direction": "Inbound",
    
    "Placements":"Tile",
    
    "Contexts":
    
           [{
    
             "Type":"",
    
            "Value":"",
    
            "Key":""
    
          }]
    
    }
    
    Simulate REST Service Execution window showing the JSON in the Message Buffer field.
    Running REST Service with POST HTTP method
  4. If the engagement policies for the actions match the customer’s data, and corresponding treatment is present for the placement in the request (Tile in the above request), then the service response will display the action that was prioritized as the top action.

Testing the Strategies by a Dataflow[edit]

When debugging strategies and conveying more granular testing, decision architects may require testing strategies. A common difficulty faced is caused by the fact that Next Best Action Strategies in Pega Customer Decision Hub run on the Decision-Data-Request-Customer class and does not have direct access to the CustomerCSMS data flow in the customer class. So when testing, you cannot directly choose the Customer you want to run the strategy with.

To be able to choose the customer, complete the following steps:

  1. Create a temporary Decision Data Store data set in the Data-Decision-Request-Customer class and name it SampleCustomers.
    Sample Customers
    Sample Customers
  2. Choose .CustomerID as the key for the data set.
    Editing data set to include .CustomerID key in the Field.
    Specifying key in the data set
  3. Create a data flow in the Customer class and name it LoadCustomersToSampleCustomers.
    1. Use out-of-the-box Customer data set as the source,
    2. Convert it to a top level page in Data-Decision-Request-Customer, map the .CustomerID to .CustomerID.
    3. For destination choose the SampleCustomers data set created in the first step.
      Data flow in the Customer Class loading Customers to Sample Customers.
      Creating a data flow for mapping Customers data
  4. Run the data flow to create the same customer records in the Cassandra data set in Data-Decision-Request-Customer class. (Optional: Add a filter shape to the data flow to reduce the number of records getting uploaded to the data set if necessary.)
  5. Create a new data flow in the Data-Decision-Request-Customer class and name it TestCustomer.
    1. For the source, select the SampleCustomers data set.
    2. Add a Compose shape to join the out-of-the-box CustomerDataCSMS data flow, which includes additional data such as Action Insights.
    3. Compose the .Customer page by adding the condition CustomerID is equal to .CustomerID.
    4. Add a convert shape to add any channel specific attributes that would be passed in the container call.
      TestCustomer data flow window showing sample data flow configuration for testing the data insertion process.
      Creating a data flow for testing the data insertion process
      For example: .ContainerPayload.Channel → Web .ContainerPayload.Direction → Inbound .ContainerPayload.TreatmentPlacementList(1).pyName → Tile .SubjectType → “UBank-Data-Customer
  6. Now select the TestCustomer data flow in any Strategy to be able to execute it for a given CustomerID.
    Data flow configuration for testing the output of the data mockup process.
    Testing the output

References[edit]