Creating Test Data

Overview

When creating apps or testing functionality, it is often necessary to create test data. There are a number of ways to do this in PhixFlow. The following methods will be covered:

  • Creating an Editable Grid - This method creates a spreadsheet-style screen, that allows you to edit and update data. This method is best when using existing data
  • Using External APIs - This method is best for creating large datasets using a third-party data generator (mockeroo.com)
  • Using Input/Output Multipliers - This method is best for small datasets, with specific examples. The data can be easily rolled back and reset to its original state. For example, testing the results of a function

If, after making changes, you wish to restore your test data to a previous run or its original form, see Rolling Back Test Data.

Video

Creating an Editable Grid 

Use a simple ERD and Screen setup to create an editable grid. 

Step 1: Create a table

 How?
  1. On an  ERD, either:

    1. Create a new table by dragging  Table from the toolbar onto your ERD canvas

    2. Add an existing table by clicking  Table on the toolbar, then dragging a table from the  Repository onto your ERD canvas 
    3. Import a CSV file by dragging it from your PC onto your ERD canvas
  2. If you create a new table, PhixFlow automatically adds the following attributes to the table:

    1.   Primary key: UID

    2.   Display Name: Name 

  3. If you import a CSV file, add the above UID attribute to your table and set it as the   Primary key 
  4. Add the attributes you require to your table by clicking Add on the table, and give your attributes appropriate names

    1. New attributes only require a valid Name and Type

Step 2: Create a Screen 

 How?
  1. To create a screen using your ERD data, click  on your table and choose screen Create Screen
  2. On the Create Screen wizard, enter the following:
    1. Name: give your screen an appropriate name 
    2. Open Maximised: toggle 
    3. Description: give your screen an appropriate description to indicate its purpose
    4. Template: choose Tile with Buttons, Tile no Buttons or Edit Form
      1. For this example, Edit Form has been chosen
    5. Click Create Screen
  3. The Available Attributes selector will automatically appear
  4. Click the tickbox next to each attribute, or click the top tickbox to select all of the attributes, and drag them onto your screen
  5. PhixFlow will ask how you would like the attributes to be displayed, choose  Grid
  6. PhixFlow will ask if you would like to add actions, choose Yes
  7. On the Grid Actions wizard, drag Delete Selected Records onto the Delete button on your screen - this is the only button you need 
  8. Close the Grid Actions and Available Attribute wizards

Step 3: Set up the Screen

 How?
  1. Right-click on the grid on your screen and select  Show the View Configuration
  2. On the  Actions tab, toggle on  Auto Save
    1. Note: Enabling Auto Save automatically saves any changes made to the data 
    2. Click  Apply and Close
  3. In the Layers panel, click on the area containing the grid to open its Properties on the right
  4. Click on the  Styles tab and within the Style Settings section, ensure the Width and Height to 100% 
    1. Click  Apply and Close
  5. Click on the Name attribute header on the grid to open the View Attribute Properties on the right
  6. On the  Styles tab, in the Grid Settings section, untick Read Only
    1. In PhixFlow version 11 and older, this option is on the  Properties tab
    2. Click  Apply and Close
  7. Repeat this step for all of your attribute headers, except UID
    1. Note: Unticking Read Only will allow you to manually enter information into these columns on your grid
  8. Then click  Apply and Close
  9. With Auto Save set up, the screen no longer requires a Save button
  10. To delete the Save button, click on it on the screen to highlight it in the Layers, right click it in Layers and select  Permanently Delete

Adding a Button

  1. Open the Palette by clicking  Palette on the toolbar
  2. Expand the Buttons - Primary section and drag the Add button onto your screen - the screen will highlight the areas where the button should be dropped
  3. Give your button a name
    1. Optional: In the Layers panel, expand the area Window CRUD Bar. Then, while holding shift, drag and drop your Add button onto either the Left or Right area within the Window CRUD Bar

Check Point

At this point, your screen should look similar to this:

