Tester
Evaluates one or more tests on a feature, and routes the feature according to the outcome of the test(s). The tests can consist of any FME-allowed operands.
Input Ports
This transformer accepts any feature.
Output Ports
If the test(s) pass, the feature is output via the Passed port.
If the test(s) fail, the feature is output via the Failed port.
Note that you can combine several tests into a single Tester transformer, and the features can be routed to Passed depending on the Pass Criteria parameter.
Parameters
Values
The Value columns (operands) may be a literal constant, the value of an attribute, a published parameter or a calculated value that is a combination of the above. If it is a calculated function, the function will be executed on the current feature and the result will be used for the test.
Operators
The Operator column is one of: =, !=, <, >, <=, >=, In Range, In, Like, Contains, Begins With, Ends With, Contains Regex, Type Is, Encodable In, Attribute has a value, Attribute Is Null, Attribute Is Empty String, and Attribute Is Missing.
Some comparison operators, such as = and !=, have conventional behavior except as documented. When doing comparisons, null, missing, and empty string values, all evaluate to empty string. Thus, they are considered equal in the context of the comparison operators. Further, the following comparison ordering is respected:
Null, missing, empty string < other values
In Automatic mode, all operators are case sensitive except Like, Contains, Begins With, and Ends With.
Other operators are:
Operator |
Description |
Example |
---|---|---|
In |
A list of values in which you are testing for a certain value. The Right Value is a comma-delimited list of values, or a range. String ranges (i.e. a-d) can also be specified. If you want to test for values that contain a hyphen, those values should be enclosed in quotation marks. For example, if x=LL-27, then x In "LL-27","LL-83" would be true. On the other hand, x In LL-27,LL-83 would be false. This is because LL-27 and LL-83 are treated as two string ranges, LL to 27 and LL to 83. Lexicographically, LL-27 is not in either of those string ranges. |
X=5, if X In 1,2,3 (no = Failed) X=5, if X In 3-7 (yes = Passed) |
In Range |
Does the value fall within the numeric range specified with the set notation? In this notation, []s denote inclusive bounds such as [0,8] which corresponds to 0<=X<=8, while ()s denote exclusive bounds such as (0,8) which corresponds to 0<X<8. It is possible to have one bound exclusive and the other inclusive such as (0,8]. It is also possible to set no bound by leaving one side empty such as [0,] which is any number greater than or equal to 0. This operator is not available in Case Sensitive and Case Insensitive modes. |
X=3, if X In Range [3,8] (yes = Passed) X=3, if X In Range (3,8] (no = Failed) |
Like |
Does the value match the specified string pattern? This supports a wildcard query using the percentage symbol (%), rather than an asterisk (*). In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. |
X=abcd, if X Like %bc% (yes = Passed) |
Contains Regex |
Does a value contain a regular expression? This operator is not available in Numeric mode. |
X=abcd, if X Contains Regex .*bc.* |
Contains |
Does the Right Value appear in the Left Value? In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. |
X=abcd, if X Contains bc (yes = Passed) |
Begins With |
Does a string begin with this? In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. |
X=abcd, if X Begins With a (yes = Passed) X=abcd, if X Begins With b (no = Failed) |
Ends With |
Does a string end with this? In Automatic mode, this operator is case insensitive. This operator is not available in Numeric mode. |
X=abcd, if X Ends With d (yes = Passed) X=abcd, if X Ends With b (no = Failed) |
Type Is |
Is the value of the attribute convertible to one of the listed types? Types included are Integer, Double, Numeric and Boolean. Integer and Double test if the contents of an attribute is representable as a 64 bit integer or 64 bit floating point number respectively. Numeric tests if the value is convertible to a number (behavior is identical to double). Boolean does a case insensitive test to see if the string matches one of the Boolean representations (True, 1, False, 0) |
X=7, if X is Numeric (yes = Passed) X=true, If X is Boolean (yes =Passed) |
Encodable In | Is the value of the specified attribute encodable in the specified encoding without data loss? |
If x=本 If X encoding cp932 passed Japanese Windows If encoding DOS Icelandic failed |
Attribute has a value | Does the attribute have a value? | If attribute specified in 'Left Value' matches (yes =passed) |
Attribute Is Null |
Does the specified attribute have a null value? |
If attribute specified in ‘Left Value’ has a null value (yes=Passed) If attribute specified in ‘Left Value’ does not have a null value (no=Failed) |
Attribute Is Empty String |
Does the specified attribute have an empty string value? |
If attribute specified in ‘Left Value’ is an empty string (yes=Passed) If attribute specified in ‘Left Value’ is not an empty string (no=Failed) |
Attribute Is Missing |
Is the specified attribute absent on the feature? |
If attribute specified in ‘Left Value’ is absent on feature (yes=Passed) If attribute specified in ‘Left Value’ is present on feature (no=Failed) |
If you choose one of the operators: Attribute Is Empty String, Attribute Is Null, or Attribute Is Missing, the Left Value will be considered an attribute name regardless of the icon shown.
Negate
A checkbox indicating that the test should return false if the test expression is true and vice versa.
For example,
X=abcd, is 'abcde' Contains X if negated (answer no = Failed)
X=5, Y=1,2,3,4 is X In Y if negated (answer yes = Passed)
Mode
When Mode is set to Automatic or Numeric, the Tester will compare operands as numbers if possible, and as strings otherwise.
When Mode is set to Case Sensitive, the Tester will compare operands as strings using a case sensitive comparison, and will not attempt numeric conversions.
When Mode is set to Case Insensitive, the Tester will compare operands as strings using a case insensitive comparison, and will not attempt numeric conversions.
Tip: If you know your data is string data, you should set the mode to either Case Sensitive or Case Insensitive. This way, FME does not spend time for each feature to determine if the data is representable as a number, but can just do the string comparison immediately.
For a string that can be represented as a number such as 4.5 or 4e5, if you set Mode to Automatic or Numeric, it will be treated as a number if the other operand is also representable as a number.
For example, if Mode is set to Automatic or Numeric, “4E5=400000” will pass the test. If, on the other hand, you want “4E5=400000” to fail the test, set Mode to Case Sensitive or Case Insensitive.
The Pass Criteria defines how multiple clauses are interpreted in the final classification of the incoming feature. The possible choices are: Any Test (OR), All Tests (AND), and Composite Test.
Here are descriptions of the three choices, and relevant scenarios.
Scenario | Pass Criteria | Description |
---|---|---|
If any test passes, the input feature will be classified as Passed. | Any Test (OR) | In this case, as long as one of the test clauses is true, then the feature is Passed. This is an OR test (test1 OR test2 OR test3). If any one is true, then the result is true. |
All tests must pass for the input feature to be classified as Passed. | All Tests (AND) |
This is stricter than Any Test (OR) because all tests must be true in order for the result to be true (test1 AND test2 AND test3). |
Create your own test expression. This is useful when you need fine-grained control over what you want the Tester to evaluate. If you select this mode, a Composite Test field is enabled. |
Composite Test |
If, for example, you want to check whether the value of an attribute is between 5 and 10, or equals 99, you can set up three test clauses: Clause 1 : x > 5 Clause 2 : x < 10 Clause 3 : x = 99 (where x is the selected attribute in the Left Value field):
To correctly get the desired results, you require that clause 1 AND clause 2 be true (between 5 and 10), OR clause 3 be true (equals 99). In this case, choosing Any Test or All Tests modes will not satisfy the test requirement. You can, however, choose Composite Test and enter the following expression in the Composite Test field: ((1 AND 2) OR 3) The numbers above correspond to the test clauses defined in the 'Test Clauses' table. When read, the composite expression above states that 'Clause 1 AND Clause 2 must be true, OR Clause 3 must be true'. |
The expression to be used when the Pass Criteria parameter is Composite Test. The expression can refer to a clause in the Test Clauses table using that clause's row number.
Examples
Attribute | Test Condition | Result |
---|---|---|
x=abcd | X Contains abcd | Passed |
x=a, Y=big | X In Y | Failed |
X=100 | X < 200 | Passed |
X=4E5 | X=400000 |
Passed, if Mode set to Automatic Failed, if Mode set to Case Sensitive or Case Insensitive |
Examples where Mode should be set to Automatic or Numeric:
@Area() < 100
@Value(numLanes) > 2
Example where Mode should be set to Case Sensitive or Case Insensitive:
"Joe" = "Jerry"
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
Transformer Categories
Transformer History
This transformer replaced the AttributeTester and GenericTester transformers.
Search FME Knowledge Center
Search for samples and information about this transformer on the FME Knowledge Center.
Tags Keywords: AttributeTester "comparison mode" GenericTester "pass criteria" "test clause"