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 Type
    Method
    Description
    void
    seeRecordExistsInTable(String tableName, Object[][] conditionsArray)
    Asserts that the table has at least one record by conditions (in an Object[][] array).
    void
    seeRecordExistsInTable(String tableName, String providedJson)
    Asserts that the table has at least one record by conditions (in a JSON string).
    void
    seeRecordExistsInTableCustom(String tableName, String conditions)
    Asserts that the table has at least one record by conditions (hardcoded SQL condition string).
    void
    seeRowsCountInTableExactly(String tableName, int expectedCount)
    Asserts that the table contains exactly the expected number of records.
    void
    seeRowsCountInTableExactly(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).
    void
    seeRowsCountInTableExactly(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).
    void
    seeRowsCountInTableExactlyCustom(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).
    void
    Asserts that the table has no records.
    void
    Asserts that the table is not empty.
    void
    showDataByCondition(String tableName, Object[][] conditionsArray)
    Creates an attachment containing all records matching the specified conditions.
    void
    /** Creates an attachment containing all records and columns from the table.
  • Method Details

    • seeRowsCountInTableExactly

      void seeRowsCountInTableExactly(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).

      Uses await.

      for example:

      
       db.seeRowsCountInTableExactly("test.users", new Object[][]{
            {"name", "Alex"},
            {"id", ">=", 2}
       }, 1);
      Parameters:
      tableName - table name in the format schema_name.table_name
      conditionsArray - conditions in Object[][] format support up to 2 options after field (column, condition, date, oracle-enum)
      {"COLUMN NAME", ">= ", "2020-01-01", "DATE"} for oracle
      expectedCount - expected rows count
      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
      QueryBuilderException - if failed to convert Object[][]
    • seeRowsCountInTableExactlyCustom

      void seeRowsCountInTableExactlyCustom(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).

      Uses await.

      for example:

      
       db.seeRowsCountInTableExactly("test.users", "where id=1", 1);
      Parameters:
      tableName - table name in the format schema_name.table_name
      conditions - hardcoded SQL conditions string

      for example: "where id=1"

      expectedCount - expected rows count
      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
    • seeRowsCountInTableExactly

      void seeRowsCountInTableExactly(String tableName, int expectedCount)
      Asserts that the table contains exactly the expected number of records.

      Uses await.

      Parameters:
      tableName - table name in the format schema_name.table_name
      expectedCount - expected rows count
      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
    • seeRowsCountInTableExactly

      void seeRowsCountInTableExactly(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).

      Uses await.

      for example:

      
       db.seeRowsCountInTableExactly("test.users",
            """
            {
                "name": "Alex",
                "id:>": 2
            }"""), 1;
      Parameters:
      tableName - table name in the format schema_name.table_name
      providedJson - 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

      void seeTableIsEmpty(String tableName)
      Asserts that the table has no records.

      Uses await.

      Parameters:
      tableName - table name in the format schema_name.table_name
      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
    • seeTableIsNotEmpty

      void seeTableIsNotEmpty(String tableName)
      Asserts that the table is not empty.

      Uses await.

      Parameters:
      tableName - table name in the format schema_name.table_name
      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
    • seeRecordExistsInTable

      void seeRecordExistsInTable(String tableName, Object[][] conditionsArray)
      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 format schema_name.table_name
      conditionsArray - 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

      void seeRecordExistsInTable(String tableName, String providedJson)
      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 format schema_name.table_name
      providedJson - 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

      void seeRecordExistsInTableCustom(String tableName, String conditions)
      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 format schema_name.table_name
      conditions - hardcoded SQL condition string

      for example: "where id=1"

      Throws:
      AssertionError - if the assertion fails (and adds Allure attachments)
    • showDataFromTable

      void showDataFromTable(String tableName)
      /** Creates an attachment containing all records and columns from the table.
      Parameters:
      tableName - table name in the format schema_name.table_name
    • showDataByCondition

      void showDataByCondition(String tableName, Object[][] conditionsArray)
      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 format schema_name.table_name
      conditionsArray - conditions in the format {{"ID", "1"}, {"NAME", "Alex"}}
      Throws:
      AssertionError - if no records are found matching the specified conditions