Developing DTL Transformations
Testing Data Transformations
Go to:

After you compile a data transformation class, you can (and should) test it. This chapter describes how to do so. It contains the following sections:

This chapter applies to both DTL transformations and custom transformations.
Using the Transformation Testing Page
The Management Portal provides the Test Transform wizard. You can access this from the following locations in the Management Portal:
Initially the Output Message window is blank and the Input Message window contains a text skeleton in a format appropriate to the source message. To test:
  1. Edit the Input Message so that it contains appropriate data. What displays and what you enter in the input box depends on your source type and class:
  2. Click Test.
  3. Review the results in the Output Message box.
The following shows an example:
Testing a Transformation Programmatically
To test a transformation programmatically, do the following in the Terminal (or write a routine or class method that contains these steps):
  1. Create an instance of the source message class.
  2. Set properties of that instance.
  3. Invoke the Transform() class method of your transformation class. This method has the following signature:
    classmethod Transform(source As %RegisteredObject, ByRef target As %RegisteredObject) as %Status
  4. Examine the target message and see if it has been transformed as wanted. For an easy way to examine both messages in XML format, do the following:
    1. Create an instance of %XML.Writer.
    2. Optionally set the Indent property of that instance equal to 1.
      This adds line breaks to the output.
    3. Call the RootObject() method of the writer instance, passing the source message as the argument.
    4. Kill the writer instance.
    5. Repeat with the target message.
For example:
    //create an instance of the source message
    set source=##class(DTLTest.Message).CreateOne()
    set writer=##class(%XML.Writer).%New()
    set writer.Indent=1
    do writer.RootObject(source)
    w !!
    set sc=##class(DTLTest.Xform1).Transform(source,.target)
    if $$$ISERR(sc) {do $system.Status.DisplayError(sc)}

    set writer=##class(%XML.Writer).%New()
    set writer.Indent=1
    do writer.RootObject(target)