Custom arguments are used to describe custom objects. Custom argument tags take place within the scope of </Argument>. The custom arguments can be nested to any number of levels. As an example, our StudentManager has a method add that takes a Student object, which is itself a custom object. So to describe the Student object, you will have to write the following XML format:
</IdArgument Name="someName" Type="type" Value="value"/>
You should replace "Id" with the actual Id defined as part of the <Argument> tag attributes. Remember the <Argument> tag for the testAdd method:
<Argument Num="1" Type="example.Student" VALUE="CustomType"
StudentX is the declared Id. So, your Custom Argument tag will look like this:
<StudentXArgument Name="name" Type="String" Value="Subbu" />
However, the Address object also has another custom object, Address, as an instance variable. Also, the method to be invoked to set this address object value does not follow the standard "set" convention. That is, you don't have a standard setAddress method; you have addressIs(Address a) instead. You can handle this situation using your XML tags.
<StudentXArgument Name="course" Type="Address" Value="CustomType"
<AddressArgument Name="street" Type="String" Value="1 Adams Ave" />
<AddressArgument Name="city" Type="String" Value="Atlanta" />
For a detailed description of the custom argument attributes, see the Custom Argument Attribute Descriptions table.
Custom Argument Attribute Descriptions
||Name of the instance variable.|
The assumption is that the instance variable name in the Student class has a public set method. Using the reflection, the Address object will be created and the setName method will be called with the value Subbu.
||Indicates the type of argument.|
This attribute supports all simple data types. For complex data types, this would be a fully qualified class name such as java.util.Vector.
E.g., String, int, java.util.Vector, Student
||Indicates the value to be passed. |
E.g., DolphinNose, for the method testFindStudent.
If the Type is a user-defined type or complex data type, Value should be set to CustomType.
||The name of the method that should be called to set the value.|
By default, this would be "set" along with an instance variable name. However, if your custom object does not have a standard setter method, you can always use the Method attribute to specify the method that should be invoked.
So, you have a nested CustomType situation (Address object as an instance variable inside Student). Follow the convention you used for describing the Student object: set the Value to CustomType and define the Id as "Course." The difference here is the Method attribute. Since you do not have a standard setAddress method, you have to list the method name explicitly.