Nodeflip Documentation

Explore the features and functionalities of Nodeflip.

Test Data

This tool allows the creation of test data files based on a template structure (XML or JSON) and configurable generation rules.

Test Data Generation

Workflow Overview

  1. Select Template: Choose a loaded file (from the Select Template File dropdown) to use as the structural template for generation.
  2. Configure Fields: Define how data should be generated for each field within the template structure.
  3. (Optional) Save Configuration: Save the current field configurations for later reuse.
  4. Set Generation Options: Specify the number of files to generate and optionally choose a source ZIP template.
  5. Generate: Create the test files based on the template and configurations.

Features

Template Selection

  • A dropdown list populated with the currently loaded files (XML/JSON). The selected file's structure is displayed in the "Template Configuration" area.

Lists Management

  • Lists are reusable collections of values that can be used to create test data.
    • Lists can be created or managed by clicking the MANAGE LISTS button in the top-right corner.
    Test Data Value List

Template Configuration

This interactive tree displays the structure of the selected template file and allows configuration of data generation for each field.

  • Tree Display: Shows the hierarchical structure of the template.
  • Expand/Collapse:

    • Nodes can be expanded/collapsed individually using arrow icons.
    • Expand All / Collapse All buttons control the entire tree's expansion state.
  • Field Configuration: For each field (leaf node) in the tree:

    • Behavior Selection: A dropdown menu allows choosing the generation behavior for the field's value.
    • Test Data Generation Options

    • Settings Icon (Gear icon): Opens the field configuration dialog to configure detailed options specific to the selected behavior.
    • Test Data Generation

    • Value Preview: Displays the original value from the template alongside a preview/example of the value that would be generated based on the current configuration.
    • Copy Value: Clicking the preview value copies it to the clipboard.
    • Tooltips: Hovering over the preview value shows a tooltip explaining the configuration and providing an example.

Field Generation Behaviors

  • Keep Original: (Default) Uses the exact value found in the template file.
  • Auto Increment (Enumerate): Generates sequential numeric values. Can often detect numbers within strings (e.g., ID-001 -> ID-002).

    • Options: Starting value (can use template value), increment amount.
  • Generate UUID: Creates unique identifiers.

    • Options: Uppercase/lowercase, prefix, suffix.
  • From List: Selects values sequentially or randomly from a predefined list (managed via the MANAGE LISTS dialog).

    • Options: Select list, selection mode (sequential, random).
  • Generate Date: Creates date/datetime values.

    • Options: Mode (Increment Day/Time, Today +/- Days, Fixed Date, Random Date), base date, date format, include time.
  • Generate Number: Generates random numbers.

    • Options: Type (Integer, Decimal), min/max values, precision (for decimals).
  • Reference Value: Copies the generated value from another field within the same generated file.

    • Options: Specify the source field, optional simple transformation.
  • Custom Script (Advanced): Uses custom code to generate a value.

    • Options: Provide custom JavaScript expression. For more info, see Custom Scrips.

Custom Scripts

Custom scripts are JavaScript expressions that generate dynamic values. They have access to:

  • value: The original field value from the template (automatically provided)
  • index: The current file index (0-based)
  • arrayIdx: The array item index (if in an array)
  • path: Current field path (e.g., "library/books/0/title")
  • row: Access to other fields in the same data row (e.g., row.title, row.author)

Script Behavior

  • Must return a value (use "return" statement)
  • Can perform calculations and manipulations
  • Can contain multiple lines and complex logic
  • Can access other values using reference paths
  • Can access sibling fields using the row object
  • Executed in a safe environment with limited scope

Example Use Cases

1. Formatting IDs with Specific Patterns
// Generate IDs like "TD0000001", "TD0000002", etc.
// In this example, we don't use the "value" parameter
const prefix = "TD";
const baseNumber = 2; // Starting number
const digits = 7;     // Number of digits in the numeric part

// Calculate the current number based on file index
const currentNumber = baseNumber + index;

// Format with correct number of leading zeros
const formattedNumber = currentNumber.toString().padStart(digits, "0");

// Combine prefix and formatted number
return `${prefix}${formattedNumber}`;
// For index = 0 → Returns: "TD0000002"
2. Formatting and Combining Values
// Format a phone number (ignoring the original "value")
const num = Math.floor(1000000000 + Math.random() * 9000000000);
return `(${num.toString().substring(0,3)}) ${num.toString().substring(3,6)}-${num.toString().substring(6)}`;
// Returns: "(123) 456-7890" (with random numbers)
3. Date Manipulations
// Generate a date N days from today (YYYY-MM-DD)
const date = new Date();
date.setDate(date.getDate() + index * 7); // Weekly dates
return date.toISOString().split("T")[0];
// For index = 0 → Returns: "2023-07-14" (today's date)
4. Complex Value Generation
// Generate GUIDs with a consistent pattern
return `${index}-${Math.random().toString(36).substring(2, 10)}-${Math.random().toString(36).substring(2, 6)}`;
// For index = 0 → Returns: "0-a1b2c3d4-e5f6"
5. Conditional Logic
// This example USES the "value" parameter
// Assuming "value" contains an age string like "25"
const age = parseInt(value || "0");
if (age >= 65) return "Senior";
if (age >= 18) return "Adult";
return "Minor";
// For value = "15" → Returns: "Minor"
6. Working with Row Data
// Combine title and author from row data
if (row.title && row.author) {
  return `${row.title} by ${row.author}`;
}
// If row.title = "The Great Gatsby" and row.author = "F. Scott Fitzgerald"
// Returns: "The Great Gatsby by F. Scott Fitzgerald"

Tips

  • Keep scripts simple for better performance
  • Use try/catch for error handling

Configuration Management

  • Saved Configurations Dropdown: Lists previously saved configuration sets for the currently selected template file type.

    Test Data Saved Configurations

    • Selecting a saved configuration applies its rules to the "Template Configuration" tree.
  • SAVE Button: Opens a dialog to name and save the current set of field configurations associated with the template.

    • Saved configurations are stored locally in your browser.

File Generation Options

  • Number of Files to Generate: A numeric input field to specify how many distinct output files should be created.
  • Template Source (Optional ZIP): A dropdown to select a loaded ZIP file.

    • If a ZIP is selected, the generator uses the file structure within the ZIP as a base, replacing or merging generated data into copies of the files found inside.
    • If None is selected, generation is based purely on the primary selected template file.
  • Generate Test Files Button: Starts the file generation process.

    • A progress bar indicates the status.
    • Generated files are added to the application's file list (visible in the "Files" section).