Transformers
Behavior Testing Framework provides a set of Transformer
classes. Each class has a transform method that simplifies and standardizes the transformation
of String values into some other type of value. They are all declared in the
gtest.gw.transformer package.
Base configuration transformers
The base configuration provides the following classes:
- CancelOptionTransformer
- Transforms one of the following Strings into a corresponding display key. This is used
to simplify code that must specify a specific drop-down menu option in the user
interface.
- The method expects the input String to be one of the following:
"Cancel Now""Cancel Policy"
- The method expects the input String to be one of the following:
- CloseOptionTransformer
- Transforms one of the following Strings into a corresponding display key. This is used
to simplify code that must specify a specific drop-down menu option in the user
interface.
- The method expects the input String to be one of the following:
"Not-Taken""Decline""Withdraw Transaction"
- The method expects the input String to be one of the following:
- ConflictOverideTransformer
- Transforms one of the following Strings into a corresponding display key. This is used
to simplify code that must specify a specific drop-down menu option in the user
interface.
- The method expects the input String to be one of the following:
"Override None""Override All"
- The method expects the input String to be one of the following:
- DateTransformer
- Transforms a String into a date value.
- You can optionally pass a second parameter, a date value pattern, to the method.
If there is no second parameter, the date pattern value defaults to
"MM/dd/yyyy". - The method does not parse the value leniently. In other words, the method uses strict parsing, which requires a data format value to be an exact match to a know data format.
- You can optionally pass a second parameter, a date value pattern, to the method.
If there is no second parameter, the date pattern value defaults to
- MonetaryAmountTransformer
- Transforms a String into a monetary amount. The String is expected to have the format
<amount><space><currency>. For example,"100 USD"or"50 EUR". The transformer returns a monetary amount whose amount is the given numeric value and whose currency is the given currency value. - TypelistTransformer
- Transforms a String into a typekey. For example, it can convert the String
"Urgent"into the typekeyPriority.TC_URGENT.- The method returns the first typekey whose display name matches the input String, ignoring case.
Best practices for transformers
If you need to transform a String value and the base configuration provides a corresponding transformer, Guidewire recommends you use the transformer. This ensures that similar values are being transformed in a consistent way.
If you need to transform a String value and the base configuration does not provide a corresponding transformer, you may want to consider creating a transformer using an approach similar to the ones used in the base configuration.
