Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Unit testing a Parse Structured rule

Updated on April 5, 2022

You can test a Parse Structured rule directly, separate from the activity or other context in your application in which it will ultimately operate.


For a simple test, obtain an XML document that contains test data. You can choose to type or paste the document into a form, store it in a local Windows file, or upload it into a Text File rule.

Conducting the test

For basics of unit testing, see Unit testing individual rules.

  1. Save the Parse Structured form.
  2. Click Run or the equivalent keyboard shortcut CTRL + R. A test window opens.
  3. Select a radio button to indicate whether a new empty page or an existing page is to provide input property values for the test.
  4. Select a radio button to indicate the source of test data.
  5. If the data is to be entered directly, type or paste the data into the text area. If the data is in a local file, click Browse and navigate to the file. Click OK. If the test data is in a text file rule, enter all three key parts of the rule separated by periods.
  6. Click Execute. The resulting parsed XML document appears in a new window. The clipboard is not altered.

The parseState object and debugging

As it executes, a Parse Structured rule creates and maintains a Java object in memory named parseState. This corresponds to a method variable in the generated Java.

This object is not visible through the Tracer or the Clipboard tool, but you can use Public API functions to examine it. To do this, include a Java step containing the Public API call:

myStepPage.putString("debug3", Long.toString(parseState.getStreamOffset()) );

where debug3 is a Single Value property. This function places the byte offset position of the Java object into a clipboard value. You can review the clipboard value with the Tracer or Clipboard tool.

Four Pega Platform methods operate on the parseState object:

  • Parse-Byte-Pos (for byte streams)
  • Parse-Char-Pos (for character streams)
  • Parse-Fixed-Binary (for byte streams)
  • Parse-Packed-Decimal (for byte streams)

The result of each method is stored in parseState.lastToken (which can be accessed in a Java step) and optionally is stored as a property value.

The parseState object is defined in the PublicAPI Interface

This facility is based on* capabilities (not the newer java.nio.* capabilities). The PublicAPI includes methods to query or operate on the object.

Using the Tracer

To trace the start and end of Parse Structured rule executions:

  1. Open the Tracer.
  2. Click Settings to open the Tracer Settings panel.
  3. Under the Rule Types to Trace section, select the Parse Rules check box.

See Configuring Tracer settings.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us