Class PostgreSQL

All Implemented Interfaces:
SqlConfig<PostgreSQL>, SqlGet, SqlPost

public class PostgreSQL extends JdbcExecutor<PostgreSQL>
Class for interacting with PostgreSQL

For one instance run recommended: PostgreSQL db = PostgreSQL.getInstance()

Contains methods for:

asserts with await, change data (create, update, clean)
more info JdbcExecutor
  • Field Details

  • Constructor Details

    • PostgreSQL

      public PostgreSQL(String dbUrl, String username, String passwd)
      Creates a new PostgreSQL database helper instance with the specified connection parameters.
      Parameters:
      dbUrl - the JDBC connection URL for the PostgreSQL database
      username - the username used to authenticate with the database
      passwd - the password used to authenticate with the database
      Throws:
      IllegalArgumentException - if any of the required parameters are null or empty
    • PostgreSQL

      public PostgreSQL()
      Constructs PostgreSQL client configuration.

      Loads configuration values from a YAML file.

      more info JdbcExecutor(String dbType, String getColumnsQuery)
  • Method Details

    • getInstance

      public static PostgreSQL getInstance()
      Returns the singleton instance of PostgreSQL with config builder PostgreSQL().

      This implementation is thread-safe using method-level synchronization.

      Returns:
      the singleton instance of PostgreSQL
    • truncateTableCascade

      @Step("Truncate table {tableName} CASCADE") public void truncateTableCascade(String tableName)
      Truncate(clean) table and all connected by foreign keys tables
      Parameters:
      tableName - schema_name.table_name
    • renameTable

      @Step("Rename table {tableName}") public void renameTable(String tableName)
      Description copied from interface: SqlPost
      Rename table(add suffix "_X_")

      Note: After test rollback with SqlPost.rollbackTable(java.lang.String).

      Specified by:
      renameTable in interface SqlPost
      Overrides:
      renameTable in class JdbcExecutor<PostgreSQL>
      Parameters:
      tableName - schema_name.table_name
    • rollbackTable

      @Step("Rollback table {tableName}") public void rollbackTable(String tableName)
      Description copied from interface: SqlPost
      Rollback table(remove suffix "_X_") after SqlPost.renameTable(java.lang.String)
      Specified by:
      rollbackTable in interface SqlPost
      Overrides:
      rollbackTable in class JdbcExecutor<PostgreSQL>
      Parameters:
      tableName - schema_name.table_name
    • assertCountInTableBuilder

      @Step("(DB)[ASSERT] Count records in {tableName} {conditions} EQUAL {expectedCount}") protected void assertCountInTableBuilder(String tableName, String conditions, @Param(mode=HIDDEN) Object[][] conditionsArray, String expectedCount, @Param(mode=HIDDEN) int awaitMs)
    • recordExistsBuilder

      @Step("(DB)[ASSERT] Record/s exists in {tableName} {conditions}") protected void recordExistsBuilder(String tableName, String conditions, @Param(mode=HIDDEN) Object[][] conditionsArray, @Param(mode=HIDDEN) int awaitMs)
    • showDataFromTableMethod

      protected void showDataFromTableMethod(String tableName)
    • seeInDbByCondMethod

      @Step("(DB)[ASSERT] Records exists in {tableName}: {conditions}") protected void seeInDbByCondMethod(String tableName, String conditions)
    • getTableColumns

      protected String[] getTableColumns(String tableName)
      Get array with table column list
      Parameters:
      tableName - table name
      Returns:
      Strings... with columns names