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 below.
Parameters
The Pass Criteria defines how multiple clauses are interpreted in the final classification of the incoming feature. The possible choices are: All Tests (AND), One Test (OR), and Composite Test.
Here are descriptions of the three choices, and relevant scenarios.
Scenario | Pass Criteria | Description |
---|---|---|
One test is required for the input feature to be classified as Passed. | One 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 are required for the input feature to be classified as Passed. | All Tests (AND) |
This is stricter than One Test (OR) because all tests must pass 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 Expression field appears. |
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 is true (equals 99). In this case, choosing One 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 Expression 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 satisfied, OR Clause 3 must be satisfied'. |
The expression to be used when the Pass Criteria parameter is Composite Test. The expression can refer to a clause from the Test Clauses table using that clause's row number.
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, In range, Like, Matches Regex, Contains, Begins With, Ends With, Type is, and Encodable in.
Some operators, such as = and !=, have conventional behavior except as documented here. When the comparison operators =, !=, <, >, <=, >= are applied to null, missing, and empty string values, the trio will all evaluate to the empty string. Thus, they are pairwise equal in the context of these comparison operators. Further, the following comparison ordering is respected:
Null, missing, empty string < numbers < other values
Other, less conventional operators are described in more detail here:
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. |
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 i.e [0,8] corresponds to 0<=X<=8. While ()s denote exclusive bounds i.e (0,8) corresponds to 0<X<8. It is possible to have one bound exclusive and the other inclusive ie (0,8]. It is also possible to set no bound by leaving one side empty ie [0,] is any number greater than or equal to 0 |
X=3, if X In Range [3,8] (yes = Passed) X=3, if X In Range (3,8] (no = Failed) |
Like |
Allows you to use a wildcard query. Note that wildcard queries use the percentage symbol (%), not an asterisk (*). 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? This operator is not available in Numeric mode. |
X=abcd, if X Contains bc (yes = Passed) |
Begins With |
Does a string begin with this...? 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..? 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. You may select multiple types, when multiple types are selected, if a feature is convertible to one or more of the listed types it will fast. Integer and Double types test if the contents of an attribute is representable as an integer or floating point number respectively. Numeric tests if the value is convertible to a number (behaviour is identical to double). Boolean tests if the string matches one of the Boolean representations (TRUE,True,true,1,FALSE,False,false,0) |
X=7, if X is Numeric (yes = Passed) X=true, If X is Booelan (yes =Passed) |
Encodable in | Is the value of the specified attribute encodable in the specified encoding without data loss? |
If x=本 If X encoding cp392 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? This operator is not available in Numeric mode. |
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? This operator is not available in Numeric mode. |
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? This operator is not available in Numeric mode. |
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. To force the Tester to use the value of an attribute, attrName, as the attribute name, you must explicitly type @Value(attrName) into the Left Value field.
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 empty string ranges, since numbers are ordered earlier than letters when considered as strings.
Negate
A checkbox indicating that the test should return the false if the “<lhs> <op> <rhs>” 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 String, the Tester will compare operands as strings, and will not attempt numeric conversions.
Let us refer to strings that can be interpreted as numbers, such as "4E5", as alphanumeric strings. For an alphanumeric string, if you set Mode to Automatic or Numeric, it will be treated as a number if the other operand is also an alphanumeric string, and furthermore the operator used is available in Numeric mode.
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 String.
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 String |
Examples where Mode could be set to Automatic or Numeric:
@Area() < 100
@Value(numLanes) > 2
Example where Mode could be set to String:
"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"