Skip to content

Feature/improve jmf rules by adding unit tests#79

Open
miroslavpojer wants to merge 3 commits intomasterfrom
feature/improve-jmf-rules-by-adding-unit-tests
Open

Feature/improve jmf rules by adding unit tests#79
miroslavpojer wants to merge 3 commits intomasterfrom
feature/improve-jmf-rules-by-adding-unit-tests

Conversation

@miroslavpojer
Copy link
Copy Markdown
Collaborator

@miroslavpojer miroslavpojer commented Apr 7, 2026

Overview

testing/classes/ had no counterpart in src/main, JMF was flagging trivially untestable methods as coverage gaps, and .github/copilot-instructions.md still referenced Python tooling.

This PR restructures the shared test traits to the root test package, adds unit and integration tests for QueryResult, tightens JMF rules with 9 project-specific entries, and migrates the Copilot instructions to Scala/sbt.

Release Notes

  • Moved DBTestingConnection and new MockResultSets stub trait from testing/classes/ to root test package za.co.absa.db.balta
  • Added QueryResultUnitTests (10 tests, no DB) and QueryResultIntegrationTests (split from QueryResultRowIntegrationTests)
  • Added 9 project-specific JMF rules for deprecated delegates, factory wrappers, label-overloads, and trivial accessors
  • Migrated .github/copilot-instructions.md and .github/copilot-review-rules.md from Python to Scala/sbt

Related

Closes #78

Summary by CodeRabbit

  • Tests

    • Added unit tests for query result iteration, exception handling, and metadata validation.
    • Added integration tests for query result functionality.
    • Added mock JDBC utilities for isolated unit testing.
  • Bug Fixes

    • Fixed resource cleanup in test database utilities.
  • Chores

    • Established standardized development guidelines and code review standards.
    • Updated test infrastructure configurations and code coverage rules.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Warning

Rate limit exceeded

@miroslavpojer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 9 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 9 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebe8cd85-40e9-4852-aa7e-9f089961890a

📥 Commits

Reviewing files that changed from the base of the PR and between 3c552dc and 8ca8285.

📒 Files selected for processing (2)
  • .github/copilot-instructions.md
  • .github/workflows/test_filenames_check.yml

Walkthrough

This PR restructures test infrastructure by relocating test utilities to align with main source package structure, introducing mock JDBC ResultSet stubs for unit testing, creating dedicated unit and integration test files, updating JMF coverage rules with project-specific exclusions, and adding Scala-specific Copilot development guidance documents.

Changes

Cohort / File(s) Summary
Documentation & Configuration
.github/copilot-instructions.md, .github/copilot-review-rules.md, .gitignore, jmf-rules.txt
Added Scala-specific Copilot instructions and review rules, updated .gitignore to exclude TODO.md, and refined JMF rules by disabling case-apply and adding 15 project-specific method filters for deprecated delegates, factory wrappers, and trivial accessors.
Test Utilities Relocation
balta/src/test/scala/za/co/absa/db/balta/DBTestingConnection.scala
Moved DBTestingConnection from za.co.absa.db.balta.testing.classes to root test package; fixed resource cleanup in now() helper to close correct PreparedStatement variable.
Mock ResultSet Infrastructure
balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala
Added new mock JDBC ResultSet utility providing factory methods (emptyMockResultSet, singleRowMockResultSet, twoRowMockResultSet, mockResultSetWithCols) and internal MockResultSet/MockMetaData stubs for unit testing without a database.
New QueryResult Test Suites
balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultUnitTests.scala, balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultIntegrationTests.scala
Added unit test suite (10 tests with mock ResultSets, no DB required) and integration test suite (2 tests on base_types table) to split and expand QueryResult coverage.
Test Import Updates
balta/src/test/scala/za/co/absa/db/balta/classes/DBTableIntegrationTests.scala, balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultRowIntegrationTests.scala, balta/src/test/scala/za/co/absa/db/balta/implicits/PostgresRowIntegrationTests.scala, balta/src/test/scala/za/co/absa/db/balta/implicits/QueryResultRowImplicitsIntegrationTests.scala
Updated DBTestingConnection imports from testing.classes to new root test package location.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • lsulak
  • benedeki
  • salamonpavel
  • tmikula-dev

