Attributes of complex objects
Arguments that are based on primitive types (int, char, double, long, and so on), wrapped primitive types (for example Integer or Double), or Strings can be visualized as a single row in a test data table. Complex objects, on the other hand, cannot be visualized in a single row in the test data table and must be represented hierarchically in several table rows. Each row of a complex object is called an attribute.
The Rational Developer products give you several ways to define an object and its attributes: These definitions are based on:
- The available constructors for the object. One set of attributes is provided for each available constructor. If there are three available constructors for a class, each with a different set of attributes, there will be at minimum, three sets of defining attributes.
- The properties of the object. A set of attributes is provided for any object that conforms to the JavaBeans specification. The attributes that are provided match the properties of the JavaBean.
- Specialized support for a predefined set of classes and interfaces (see below). This specialized support lets you compare objects of a particular class by breaking down the class into a set of attributes. These attributes can also be used as the object's defining attributes.
When you click in the test data table in any cell that represents an object with defining attributes, you are presented with a list containing the different sets of defining attributes for the object, as shown in the following screen capture:
![]()
In this figure, several sets of defining attributes are provided for the object, which is of type Date.
- The first set (set date as long) is included in the product's specialized support for the Date class.
- The second set (set properties) is from the properties of the JavaBean. (For details about JavaBeans, see http://java.sun.com/products/javabeans/docs/beans.101.pdf.)
- The other sets are from the available constructors.
When you choose one of the sets, the row representing the object expands to display the defining attributes that you have chosen for the object (in this case set properties), as shown in the following screen capture:
![]()
Object comparisons in validation action calls
An object's defining attributes are used not only to define the object in the test data table, but also to compare objects in a validation action. If class or interface-specific support has been used to initialize the object, the same support will be used to perform the comparison. If the object has been initialized by a constructor, the actual value will be compared to the expected value using the global comparison (the equals() method). If the object has been initialized by properties, actual values will be compared to expected values by comparing each property (attribute).
Working with interfaces and abstract classes
If the parameters or return types that you need to define are for an interface or abstract class, you will need to change the data type to a subclass that implements the interface or extends the abstract class in order to actually define the object's attributes. For example, the following method takes an IMoney interface as a parameter:
public add (IMoney m)
In the test data table, you will need to change the IMoney interface to a class that implements IMoney, such as Money. For details, see Using a subclass to initialize and test an object.
Java classes with special support
Special support is provided for the following classes:
- Arrays in general
- java.math.BigDecimal
- java.math.BigInteger
- java.util.BitSet
- java.lang.Boolean
- java.lang.Byte
- java.lang.Character
- java.util.Date
- java.lang.Double
- java.lang.Float
- java.lang.Integer
- java.lang.Long
- java.lang.Short
- java.lang.StringBuffer
- java.lang.Throwable
- Classes that implement the java.util.Collection interface
- Classes that implement the java.util.Map interface
Related tasks
Supplying test data for the attributes of object data types