Handcrafted TableData

The simplest way to set up a DB state is to use handcrafted reference/table-data TableData. def PRICES = db.table("PRICES") // declare PRICES table PRICES << [ "id" | "description" | "price"] { // append two rows to PRICES ___________________________________ "id1" | "nice set" | 1000 "id2" | "another set" | 2000 }

Semi-Auto Generated TableData

reference/table-data TableData has features like reference/table-data#permutations permute and reference/table-data#guid cell.guid among others. Using them can reduce the effort required to maintain data setup. def PRICES = db.table("PRICES") PRICES << [ "id" | "description" | "available" | "type" | "price" ] { _____________________________________________________________________________________________ cell.guid | "nice set" | true | "card" | 1000 // cell.guid generates random guid that can be used for ids cell.guid | "nice set" | true | "card" | cell.above + 10 // cell.above refers values above and can be modified with simple math operations cell.guid | "another set" | permute(true, false) | permute("rts", "fps") | cell.above + 20 } // permute generates additional rows generating new rows with all the permutations Note: code above assumes WebTauCore.* static import or WebTauGroovyDsl.* static import import static org.testingisdocumenting.webtau.WebTauCore.* ID DESCRIPTION AVAILABLE TYPE PRICE f7352078-3f73-4954-ac03-77b4fba3fbfa nice set true card 1000 5462a55a-feb6-49a2-ac0f-dbbcbcaae96b nice set true card 1010 38000bfd-f683-46dd-95d0-8c6ed42b73e3 another set true rts 1030 2d1411f5-6f53-4b78-bb8f-fb13384ebaca another set false rts 1050 931fccd2-1bcd-4270-909b-0709677ca4e5 another set true fps 1070 c8ceaad4-bff2-4a83-9d67-e3c4ad4bdcd7 another set false fps 1090

External File TableData

def PRICES = db.table("PRICES") PRICES << data.csv.table('prices-db.csv') id, description, available, type, price id1, description1, true, card, 200 id2, description2, false, rts, 400 ID DESCRIPTION AVAILABLE TYPE PRICE id1 description1 true card 200 id2 description2 false rts 400

Cleaning Tables

db.update("delete from PRICES where price > :price", [price: 950])

Updating Tables

ID DESCRIPTION AVAILABLE TYPE PRICE id1 nice set 1000 id2 another set 2000 db.update("update PRICES set price=:price where id=:id", [id: 'id2', price: 4000]) ID DESCRIPTION AVAILABLE TYPE PRICE id1 nice set 1000 id2 another set 4000