Create

Use language specific DSL to create TableData instance: Groovy ["Col A" | "Col B" | "Col C"] { ________________________________ "v1a" | "v1b" | "v1c" "v2a" | "v2b" | "v2c" } Java table("Col A", "Col B", "Col C", ________________________________, "v1a", "v1b", "v1c", "v2a", "v2b", "v2c") Note: The example above assumes import static org.testingisdocumenting.webtau.WebTauCore.* or import static org.testingisdocumenting.webtau.WebTauDsl.* . Additionally WebTauCore has header-separating lines defined using underscores ___ of various lengths, which you can optionally use for aesthetics. Using ____ underscore is optional and is there for aesthetics only Groovy ["Col A" | "Col B" | "Col C"] { "v1a" | "v1b" | "v1c" "v2a" | "v2b" | "v2c" } Java table("Col A", "Col B", "Col C").values( "v1a", "v1b", "v1c", "v2a", "v2b", "v2c")

Key Columns

Use * in front of a column to specify it as a key column Groovy ["*id" | "Name" | "Type"] { ___________________________ "id1" | "N" | "T" "id2" | "N2" | "T2" "id3" | "N" | "T" } Java table("*id" , "Name" , "Type", _______________________, "id1" , "N" , "T", "id2" , "N2" , "T2", "id3" , "N" , "T") To access a value by key column Groovy def found = tableData.findByKey("id2") found.Name.should == "N2" Java Record found = tableData.findByKey("id2"); String name = found.get("Name"); actual(name).should(equal("N2")); To change key columns of an existing table Groovy tableData.withNewKeyColumns("Name", "Type") Java tableData.withNewKeyColumns("Name", "Type") Note: withNewKeyColumns creates new table and validates new key column uniqueness

Create From List

Use to create TableData from a list of maps. Groovy def list = [ [k1: "v1", k2: "v2"], [k1: "v3", k3: "v4"]] TableData tableData = TableData.fromListOfMaps(list) TableData expected = ["k1" | "k2" | "k3"] { ____________________ "v1" | "v2" | null "v3" | null | "v4" } tableData.should == expected Java List<Map<String, ?>> list = new ArrayList<>(); list.add(CollectionUtils.map("k1", "v1", "k2", "v2")); list.add(CollectionUtils.map("k1", "v3", "k3", "v4")); TableData tableData = TableData.fromListOfMaps(list); TableData expected = table("k1", "k2", "k3", _________________, "v1", "v2", null, "v3", null, "v4"); actual(tableData).should(equal(expected)); Note: WebTau merges keys from all list elements to create the table header

Create From Existing Rows

Use to create TableData from existing rows. Groovy def table = ["*id" | "description"] { __________________________ "id1" | "description one" "id2" | "description two" "id3" | "description three" } def newTable = table.fromRowsByKeys("id1", "id3") newTable.should == ["*id" | "description"] { __________________________ "id1" | "description one" "id3" | "description three" } def table = ["*id1" | "*id2" | "description"] { _____________________________________ "id11" | "id21" | "description one" "id21" | "id22" | "description two" "id31" | "id32" | "description three" } def newTable = table.fromRowsByKeys(key("id11", "id21"), key("id31", "id32")) newTable.should == ["*id1" | "*id2" | "description"] { _____________________________________ "id11" | "id21" | "description one" "id31" | "id32" | "description three" } Java TableData table = table("*id", "description", __________________________, "id1", "description one", "id2", "description two", "id3", "description three"); TableData newTable = table.fromRowsByKeys("id1", "id3"); actual(newTable).should(equal(table("*id", "description", __________________________, "id1", "description one", "id3", "description three"))); TableData table = table("*id1", "*id2", "description", ____________________________________, "id11", "id12", "description one", "id21", "id22", "description two", "id31", "id32", "description three"); TableData newTable = table.fromRowsByKeys(key("id11", "id12"), key("id31", "id32")); actual(newTable).should(equal(table("*id1", "*id2", "description", ____________________________________, "id11", "id12", "description one", "id31", "id32", "description three")));

Serialization

Use to serialize as JSON System.out.println(tableData.toJson()); [ { "A" : 1.3, "B" : 2 }, { "A" : "Hello", "B" : "World" } ] Use to serialize as CSV System.out.println(tableData.toCsv()); A,B 1.3,2 Hello,World

Serialization To File

Use data/csv#write-table data.csv.write and data/json#write-table-data data.json.write to serialize Table Data to a file

