Previous Topic: Usage Scenarios for Simple ObjectsNext Topic: Building Test Steps


Usage Scenarios for Complex Objects

The following examples are based on the standard Java classes for complex objects. We have used classes from the demo server included with DevTest that are easy to reproduce in your environment.

Complex DTO Object Scenario 1

A complex DTO Object, com.itko.examples.dto.Customer, is loaded in the Complex Object Editor using a Dynamic Java Execution step.

A complex DTO Object, com.itko.examples.dto.Customer, has been loaded in the Complex Object Editor using a Dynamic Java Execution step

This DTO is complex because its properties are not all simple values, such as primitives or strings. However, because of its DTO structure, we can still use Simple Mode.

Each of the properties must be given values before the Customer object can be used.

locations

An array of Address objects

poAddr

An Address object

since

A Java Date object

types

An array of integers

  1. Starting with the poAddr object, identify the setPoAddr method in the Call Sheet.

    COE Call Sheet with setPoAddr method selected

  2. Select the setPoAddr method and double-click or click Icon - right arrow Add Method to run this method.

    COE Call Sheet with setPoAddr method invoked

  3. This DTO enables the use of Simple mode. Do not select the Expert Mode check box. The poAddress property is identified as type Address.
  4. In a Simple mode, when you clear the Null parameter, the Address object is expanded to expose its properties. You know, from the previously illustrated Simple Data Object Scenario, that Address has simple properties. You can enter them as values or properties in the Value column.

    COE Object Call Tree with Address object expanded

  5. Click the Execute button to invoke the setPoAddr method.
  6. Select the setTypes method on the Call Sheet and click Icon - right arrow Invoke Method.

    COE Call Sheet with setTypes method invoked

  7. Types is an array of integers. To add as many integers as the array requires, click LISA-- icon_image_whiteplussign Add at the bottom. In the previous example, we added four elements and entered values for each.
  8. Click the Execute button to invoke the setTypes method.
  9. Select the setLocations method on the Call Sheet and click Icon - right arrow Invoke Method.

    COE Call Sheet with setLocations method invoked

  10. Locations is an array of Address objects. Click LISA-- icon_image_whiteplussign Add to add as many elements (of type Address) as required.
  11. In the previous example, we added three Address objects. Two are complete, and we are ready to expand the third Address object to enter property values. When complete, click Execute to invoke the setLocations method. Notice that you can click one of the Location elements in the Object Call Tree to display and edit properties in the Data Sheet tab.

    COE Call Sheet with Address object expanded

    This holds true for all the properties that are listed in the Object Call tree.

  12. Select the getSince method on the Call Sheet and click Icon - right arrow Invoke Method.

    COE Call Sheet with setSince object invoked

    The input parameters for the Data object are displayed and can be given values.

  13. Click the Execute button.

    The Customer object is now fully specified and can be used in your test case.

Complex DTO Object Scenario 2

The last scenario shows an example that builds on the last three scenarios.

This DTO, com.itko.examples.dto.OrderDTO, has a Customer object as one of its properties. This scenario shows how easy it is to build a Customer object in simple mode without calling any setter methods.

The OrderDTO object was loaded in COE using a Dynamic Java Execution step.

The OrderDTO object has been loaded in COE using a Dynamic Java Execution step

Again we can use Simple Mode for the OrderDTO object.

Follow these steps:

  1. Select the setCustomer method in the Call Sheet and click Icon - right arrow Invoke Method. As expected, the input parameter is a Customer object.

    COE Call Sheet with setCustomer method invoked

  2. Clear the check box in the Null column.

    The Customer row expands to expose its properties.

    COE Call Sheet with setCustomer method expanded

    All the properties can be edited in this window. The Integer and String properties can be added in the Value column. The remaining properties expand to show their properties when you clear the Null box for the property. If the property is a single object, it expands to expose its properties. If it is an array or collection, you can add the appropriate number of elements. This graphic shows a snapshot of the editing process.

    COE Call Sheet with setCustomer method being edited

    The locations property has two elements; the types property has three elements. The poAddr object is of type Address, and is expanded exposing simple string properties.