Home / Developing DTL Transformations / Testing Data Transformations

Developing DTL Transformations
Testing Data Transformations
Previous section          
InterSystems: The power behind what matters   

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. If your DTL code references the properties of the aux, context, or process systems objects, enter values for these properties to see the results as if the data transformation was invoked with these objects instantiated. The table for entering values appears only if the DTL references the internal properties of aux, process, or context systems objects.
  2. 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:
  3. Click Test.
  4. 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)

Previous section          
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-06-24 05:36:40