-1

I am using jdbc call in ready api and running a describe query to get the columns and respective data types, how can I assert these columns and data types with the expected columns and data types?

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
peter
  • 391
  • 1
  • 4
  • 17

1 Answers1

0

Assuming you're using MySQL, a DESCRIBE query will return a XML that looks like this :

<Results>
    <ResultSet fetchSize="0">
        <Row rowNumber="1">
            <COLUMNS.COLUMN_NAME>id</COLUMNS.COLUMN_NAME>
            <COLUMNS.COLUMN_TYPE>bigint(20)</COLUMNS.COLUMN_TYPE>
            <COLUMNS.IS_NULLABLE>NO</COLUMNS.IS_NULLABLE>
            <COLUMNS.COLUMN_KEY>PRI</COLUMNS.COLUMN_KEY>
            <COLUMNS.COLUMN_DEFAULT/>
            <COLUMNS.EXTRA>auto_increment</COLUMNS.EXTRA>
        </Row>
        ...`

If you want to test that column 'id' is a bigint(20), you should add a XPath Match assertion with the following XPath Expression : //ResultSet/Row/COLUMNS.COLUMN_NAME[text()='id']/following-sibling::COLUMNS.COLUMN_TYPE With expected result being 'bigint(20)'

Tom
  • 106
  • 4