Skip to content

Enhance Test Coverage in Test Suite issue solution - #52

Open
CBHeithoff wants to merge 4 commits into
abhi9720:mainfrom
CBHeithoff:issue-2-test-coverage
Open

Enhance Test Coverage in Test Suite issue solution #52
CBHeithoff wants to merge 4 commits into
abhi9720:mainfrom
CBHeithoff:issue-2-test-coverage

Conversation

@CBHeithoff

Copy link
Copy Markdown

Solution for Git Issue Enhance Test Coverage in Test Suite #29

This PR adds comprehensive unit tests for two previously untested areas of the codebase: TransactionService and ValidationUtil.

New test classes (41 new tests, all passing):

  • TransactionServiceTests — covers getAllTransactionsByAccountNumber (empty account, after deposit, after deposit+withdrawal, fund transfer source/target tracking, transaction type
    verification, descending date sort order, source account field) and sendBankStatementByEmail (null, empty, and blank account number validation)
  • ValidationUtilTests — covers isValidEmail, isValidAccountNumber (6-char boundary, null), isValidCountryCode, all branches of validatePassword (length, whitespace, missing
    uppercase/lowercase/digit/special char), validateUserDetailsNotEmpty (null user, missing fields), and doesAccountExist/doesEmailExist/doesPhoneNumberExist

Supporting testing infrastructure:

  • Added H2 in-memory database as a test-scoped dependency so tests run without requiring a local MySQL instance
  • Added src/test/resources/application-test.properties to provide the Spring test context configuration
  • Updated .gitignore to allow application-test.properties to be tracked

@gitguardian

gitguardian Bot commented May 7, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - Generic Password 9e36464 src/test/java/com/webapp/bankingportal/ValidationUtilTests.java View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Issue #29 by expanding the automated test suite around previously untested areas, and by adding a dedicated Spring Boot test configuration to run tests against an in-memory database rather than requiring a local MySQL instance.

Changes:

  • Added new Spring Boot integration tests for TransactionService and ValidationUtil (41 tests total).
  • Introduced application-test.properties for test-only configuration (H2, JWT/mail/redis placeholders, logging).
  • Added H2 as a test dependency and updated .gitignore to allow application-test.properties to be committed.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/test/resources/application-test.properties Adds test-scoped Spring configuration (H2 in-memory DB + supporting properties).
src/test/java/com/webapp/bankingportal/ValidationUtilTests.java Adds coverage for ValidationUtil static validations and repository-backed existence checks.
src/test/java/com/webapp/bankingportal/TransactionServiceTests.java Adds coverage for transaction retrieval scenarios and bank-statement input validation.
pom.xml Adds H2 dependency scoped to tests to avoid MySQL requirement during test runs.
.gitignore Ensures application-test.properties is not ignored so CI/test runs have consistent config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

spring.datasource.password=

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.generate-ddl=true
Comment on lines +119 to +135
@Test
public void test_send_bank_statement_with_null_account_number() {
Assertions.assertThrows(IllegalArgumentException.class, () ->
transactionService.sendBankStatementByEmail(null));
}

@Test
public void test_send_bank_statement_with_empty_account_number() {
Assertions.assertThrows(IllegalArgumentException.class, () ->
transactionService.sendBankStatementByEmail(""));
}

@Test
public void test_send_bank_statement_with_blank_account_number() {
Assertions.assertThrows(IllegalArgumentException.class, () ->
transactionService.sendBankStatementByEmail(" "));
}
Comment on lines +138 to +139
public void test_send_bank_statement_with_nonexistent_account_returns_silently() {
Assertions.assertDoesNotThrow(() ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants