DataFactory Testing API

DataFactory is MasonHub’s powerful testing and simulation utility that allows you to trigger various OMS actions and callbacks in the sandbox environment. This comprehensive tool helps you test integration workflows, simulate real-world scenarios, and validate your system behavior before production deployment.

DataFactory is only available in the sandbox environment. Use it to test integrations thoroughly before deploying to production.

Overview

DataFactory provides comprehensive testing capabilities:

Inventory Simulation

Simulate inventory changes, receipts, and adjustments with realistic scenarios

Order Fulfillment

Trigger order shipping, multi-shipments, shorts, and delivery events

Callback Testing

Generate all callback types to test webhook handling

Workflow Validation

Test complete end-to-end integration workflows

Inventory Operations

Create Available Inventory

Simulate inventory receipts and additions for testing purposes.

sku_id
string
required

UUID of the SKU to add inventory for

quantity
integer
required

Amount of inventory to add

location_id
string

Specific inventory location UUID

lot_number
string

Lot/batch number for traceability

expiration_date
string

Expiration date for perishable items

This operation will:

  • Add inventory in ‘available’ status
  • Trigger skuInventoryChange callbacks
  • Update total available-to-sell quantities

Simulate Inventory Loss

Simulate inventory adjustments for damaged, lost, or spoiled items.

sku_id
string
required

UUID of the SKU to adjust inventory for

quantity
integer
required

Amount of inventory to remove

reason
string

Reason for inventory loss (damage, theft, spoilage, etc.)

Order Fulfillment Simulation

Ship Orders

Simulate order shipments to test fulfillment workflows and callbacks.

order_customer_id
string
required

Customer order identifier to ship

shipping_provider
string

Carrier for shipment (UPS, FedEx, etc.)

service_level
string

Service level (ground, express, overnight)

simulate_shorts
boolean

Simulate short shipments (partial fulfillment)

tracking_number
string

Custom tracking number for testing

Simple order shipment with standard carrier and service level

Callback Testing

Trigger Specific Callbacks


```json Response
{
  "orders_processed": 1,
  "shipments_created": 2,
  "callbacks_triggered": [
    "orderEvent"
  ],
  "shipment_details": [
    {
      "shipment_id": "test-ship-001",
      "tracking_number": "1Z999AA1234567890",
      "line_items": [
        {
          "sku_customer_id": "sku-003",
          "quantity": 2
        }
      ]
    }
  ]
}

Parameters

FieldTypeDescription
order_customer_idstringCustomer order identifier
shortsarraySKU identifiers to simulate shortages
number_of_shipmentsintegerNumber of shipments to create (1-5)
shipping_providerstringCarrier simulation (UPS, FedEx, USPS)
randomize_trackingbooleanGenerate random tracking numbers

Delivery Events

Available Events

1

tendered

Package tendered to carrier - initial scan

2

inTransit

Package in transit with location updates

3

outForDelivery

Package out for delivery on delivery vehicle

4

delivered

Package successfully delivered

5

undeliverable

Package undeliverable - return to sender

Order Management Operations

Resolve Update Requests

Resolve Cancel Requests

POST /data_factory/resolveOrderCancel

[
  {
    "order_cancel_request_id": "1c855f3a-f779-5597-9eed-93639c6eb0ee",
    "resolution": "success",
    "refund_amount": 99.99,
    "refund_method": "original_payment"
  }
]

Inbound Shipment Simulation

Receiving Events

Event Types

onDock: Shipment arrived at facility dock

receivingStarted: Warehouse team started processing

receivingCompleted: All items processed and put away

Randomized Status Distribution

When randomize_inventory_statuses is enabled:

Available (70%)

Items received in good condition, ready for sale

Quality Control (15%)

Items requiring inspection before availability

Damaged (10%)

Items received with damage requiring disposition

Refurbishing (3%)

Items requiring repair or refurbishment

Under Investigation (2%)

Items with unclear status requiring investigation

Returns Management (RMA)

RMA Processing Events

RMA Event Types

1

tendered

Return package tendered to carrier by customer

2

inTransit

Return package in transit to facility

3

delivered

Return package delivered to facility

4

receiveFull

All expected items received and processed

5

receivePartial

Only some expected items received

Testing Workflows

Basic Integration Test

1

Setup Test Data

// Create SKUs with inventory
POST /data_factory/createAvailable
[{"sku_id": "test-sku-001", "quantity": 100}]
2

Create Test Orders

// Create orders via standard API
POST /orders
[{"customer_identifier": "test-order-001", ...}]
3

Simulate Fulfillment

// Ship the orders
POST /data_factory/shipOrder
[{"order_customer_id": "test-order-001"}]
4

Verify Callbacks

Monitor webhook endpoints for expected callbacks

Advanced Scenario Testing

Callback Validation

Expected Callback Events

DataFactory operations trigger production-equivalent callbacks:

Inventory Events

skuInventoryChange: After createAvailable, loseInventory

snapshotReady: Not triggered by DataFactory

Order Events

orderEvent: After shipOrder, delivery events

orderUpdateResolution: After resolveOrderUpdate

orderCancelResolution: After resolveOrderCancel

Fulfillment Events

inboundShipmentEvent: After inbound simulations

shipmentEvent: After shipping operations

Returns Events

rmaEvent: After RMA simulations

qualityEvent: During randomized processing

Callback Testing Strategy

// Test webhook handler
const testWebhook = async (eventType, testData) => {
  // Trigger DataFactory event
  await triggerDataFactoryEvent(eventType, testData);
  
  // Wait for callback
  const callback = await waitForCallback(eventType, 30000);
  
  // Validate payload
  expect(callback.message_type).toBe(eventType);
  expect(callback.data).toBeDefined();
  
  // Verify business logic
  await verifyBusinessLogic(callback.data);
};

Performance Testing

Load Testing with DataFactory

Best Practices

Test Data Management

Consistent Identifiers

Use predictable, test-specific IDs to avoid conflicts with other tests

Data Isolation

Separate test scenarios to prevent interference between test runs

State Management

Reset test state between runs for consistent results

Documentation

Document test scenarios and expected outcomes

Integration Testing Strategy

  1. Start Simple: Begin with basic CRUD operations
  2. Add Complexity: Gradually introduce complex scenarios
  3. Test Edge Cases: Validate error conditions and edge cases
  4. Performance Testing: Test with realistic data volumes
  5. End-to-End Validation: Test complete business workflows

Limitations & Considerations

Sandbox Only: DataFactory is not available in production environments

Test Data: Creates simulated data that doesn’t reflect real inventory or order states

  • Rate Limits: Standard API rate limits apply to DataFactory operations
  • State Consistency: Maintains sandbox state consistency but may not match production patterns
  • Timing: Events are triggered immediately, not following real-world timing patterns

Next Steps

After using DataFactory for testing, explore: