Introduction

Currently, ATS database operations are possible for ATS supports Oracle, MySQL, MSSQL(Microsoft SQL Server)Cassandra and PostgreSQL

This page shows how to verify some data is present or not into some table cell following the logic of Rule Based Verifications


PostgreSQL notes

When you are verifying a value from a PostgreSQL database:

  1. The format of the column name must be <TABLE_NAME>.<COLUMN_NAME>
  2. If the table name or the column name is not lower-case only, they must be enclosed in double quotes.

Example:

...

dbVerification.checkFieldValueContains( "\"Table1\"", "Table1.column1", "How old" ); // only then using PostgreSQL
dbVerification.checkFieldValueContains( "Table1", "column1", "How old" ); // when using MySql, Oracle, etc

...




Constructing the verification object

In order to create the verification object, you need to pass the DB connection parameters and the table to work with.

You can do it this way:

import com.axway.ats.rbv.clients.DbVerification;
 
TestBox serverBox = new TestBox();
serverBox.setHost( SERVER_IP );
serverBox.setDbType( "ORACLE" );
serverBox.setDbName( DATABASE_NAME );
serverBox.setDbUser( USER_NAME );
serverBox.setDbPass( USER_PASSWORD );

DbVerification dbVerification = new DbVerification( serverBox, "Table1" );

which will actually run "SELECT * FROM Table1".

Or you can do it this way:

DbVerification dbVerification = new DbVerification( serverBox, new DbSearchTerm( "SELECT * FROM Table1 WHERE id = 1" ) );

In this case, you can use some complex SELECT query. As you see you can add a WHERE clause or you could establish joins between tables.

The next step is the definition of the expected return result set.



Add verification rules

Using the different check... methods you can add as many checks as you need

dbVerification.checkFieldValueContains( "Table1", "column1", "How old" );

dbVerification.checkFieldValueRegex( "Table1", "column1", ".*are you.*" );

dbVerification.checkFieldValueEquals( "Table1", "column2", "20" );

So far we have just specified the data we are interested in.

But the actual verification starts at the moment one of the verify... methods is called.

The list of supported methods is constantly growing. Look up the code or javadoc for the whole list.



Verify DB data exists

Keep polling until there is verification that the searched data is present.

Fail if the searched data is not found for all polling attempts.

dbVerification.verifyDbDataExists();



Verify DB data does not exist

Keep polling until there is verification that the searched data is NOT present.

Fail if the searched file is present for all polling attempts.

dbVerification.verifyDbDataDoesNotExist();



Verify DB data always exists

The next code will succeed if the searched data is present for all polling attempts otherwise it will fail.


dbVerification.verifyDbDataAlwaysExists();



Verify DB data never exists

The next code will succeed if the searched data is NOT present for all polling attempts otherwise it will fail.

dbVerification.verifyDbDataNeverExists();



Back to parent page

Go to Table of Contents