Step 4: Add New Records via an Actionflow

 How?
  1. Right-click on your new Add button and choose  Add Actionflow
    1. Give your Actionflow a name
  2. To configure the input connection, within the Connections section on the left, click on Click to Connect
  3. Choose the On Click Action Event, then select Connect Input
  4. Drag a  Calculate action from the toolbar onto the canvas
    1. Give it a suitable name
  5. The  Properties for the Calculate action will show on the right
    1. If these are not open, click the Calculate action to reopen them
  6. In the Output Attributes section, add a new attribute by selecting 
    1. Give it a name and set the expression to "new"
  7. Drag a  Save action from the toolbar onto the canvas
    1. Give it a name
    2. Set the Type to Auto Insert/Update
    3. On the Table dropdown list, choose the table you made earlier on your ERD
  8. Connect the out pipe from the Calculate node to the Save node
  9. Map across your Output Attribute from the Calculate node onto the Save node
  10. Drag the Input Connection Point onto the Calculate node 
  11. Close the Actionflow and open the screen you created earlier
  12.  Lock the screen, then select the Add button
  13. The Actionflow will fire and a new record will be created on the grid, with a unique ID (UID)
  14. Double click on the fields to manually enter information 
  15. Repeat these steps of adding a new record and updating the information as many times as required
  16. Each record will save automatically

Check Point

At this point, your screen should look similar to this:

Using External APIs 

Configure an  Analysis Model to import data stored outside of PhixFlow using an API.

Create a Multi-Record Table using an API

This example uses the below three elements to create dynamic data. The table in this example will pull across data, as stipulated by the attributes, and this data will change each time the user clicks  Run Analysis.

The HTTP Datasource is used to connect to the external source, the HTTP Collector then reads the data, and the Table stores the data in PhixFlow. 

For more information on how these three elements work and for a detailed example, see Importing Data Through an API.

 How?
  1. Prepare your API data and ensure it is in JSON format. For this example, we have created a data schema and mock API using https://www.mockaroo.com/mock_apis
  2. On an  Analysis Model, create a new  HTTP Datasource
  3. Set up your  HTTP Datasource Properties to look similar to the below settings, and ensure your URL matches your API source
  4. Hover over your  HTTP Datasource and select  Add a new HTTP Collector on the hover menu
  5. Set up the  HTTP Collector Properties to look similar to the below settings, and ensure your URL passes in your API key
  6. Hover over your  HTTP Collector and select  Create New Table
  7. Set up the  Table Properties to look similar to the below settings, and ensure the  Attributes you wish to display on your view are set up
  8.  Run Analysis on your  Table, then  Show view to see your data

Using Input and Output Multipliers 

Use a simple table configuration on an  Analysis Model.

Create a Multi-Record Table using an Array

This example uses an array to create static data. The table in this example will produce the exact records as stipulated in the Input Multiplier.

 How?
  1. On an  Analysis Model, create a blank Calculate  Table
  2. Within the Table's  Properties tab, add  Attributes to the table, which will act as column headers

    1. Add the Expression _inputMultiplier, followed by .1, .2, .3, etc. to the relevant attributes
  3. In the Analysis Options section, in the Input Multiplier box, add an array, like the example here
    1. Input Multiplier
      [
          [1,'CHAIR',100],
          [2,'TABLE',430],
          [3,'MONITOR',800]
      ]
  4.  Apply and Close the Properties, then  Run Analysis on the table
    1. Hover over the table and select  Show view
    2. For this example, the data shows three records, with each record assigned the UID, Item name and Quantity as specified by the Input Multiplier, along with the Last Updated date 

Alternatively, an Output Multiplier can be used to create data. Repeat the steps above, but with the following changes:

  1. The Expression for all of your attributes must be _outputMultiplier, followed by .1, .2, .3, etc.
  2. Add the same array as above, but to the Output Multiplier box
  3. Add 1 in the Input Multiplier box to indicate the number of times the table should run