Poem

🐰 A rabbit hops through test files with glee,
Mock ResultSets bloom where no DB should be!
DBTesting moved from shadows so dark,
Now unit tests run without leaving a mark.
Coverage rules tuned, infrastructure shines—
This warren of tests now follows best lines! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feature/improve jmf rules by adding unit tests' clearly summarizes the main change: adding unit tests and improving JMF rules.
Description check ✅ Passed The PR description includes Overview, Release Notes, and Related sections matching the template, providing clear context and actionable information.
Linked Issues check ✅ Passed The PR meets all acceptance criteria from issue #78: relocated test traits [#78], added QueryResult unit and integration tests [#78], implemented MockResultSets [#78], added 9 JMF rules with comments [#78], and enabled 'testOnly *UnitTests' [#78].
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #78 objectives: test infrastructure restructuring, unit test addition, JMF rule improvements, and Copilot documentation migration to Scala/sbt.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/improve-jmf-rules-by-adding-unit-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
.gitignore (1)

58-58: Consider whether TODO.md files in subdirectories should also be ignored.

The current pattern TODO.md only matches files at the repository root. If developers might create TODO.md files in subdirectories (e.g., src/TODO.md or docs/TODO.md), consider using **/TODO.md or simply TODO.md at any level.

If the intent is specifically to ignore only a root-level TODO.md, the current pattern is correct.

📝 Optional pattern to ignore TODO.md anywhere in the repository
-TODO.md
+**/TODO.md
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore at line 58, The .gitignore entry currently lists the pattern
"TODO.md" which only matches a root-level file; if you want to ignore TODO.md
files in any subdirectory, replace or add the recursive pattern "**/TODO.md" (or
use a leading slash if you must restrict to root), otherwise leave "TODO.md"
as-is if you intentionally want root-only behavior—update the gitignore entry
for the TODO.md pattern accordingly.
balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala (1)

85-92: Consider documenting the null.asInstanceOf[T] behavior for primitive types.