Permutations

Use permute(v1, v2) to automatically generate multiple rows. Groovy ["Col A" | "Col B" | "Col C"] { ___________________________________________________________ permute(true, false) | "v1b" | permute('a', 'b') "v2a" | permute(10, 20) | "v2c" } Java table("Col A" , "Col B" , "Col C", ________________________________________________________________, permute(true, false), "v1b" , permute('a', 'b'), "v2a" , permute(10, 20) , "v2c") Col A Col B Col C true v1b a false v1b a true v1b b false v1b b v2a 10 v2c v2a 20 v2c

GUID

Use cell.guid to automatically generate unique ids. Groovy ["ID" | "Col A" | "Col B" | "Col C"] { ________________________________________________________________________ cell.guid | permute(true, false) | "v1b" | permute('a', 'b') cell.guid | "v2a" | permute(10, 20) | "v2c" } Java table("ID" , "Col A" , "Col B" , "Col C", ______________________________________________________________________, cell.guid, permute(true, false), "v1b" , permute('a', 'b'), cell.guid, "v2a" , permute(10, 20) , "v2c") ID Col A Col B Col C d4af892a-8ebb-48cf-83f8-d163de199a71 true v1b a 8af21d35-94c4-4e83-ae71-092d70f326ee false v1b a 00dafdfc-78e1-4642-906e-f239afb66182 true v1b b f17451ba-2d15-4512-b876-08783522c4f4 false v1b b c50210c1-4000-4e8f-8dca-74ac53887138 v2a 10 v2c 1bd73640-7ab2-42f7-b466-91921904f877 v2a 20 v2c

Replace

Use table.replace(before, after) to replace values in a table. Groovy ["Col A" | "Col B" | "Col C"] { ________________________________ "v1a" | "v1b" | "v1c" "v2a" | "v2b" | "v2c" } tableData.replace("v1b", "v1b_") Java table("Col A", "Col B", "Col C", ________________________________, "v1a", "v1b", "v1c", "v2a", "v2b", "v2c") tableData.replace("v1b", "v1b_") Col A Col B Col C v1a v1b_ v1c v2a v2b v2c

Cell Above Value Reference

Use cell.above to refer to the previous row value Groovy ["Name" | "Start Date" | "Games To Play" ] { ______________________________________________________ "John" | LocalDate.of(2016, 6, 20) | 10 "Bob" | cell.above | 8 "Mike" | cell.above | 14 "Drew" | LocalDate.of(2016, 6, 22) | 10 "Pete" | cell.above | 11 "Max" | cell.above | 3 } Java table("Name", "Start Date" , "Games To Play", __________________________________________________, "John", LocalDate.of(2016, 6, 20), 10, "Bob" , cell.above , 8, "Mike", cell.above , 14, "Drew", LocalDate.of(2016, 6, 22), 10, "Pete", cell.above , 11, "Max" , cell.above , 3) Name Start Date Games To Play John 2016-06-20 10 Bob 2016-06-20 8 Mike 2016-06-20 14 Drew 2016-06-22 10 Pete 2016-06-22 11 Max 2016-06-22 3

Cell Above Math

Use cell.above.plus|minus to generate a derived value based on the previous row value Groovy ["Name" | "Start Date" | "Games To Play" ] { ______________________________________________________ "John" | LocalDate.of(2016, 6, 20) | 10 "Bob" | cell.above | cell.above + 1 "Mike" | cell.above | cell.above + 1 } Java table("Name", "Start Date" , "Games To Play", ________________________________________________________________, "John", LocalDate.of(2016, 6, 20), 10, "Bob" , cell.above , cell.above.plus(1), "Mike", cell.above , cell.above.plus(1)) Name Start Date Games To Play John 2016-06-20 10 Bob 2016-06-20 11 Mike 2016-06-20 12 Extract cell.above.operation to make your intentions clearer Groovy def increment = cell.above + 1 ["Name" | "Start Date" | "Games To Play" ] { ______________________________________________________ "John" | LocalDate.of(2016, 6, 20) | 10 "Bob" | cell.above | increment "Mike" | cell.above | increment } Java TableDataCellValueGenerator<?> increment = cell.above.plus(1) table("Name", "Start Date" , "Games To Play", ________________________________________________________________, "John", LocalDate.of(2016, 6, 20), 10, "Bob" , cell.above , increment, "Mike", cell.above , increment)