Table Transformers
VIVIDUS provides a set of pre-registered table transformers. Also plugins may register own table transformers (they are documented in the corresponding plugins articles).
FROM_LANDSCAPE
FROM_LANDSCAPE
transformer is designed to transform the table from a landscape form.
{transformer=FROM_LANDSCAPE}
|header 1|value 11| ... | value m1|
...
|header n|value 1n| .... |value mn|
RESOLVING_VARIABLES_EAGERLY
Normally the variable placeholders in ExamplesTables are resolved prior to scenario execution, but there might be cases where the variable placeholders resolution is required during the processing of transformers chain.
RESOLVING_VARIABLES_EAGERLY transformer supports only NEXT_BATCHES variables and global variables defined in properties.
|
{transformer=RESOLVING_VARIABLES_EAGERLY}
{transformer=X}
{transformer=Y}
|value |
|${variable_ref}|
{transformer=RESOLVING_VARIABLES_EAGERLY}
|Meta: |value |
|@env ${currentEnv}|${variable_ref}|
RESOLVING_EXPRESSIONS_EAGERLY
RESOLVING_EXPRESSIONS_EAGERLY
transformer processes expressions which are used inside ExamplesTable eagerly, i.e. at the table loading stage.
If expressions generating random data are used in the table with RESOLVING_EXPRESSIONS_EAGERLY
transfomer, the random data will be generated once
and each placeholder will be replaced with this value. While in regular flow placeholders are replaced with the expression and data is generated
at step execution stage, in other words the same placeholders will be replaced by different randomly generated datasets.
{transformer=RESOLVING_EXPRESSIONS_EAGERLY}
|firstName |lastName |
|#{generate(Address.firstName)}|#{generate(Address.lastName)}|
RESOLVING_SELF_REFERENCES_EAGERLY
RESOLVING_SELF_REFERENCES_EAGERLY
transformer enables eagerly resolution of references to one column from another column within single ExamplesTable ("eagerly" means at the table loading stage). Circular references will result in error.
{transformer=RESOLVING_SELF_REFERENCES_EAGERLY}
|column1|column2 |column3 |
|A |foo<column3>bar|before<column1>after|
FORMATTING
FORMATTING
transformer formats the table according to the max width of each column. Also this transformer removes the commented lines.
{transformer=FORMATTING}
|key|
|value|
|-- |value|
|longValue|
REPLACING
REPLACING
transformer replaces all substrings inside table values with replacement according to the given parameters.
Parameter | Description |
---|---|
|
the sequence of chars to be replaced in the table cells |
|
the replacing sequence of chars |
{transformer=REPLACING, replacing=k, replacement=l}
|key |
|vakue|
SORTING
SORTING
transformer is designed to sort the table rows by the values in
the columns.
Parameter | Description |
---|---|
|
column names ordered according to the priority of applying sorting (the column names are joined using |
|
the optional sorting order: ASCENDING or DESCENDING. By default - ASCENDING. |
|
the optional sorting types ordered according to the column names from the |
{transformer=SORTING, byColumns=key1|key2, order=DESCENDING}
|key1|key2|key3|
|bb |d |1 |
|ba |c |2 |
|bb |b |3 |
|aa |a |4 |
will result in the following ExamplesTable:
|key1|key2|key3|
|bb |d |1 |
|bb |b |3 |
|ba |c |2 |
|aa |a |4 |
{transformer=SORTING, byColumns=key2, order=DESCENDING, sortingTypes=NUMBER}
|key1|key2|
|a |10 |
|b |2.3 |
|c |10.2|
will result in the following ExamplesTable:
|key1|key2|
|c |10.2|
|a |10 |
|b |2.3 |
{transformer=SORTING, byColumns=key2, order=DESCENDING, sortingTypes=STRING}
|key1|key2|
|a |10 |
|b |2.3 |
|c |10.2|
will result in the following ExamplesTable:
|key1|key2|
|b |2.3 |
|c |10.2|
|a |10 |
key1
and NUMBER sorting type for column name key2
. The following transformer:{transformer=SORTING, byColumns=key1|key2, sortingTypes=STRING|NUMBER}
|key1|key2|index|
|a1 |10 |1 |
|a1 |2.3 |2 |
|a2 |10.2|3 |
will result in the following ExamplesTable:
|key1|key2 |index|
|a1 |2.3 |2 |
|a1 |10 |1 |
|a2 |10.2|3 |
{transformer=SORTING, byColumns=key|key1}
|key |key1 |
|value3|value4|
|value1|value2|
ITERATING
ITERATING
transformer generates simple one-column table with header iterator
and numbers as values: 0, 1, 2… .
Parameter | Description |
---|---|
|
value specifying which number to start generating values from, it should be less than or equal to |
|
threshold value specifying at which number to stop generating values, it should be greater than or equal to |
{transformer=ITERATING, startInclusive=0, endInclusive=4}
REPEATING
REPEATING
transformer generates ExamplesTable by copy-pasting the initial table the desired number of times.
Parameter | Description |
---|---|
|
the number of times to copy-paste the initial table |
The following REPEATING
transformer:
{transformer=REPEATING, times=3}
|column1|column2|
|A |C |
|B |D |
will result in the following ExamplesTable:
|column1|column2|
|A |C |
|B |D |
|A |C |
|B |D |
|A |C |
|B |D |
FILTERING
FILTERING
transformer filters the table using the specified parameters.
Parameter | Description | ||
---|---|---|---|
|
The maximum number of columns to keep. If the number of columns in the original table is less than the value specified in this parameter, then all the original table columns are kept. |
||
|
The maximum number of rows to keep. If the number of rows in the original table is less than the value specified in this parameter, then all the original table rows are kept. |
||
|
The number of random rows to keep. If the number of rows in the original table is less than the value specified in this parameter, then all the original table rows are kept. |
||
|
The names of the columns to keep separated by semicolon. |
||
|
The zero-based indexes of the rows to keep, allowing individual indexes and ranges of indexes separated by semicolons. The range of indexes is specified using the hyphen (-) symbol between two indexes (e.g., 0-5). |
||
|
Select rows where the value in the specified column matches the given regex.
|
byMaxColumns and byColumnNames are competing properties and only one can be specified at the same time. The same restriction is applied to the properties byMaxRows , byRandomRows and byRowIndexes .
|
In case if byColumnNames contains nonexistent table columns the exception with list of the invalid columns will be thrown.
|
{transformer=FILTERING, byColumnNames=key1;key3, byMaxRows=1}
|key1 |key2 |key3 |
|value1|value2|value3|
|value4|value5|value6|
{transformer=FILTERING, byMaxColumns=2, byRowIndexes=0;2-4;6}
|key1 |key2 |key3 |
|value1 |value2 |value3 |
|value4 |value5 |value6 |
|value7 |value8 |value9 |
|value10|value11|value12|
|value13|value14|value15|
|value16|value17|value18|
|value19|value20|value21|
will result in the following ExamplesTable:
|key1 |key2 |
|value1 |value2 |
|value7 |value8 |
|value10|value11|
|value13|value14|
|value19|value20|
{transformer=FILTERING, byColumnNames=key2;key3, byRandomRows=2}
|key1 |key2 |key3 |
|value1|value2|value3|
|value4|value5|value6|
|value7|value8|value9|
{transformer=FILTERING, column.sequence=^((?!bbb).)*$}
|sequence |
|aaabbbccc|
|qqqwwwlll|
|bbbfffttt|
|iiioooddd|
|uuuhhhbbb|
in the exampe above we select only those rows that do not contain bbb
string in the sequence
column, as a result we get the following ExamplesTable:
|sequence |
|qqqwwwlll|
|iiioooddd|
DISTINCTING
DISTINCTING
transformer generates ExamplesTable from the specified columns, deleting the rows with repeating values.
Parameter | Default value | Description |
---|---|---|
|
The names of the columns to keep (separated by semicolon). |
|
|
|
If |
This DISTINCTING
transformer:
{transformer=DISTINCTING, byColumnNames=column1;column2}
|column1|column2|column3|
|A |C |0 |
|B |D |1 |
|A |C |1 |
|A |C |0 |
|B |D |1 |
will result in the following ExamplesTable:
|column1|column2|
|A |C |
|B |D |
This DISTINCTING
transformer keeping all columns:
{transformer=DISTINCTING, byColumnNames=column1;column2, keepAllColumns=true}
|column1|column2|column3|
|A |C |0 |
|B |D |1 |
|A |C |1 |
|A |C |0 |
|B |D |0 |
will result in the following ExamplesTable:
|column1|column2|column3|
|A |C |0 |
|B |D |1 |
MERGING
MERGING
transformer merges several tables into one.
Parameter | Description |
---|---|
|
rows or columns |
|
paths to examples tables or transformers to merge |
|
value to fill new cells while merging tables with different number of rows (in |
|
{transformer=MERGING, mergeMode=rows, tables=story/tables/test1.table;story/tables/test2.table}
{transformer=MERGING, mergeMode=columns, tables=story/tables/test1.table;story/tables/test2.table;story/tables/test3.table}
{transformer=MERGING, mergeMode=columns, fillerValue=null, tables=\{transformer=FROM_EXCEL\, path=TestTemplate.xlsx\, sheet=Data\, addresses=A2\;A3\, column=test1\};\{transformer=FROM_EXCEL\, path=TestTemplate.xlsx\, sheet=Data\, range=B2:B4\, column=test2\}}
{
transformer=MERGING,
mergeMode=rows,
fillerValue=null,
tables=
\{
transformer=MERGING\,
mergeMode=columns\,
tables=
\\{
transformer=FROM_EXCEL\\,
path=TestTemplate.xlsx\\,
sheet=Data\\,
addresses=E6\\,
column=text1
\\}
\;
\\{
transformer=FROM_EXCEL\\,
path=TestTemplate.xlsx\\,
sheet=Data\\,
addresses=E7\\,
column=text2
\\}
\}
;
\{
transformer=FROM_EXCEL\,
path=TestTemplate.xlsx\,
sheet=Data\,
addresses=E8\,
column=text1
\}
}
{transformer=MERGING, mergeMode=columns, tables=/data/some-table.table}
|column1|
|value1 |
INDEXING
INDEXING
transformer adds a column with the rows indices in the specified order.
Parameter | Default value | Description |
---|---|---|
|
The indexing order: |
|
|
|
The start index. Negative integer numbers are allowed. |
INDEXING
transformer with ASCENDING
order. The following transformer:{transformer=INDEXING, order=ASCENDING}
|key |
|value1|
|value2|
will result in the following ExamplesTable:
|key |index|
|value1|0 |
|value2|1 |
INDEXING
transformer with DESCENDING
order. The following transformer:{transformer=INDEXING, order=DESCENDING}
|key |
|value1|
|value2|
will result in the following ExamplesTable:
|key |index|
|value1|1 |
|value2|0 |
INDEXING
transformer starting from 1
with ASCENDING
order. The following transformer:{transformer=INDEXING, order=ASCENDING, startIndex=1}
|key |
|value1|
|value2|
will result in the following ExamplesTable:
|key |index|
|value1|1 |
|value2|2 |
JOINING
JOINING
transformer joins values from rows/columns of the table.
Parameter | Description |
---|---|
|
rows or columns |
|
[columns mode only] name of the new column with joined values |
|
[columns mode only] colon-separated list of the columns to join |
JOINING transformer should be the last while joining columns/rows of the table which created using another transformer.
|
columns
join modeScenario: Verify JOINING transformer in default columns mode
Then `<joinedColumn>` is equal to `A B`
Examples:
{transformer=JOINING, joinMode=columns, joinedColumn=joinedColumn}
|column1|column2|
|A |B |
columns
join mode and definition of columns to joinScenario: Verify JOINING transformer in configured columns mode
Then `<joinedColumn>` is equal to `B D`
Examples:
{transformer=JOINING, joinMode=columns, joinedColumn=joinedColumn, columnsToJoin=column2;column4}
|column1|column2|column3|column4|
|A |B |C |D |
rows
join modeScenario: Verify JOINING transformer in default rows mode
Then `<column1>` is equal to `A B`
Then `<column2>` is equal to `C D`
Examples:
{transformer=JOINING, joinMode=rows}
|column1|column2|
|A |C |
|B |D |
{transformer=MERGING, mergeMode=columns, tables=
\{transformer=FROM_EXCEL\, path=/TestTemplate.xlsx\, sheet=Mapping\, range=A4:A5\, column=header1\, joinValues=true\};
\{transformer=FROM_EXCEL\, path=/TestTemplate.xlsx\, sheet=Mapping\, range=B4:B5\, column=header2\, joinValues=true\}
}
{transformer=JOINING, joinMode=columns, joinedColumn=header}
{transformer=JOINING, joinMode=columns, joinedColumn=header}
/test1.table
LEFT_JOIN
The LEFT_JOIN
transformer combines all rows from the left table with matching rows from the right table, and includes rows from the left table even if there are no matches in the right table.
Parameter | Description |
---|---|
|
the column name for matching in the left table |
|
the column name for matching in the right table |
|
ExamplesTable-s to join |
-
left
table is the first ExamplesTable declared intables
parameter, -
right
table is the second ExamplesTable declared intables
parameter or table body put under the transformer definition.
|
{transformer=LEFT_JOIN, leftTableJoinColumn=ID, rightTableJoinColumn=ID, tables=/tables/customers.table;/tables/orders.table}
where ExamplesTable from /tables/customers.table:
|ID|Customer Name|Country |
|1 |Alice |USA |
|2 |Bob |Canada |
|3 |Charlie |UK |
|4 |David |Australia|
|5 |Eva |Germany |
and ExamplesTable from /tables/orders.table:
|ID|Order ID|Order Amount|
|1 |101 |150.00 |
|3 |102 |200.00 |
|5 |103 |250.00 |
|5 |104 |300.00 |
will result in the following ExamplesTable:
|Country |ID|Order Amount|Customer Name|Order ID|
|USA |1 |150.00 |Alice |101 |
|Canada |2 | |Bob | |
|UK |3 |200.00 |Charlie |102 |
|Australia|4 |David | | |
|Germany |5 |250.00 |Eva |103 |
|Germany |5 |300.00 |Eva |104 |
INNER_JOIN
INNER_JOIN
transformer combines rows from two tables whenever there are matching values between the columns.
Parameter | Description |
---|---|
|
the column name for matching in the left table |
|
the column name for matching in the right table |
|
ExamplesTable-s to join |
-
left
table is the first ExamplesTable declared intables
parameter, -
right
table is the second ExamplesTable declared intables
parameter or table body put under the transformer definition.
|
{transformer=INNER_JOIN, leftTableJoinColumn=joinID, rightTableJoinColumn=joinID, tables=/tables/some-table.table}
|joinID|column2|
|5 |row25 |
|3 |row23 |
|1 |row21 |
where ExamplesTable from /tables/some-table.table:
|joinID|column1|
|1 |row11 |
|2 |row12 |
|3 |row13 |
|4 |row14 |
will result in the following ExamplesTable:
|column1|joinID|column2|
|row11 |1 |row21 |
|row13 |3 |row23 |
{transformer=INNER_JOIN, leftTableJoinColumn=joinID, rightTableJoinColumn=joinID, tables=/tables/test1.table;/tables/test2.table}
{transformer=INNER_JOIN, leftTableJoinColumn=joinID1, rightTableJoinColumn=joinID2, tables=/tables/test1.table;/tables/test2.table}
{
transformer=INNER_JOIN,
leftTableJoinColumn=joinID,
rightTableJoinColumn=joinID,
tables=
\{
transformer=FROM_EXCEL\,
path=TestTemplate.xlsx\,
sheet=Data\, addresses=A2\;A3\,
column=joinID
\};
\{
transformer=FROM_EXCEL\,
path=TestTemplate.xlsx\,
sheet=Data\, range=B2:B4\,
column=joinID
\}
}
CARTESIAN_PRODUCT
CARTESIAN_PRODUCT
transformer creates a cartesian product from several tables.
Parameter | Description |
---|---|
|
paths to examples tables or transformers to create a cartesian product |
|
{transformer=CARTESIAN_PRODUCT, tables=story/tables/test1.table;story/tables/test2.table}
{transformer=CARTESIAN_PRODUCT, tables=/data/some-table.table}
|column1|
|value1 |
{transformer=CARTESIAN_PRODUCT, tables=\{transformer=REPEATING\, times=100\};\{transformer=FROM_CSV\, csvPath=/data/csv.csv\}}