getObject[T](...): T returning null.asInstanceOf[T] will produce 0, false, etc. for primitive type parameters at runtime due to Scala/JVM boxing semantics. This is acceptable for mock purposes, but a brief doc comment noting this behavior would help future maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala` around lines
85 - 92, Add a brief Scaladoc comment to the MockResultSet class (or directly
above the getObject[T](columnIndex: Int, `type`: Class[T]): T method) explaining
that the implementation returns null.asInstanceOf[T], which on the JVM yields
default primitive values (0, false, etc.) when T is a primitive type wrapper,
and that this behavior is intentional for the mock; mention any implications for
callers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/copilot-instructions.md:
- Line 53: Update the guidance that mandates a `testing` sub-package: change the
line "Must place shared test helpers and fixtures in a dedicated `testing`
sub-package and reuse them across tests." to reflect the new project structure
by instructing contributors to place shared test helpers and fixtures in the
root test package `za.co.absa.db.balta` (or the agreed test package) so it no
longer requires a `testing` sub-package; ensure the wording references the root
test package name `za.co.absa.db.balta` to avoid future conflicts.
- Around line 52-54: The style guidance is inconsistent: it recommends
AnyFunSuite/AnyFunSuiteLike and AnyWordSpec (lines mentioning AnyFunSuite,
AnyFunSuiteLike, AnyWordSpec) but then mandates describe blocks (which belong to
AnyFunSpec); update the document to align frameworks and idioms by either (a)
changing the describe requirement to recommend AnyFunSpec when describe is
required, or (b) removing/rewriting the describe mandate and instead document
idiomatic patterns for the recommended styles—e.g., for AnyFunSuite use flat
test("...") definitions, for AnyWordSpec use nested should/when/in blocks—so
references to describe only appear with AnyFunSpec and the test()/should/when/in
examples match the stated preferred suites.

In `@balta/src/test/scala/za/co/absa/db/balta/DBTestingConnection.scala`:
- Line 17: The test filename DBTestingConnection.scala violates the test-naming
pipeline rule; fix by either renaming the utility to follow allowed patterns
(e.g., DBTestingConnectionSupport.scala or DBTestingConnectionUtil.scala), or
moving the trait into an excluded subfolder such as support/ or fixtures/, or
update the filename-inspector config to exclude this pattern; locate the
trait/type in DBTestingConnection.scala (symbol DBTestingConnection) and apply
one of these changes so the file is no longer treated as a test by the checker.

In `@balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala`:
- Line 17: This test-source filename violates the test-naming rule (same as
DBTestingConnection.scala); since MockResultSets.scala is a test utility, either
move the file into a test support subpackage (e.g., a "support" or "testutils"
test subfolder) so the filename-inspector ignores it, or adjust your inspector
rules to exclude utility files, or if the checker requires test names, rename
the file to match the convention; target the file named MockResultSets.scala
(and related DBTestingConnection.scala) when applying the change.

---

Nitpick comments:
In @.gitignore:
- Line 58: The .gitignore entry currently lists the pattern "TODO.md" which only
matches a root-level file; if you want to ignore TODO.md files in any
subdirectory, replace or add the recursive pattern "**/TODO.md" (or use a
leading slash if you must restrict to root), otherwise leave "TODO.md" as-is if
you intentionally want root-only behavior—update the gitignore entry for the
TODO.md pattern accordingly.

In `@balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala`:
- Around line 85-92: Add a brief Scaladoc comment to the MockResultSet class (or
directly above the getObject[T](columnIndex: Int, `type`: Class[T]): T method)
explaining that the implementation returns null.asInstanceOf[T], which on the
JVM yields default primitive values (0, false, etc.) when T is a primitive type
wrapper, and that this behavior is intentional for the mock; mention any
implications for callers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 850e4589-07c7-4fd6-8428-a6ac7d0a27ea

📥 Commits

Reviewing files that changed from the base of the PR and between 48110b0 and 3c552dc.

📒 Files selected for processing (12)
  • .github/copilot-instructions.md
  • .github/copilot-review-rules.md
  • .gitignore
  • balta/src/test/scala/za/co/absa/db/balta/DBTestingConnection.scala
  • balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala
  • balta/src/test/scala/za/co/absa/db/balta/classes/DBTableIntegrationTests.scala
  • balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultIntegrationTests.scala
  • balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultRowIntegrationTests.scala
  • balta/src/test/scala/za/co/absa/db/balta/classes/QueryResultUnitTests.scala
  • balta/src/test/scala/za/co/absa/db/balta/implicits/PostgresRowIntegrationTests.scala
  • balta/src/test/scala/za/co/absa/db/balta/implicits/QueryResultRowImplicitsIntegrationTests.scala
  • jmf-rules.txt

Copy link
Copy Markdown
Contributor

@benedeki benedeki left a comment

Choose a reason for hiding this comment

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

The test itself are fine, so as the other content as far as I can judge (can be tweaked in future, if needed).
But I oppose the class move and change in excludes.

paths: '**/src/test/scala/**'
report-format: 'console'
excludes: 'balta/src/test/scala/za/co/absa/db/balta/testing/*'
excludes: 'balta/src/test/scala/za/co/absa/db/balta/DBTestingConnection.scala,balta/src/test/scala/za/co/absa/db/balta/MockResultSets.scala'
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.

Why this change? This folder was created exactly for placing there files not to be tested. Visa-versa I would place the MockResultSets there.
So please move the file back, and add new one there, I would suggest testing/data folder.

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.

Improve test infrastructure: restructure shared traits, unit tests, and JMF rules

2 participants