Package net.bugreaper.modules.db
Class CustomDb
CustomDb helper that provides a common API for operating with SQL-database that is not yet fully supported.
It is recommended to use a single instance:
CustomDb db = CustomDb.getInstance();
- Get all data for allure on failed not supported
- Get data all data by conditions not supported
- Get data all data from table not supported
- Specific conditions(JSON_*, REGEX) not supported (only basic conditions)
Provides:
- Assertions with await support
- Data manipulation operations such as create, update, and clean
For more information, see JdbcExecutor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDefault await polling interval in milliseconds for tests.protected static final Stringprotected booleanEnables enhanced reporting with full table data attached to Allure and actual column values included in assertion exceptions.protected Stringprotected JdbcDirectivesHikariprotected Stringprotected static final Stringprotected Stringprotected String -
Constructor Summary
ConstructorsConstructorDescriptionCustomDb()Constructs a CustomDb client for a database that is not yet fully supported, using YAML configuration.Constructs a CustomDb client for a database that is not yet fully supported, using YAML configuration.Creates a new Custom database helper instance with the specified connection parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertCountInTableBuilder(String tableName, String conditions, Object[][] conditionsArray, String expectedCount, int providedAwaitMs) static CustomDbReturns the instance ofCustomDbwith config builderCustomDb().static CustomDbgetInstance(String suffix) Returns a uniqueCustomDbhelper instance for the specified suffix using YAML configuration.protected String[]getTableColumns(String tableName) Returns the list of columns in the table.protected voidrecordExistsBuilder(String tableName, String conditions, Object[][] conditionsArray, int providedAwaitMs) protected voidseeInDbByCondMethod(String tableName, String conditions) protected voidshowDataFromTableMethod(String tableName) Methods inherited from class net.bugreaper.modules.db.jdbc.JdbcExecutor
deleteFromTable, deleteFromTable, deleteFromTable, getConfigSummary, insertIntoTable, insertIntoTable, insertIntoTable, renameTable, rollbackTable, runScript, runScriptFromFile, seeRecordExistsInTable, seeRecordExistsInTable, seeRecordExistsInTableCustom, seeRowsCountInTableExactly, seeRowsCountInTableExactly, seeRowsCountInTableExactly, seeRowsCountInTableExactlyCustom, seeTableIsEmpty, seeTableIsNotEmpty, self, setAwaitMs, setEnchantedReport, setTemplatesDirectory, showDataByCondition, showDataFromTable, truncateTable, truncateTables, updateTable, updateTable, updateTable, withAwaitMs
-
Field Details
-
jdbc
-
getColumnsQuery
-
url
-
username
-
password
-
SELECT_ALL
- See Also:
-
COUNT
- See Also:
-
awaitPollInterval
protected volatile int awaitPollIntervalDefault await polling interval in milliseconds for tests. -
enableEnchantedReport
protected volatile boolean enableEnchantedReportEnables enhanced reporting with full table data attached to Allure and actual column values included in assertion exceptions.
-
-
Constructor Details
-
CustomDb
Creates a new Custom database helper instance with the specified connection parameters.- Parameters:
dbUrl- the JDBC connection URL for the Custom databaseusername- the username used to authenticate with the databasepasswd- the password used to authenticate with the database- Throws:
IllegalArgumentException- if any of the required parameters are null or empty
-
CustomDb
public CustomDb()Constructs a CustomDb client for a database that is not yet fully supported, using YAML configuration.Loads configuration values from a YAML file.
Example:CustomDb db = new CustomDb();modules: db: custom-db: # reserved type url: 'jdbc:mysql://localhost:3308' username: user password: pass await: 1000 (optional) enchanted-report: true # (optional)- See Also:
-
CustomDb
Constructs a CustomDb client for a database that is not yet fully supported, using YAML configuration.Loads configuration values from a YAML file.
Example:CustomDb db = new CustomDb("-mydb");modules: db: custom-db-mydb: # reserved type url: 'jdbc:mysql://localhost:3308' username: user password: pass await: 1000 (optional) enchanted-report: true # (optional)- Parameters:
suffix- concatenation of CustomDb client (example CustomDb("-mydb") keys will be "modules.db.custom-db-mydb")- See Also:
-
-
Method Details
-
getInstance
Returns the instance ofCustomDbwith config builderCustomDb().This implementation is thread-safe using method-level synchronization.
- Returns:
- the shared instance of
CustomDb - Throws:
IllegalArgumentException- if the configuration contains invalid values- See Also:
-
getInstance
Returns a uniqueCustomDbhelper instance for the specified suffix using YAML configuration.This method implements the Multiton pattern. A separate singleton instance is created for each CustomDb. Subsequent calls with the same suffix return the already created instance.
- Returns:
- unique
CustomDbinstance associated with the specified Redis data type - Throws:
IllegalArgumentException- if the configuration contains invalid values- See Also:
-
assertCountInTableBuilder
-
recordExistsBuilder
-
showDataFromTableMethod
-
seeInDbByCondMethod
-
getTableColumns
Returns the list of columns in the table.- Parameters:
tableName- table name in the formatschema_name.table_name- Returns:
- array containing column names
-