Interface SqlGet
- All Known Implementing Classes:
CustomDb,JdbcExecutor,MariaDb,MsSQL,MySQL,OracleDb,PostgreSQL
public interface SqlGet
Defines operations for executing SQL SELECT queries.
Implementations of this interface are responsible for performing read-only database operations that retrieve data without modifying the database state, such as get data for asserts or reports.
This interface should contain only non-mutating operations.
All data-changing SQL commands must be handled by SqlPost.
-
Method Summary
Modifier and TypeMethodDescriptionvoidseeRecordExistsInTable(String tableName, Object[][] conditionsArray) Asserts that the table has at least one record by conditions (in an Object[][] array).voidseeRecordExistsInTable(String tableName, String providedJson) Asserts that the table has at least one record by conditions (in a JSON string).voidseeRecordExistsInTableCustom(String tableName, String conditions) Asserts that the table has at least one record by conditions (hardcoded SQL condition string).voidseeRowsCountInTableExactly(String tableName, int expectedCount) Asserts that the table contains exactly the expected number of records.voidseeRowsCountInTableExactly(String tableName, Object[][] conditionsArray, int expectedCount) Asserts that the table contains exactly the expected number of records matching the specified conditions (in an Object[][] array).voidseeRowsCountInTableExactly(String tableName, String providedJson, int expectedCount) Asserts that the table contains exactly the expected number of records matching the specified conditions (in a JSON string).voidseeRowsCountInTableExactlyCustom(String tableName, String conditions, int expectedCount) Asserts that the table contains exactly the expected number of records matching the specified conditions (hardcoded SQL conditions string).voidseeTableIsEmpty(String tableName) Asserts that the table has no records.voidseeTableIsNotEmpty(String tableName) Asserts that the table is not empty.voidshowDataByCondition(String tableName, Object[][] conditionsArray) Creates an attachment containing all records matching the specified conditions.voidshowDataFromTable(String tableName) /** Creates an attachment containing all records and columns from the table.
-
Method Details
-
seeRowsCountInTableExactly
Asserts that the table contains exactly the expected number of records matching the specified conditions (in an Object[][] array).Uses await.
for example:
db.seeRowsCountInTableExactly("test.users", new Object[][]{ {"name", "Alex"}, {"id", ">=", 2} }, 1);- Parameters:
tableName- table name in the formatschema_name.table_nameconditionsArray- conditions in Object[][] format support up to 2 options after field (column, condition, date, oracle-enum)
{"COLUMN NAME", ">= ", "2020-01-01", "DATE"}for oracleexpectedCount- expected rows count- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)QueryBuilderException- if failed to convert Object[][]
-
seeRowsCountInTableExactlyCustom
Asserts that the table contains exactly the expected number of records matching the specified conditions (hardcoded SQL conditions string).Uses await.
for example:
db.seeRowsCountInTableExactly("test.users", "where id=1", 1);- Parameters:
tableName- table name in the formatschema_name.table_nameconditions- hardcoded SQL conditions stringfor example:
"where id=1"expectedCount- expected rows count- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeRowsCountInTableExactly
Asserts that the table contains exactly the expected number of records.Uses await.
- Parameters:
tableName- table name in the formatschema_name.table_nameexpectedCount- expected rows count- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeRowsCountInTableExactly
Asserts that the table contains exactly the expected number of records matching the specified conditions (in a JSON string).Uses await.
for example:
db.seeRowsCountInTableExactly("test.users", """ { "name": "Alex", "id:>": 2 }"""), 1;- Parameters:
tableName- table name in the formatschema_name.table_nameprovidedJson- conditions in JSON format support up to 2 options in key after field (column:condition:oracle-enum)
"CREATE_DATE:>="
"CREATE_DATE:=:TIMESTAMP"(for oracleDd)expectedCount- expected rows count- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)QueryBuilderException- if failed to convert JSON
-
seeTableIsEmpty
Asserts that the table has no records.Uses await.
- Parameters:
tableName- table name in the formatschema_name.table_name- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeTableIsNotEmpty
Asserts that the table is not empty.Uses await.
- Parameters:
tableName- table name in the formatschema_name.table_name- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeRecordExistsInTable
Asserts that the table has at least one record by conditions (in an Object[][] array).Uses await.
for example:
db.seeRecordExistsInTable("test.users", new Object[][]{ {"name", "Alex"}, {"id", ">=", 2} });- Parameters:
tableName- table name in the formatschema_name.table_nameconditionsArray- conditions in Object[][] format support up to 2 options after field (column, condition, date, oracle-enum)
{"COLUMN NAME", ">= ", "2020-01-01", "DATE"}for oracle- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeRecordExistsInTable
Asserts that the table has at least one record by conditions (in a JSON string).Uses await.
for example:
db.seeRecordExistsInTable("test.users", """ { "name": "Alex", "id:>": 2 }""");- Parameters:
tableName- table name in the formatschema_name.table_nameprovidedJson- conditions in JSON format support up to 2 options in key after field (column:condition:oracle-enum)
"CREATE_DATE:>="
"CREATE_DATE:=:TIMESTAMP"(for oracleDd)- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
seeRecordExistsInTableCustom
Asserts that the table has at least one record by conditions (hardcoded SQL condition string).Uses await.
for example:
db.seeRecordExistsInTableCustom("test.users", "where id=1");- Parameters:
tableName- table name in the formatschema_name.table_nameconditions- hardcoded SQL condition stringfor example:
"where id=1"- Throws:
AssertionError- if the assertion fails (and adds Allure attachments)
-
showDataFromTable
/** Creates an attachment containing all records and columns from the table.- Parameters:
tableName- table name in the formatschema_name.table_name
-
showDataByCondition
Creates an attachment containing all records matching the specified conditions.db.showDataByCondition("test.users", new Object[][]{ {"ID", 1}, {"NAME", "Alex"} });- Parameters:
tableName- table name in the formatschema_name.table_nameconditionsArray- conditions in the format{{"ID", "1"}, {"NAME", "Alex"}}- Throws:
AssertionError- if no records are found matching the specified conditions
-