Skip to content

test(java): add unit tests for TargetKey - #5044

Open
viniciusscience wants to merge 1 commit into
apache:masterfrom
viniciusscience:test/java-target-key
Open

viniciusscience wants to merge 1 commit into
apache:masterfrom
viniciusscience:test/java-target-key

Conversation

@viniciusscience

@viniciusscience viniciusscience commented Nov 23, 2026 •

Copy link
Copy Markdown

Which issue does this PR address?

Closes #5034

Rationale

TargetKey in the async TCP client had no dedicated unit tests verifying content-based equality, hashing, prefix matching, or topic() slicing.

What changed?

Added TargetKeyTest in org.apache.iggy.client.async.tcp covering:

  • equal byte arrays produce equal keys with matching hashCode(), while differing content or lengths are not equal;
  • topic() strips the 4 trailing partition ID bytes to equal TargetKey.of(...) on the stream+topic prefix (with matching hashCode());
  • startsWith() returns true for a prefix and for an identical key, and false for a longer key or mismatched prefix;
  • equals() returns false for null and non-TargetKey objects.

Local Execution

  • Passed (./gradlew :iggy:test --tests '*TargetKeyTest' --rerun :iggy:checkstyleTest spotlessCheck — 5/5 tests passed, Checkstyle and Spotless green)
  • Pre-commit hooks passed (prek run --files foreign/java/java-sdk/src/test/java/org/apache/iggy/client/async/tcp/TargetKeyTest.java — mixed-line-ending, license-headers, trailing-whitespace, trailing-newline, binary-artifacts, and typos all passed)

Docs

  • no user-facing change

AI Usage

  1. Antigravity (Gemini)
  2. Assisted with drafting test cases and checking formatting against BigIntegerMessageIdTest conventions.
  3. Ran ./gradlew :iggy:test --tests '*TargetKeyTest' --rerun :iggy:checkstyleTest spotlessCheck and prek run locally (5/5 tests passed, Checkstyle, Spotless, and prek hooks green), ran the 4-expert team-review skill (Verdict: APPROVE), and verified every case against TargetKey.java.
  4. Yes — every assertion maps directly to TargetKey's of, topic, startsWith, equals, and hashCode implementation.

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI assistance was used to create this PR, you are required to run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Nov 23, 2026
@justinmclean

Copy link
Copy Markdown
Member

Thanks @viniciusscience, and welcome. Please run prek as CONTRIBUTING.md asks, and as you used Antigravity, please run the team-review skill and post the result here.

@viniciusscience

Copy link
Copy Markdown
Author

Thanks for the welcome, @justinmclean!

I have installed and run prek locally on the change (mixed-line-ending, license-headers, trailing-whitespace, trailing-newline, binary-artifacts, and typos all passed, and updated the PR description accordingly) and ran the 4-expert team-review skill (storage, perf, distsys, ecosystem). Here is the full team-review report:


Iggy Team Review - Add unit tests for TargetKey (#5044) (ce79e1a)

  • target: #5044
  • reviewed commit: ce79e1a9ff1d2dc8c2c8c850e03b15dd8e9c4c38 (base d9bb42398f024a314b4e628f0e011fc72865aa5d)
  • timestamp: 2026-11-24T10:52:00Z
  • roles: storage, perf, distsys, ecosystem
  • expert count: 4
  • validation: none (manual)

Review: Add unit tests for TargetKey (#5044)

Findings

None.

Unconfirmed (conf:L, check these first)

None.

Pre-existing (origin pre-*, does not block the merge)

None.

Simplification opportunities (does not block the merge)

None.

Verdict: APPROVE

Reason: All four reviewers verified TargetKeyTest against TargetKey and found no defects or simplification items.

Counts: critical 0, warning 0, nit 0, simplify 0
Verification: CI check apply passed on ce79e1a9 (https://github.com/apache/iggy/actions/runs/45148512467/job/137607945421); local prek hooks (mixed-line-ending, license-headers, trailing-whitespace, trailing-newline, binary-artifacts, typos) and ./gradlew :iggy:test --tests '*TargetKeyTest' --rerun :iggy:checkstyleTest spotlessCheck passed.
Open each cited line and confirm the finding before you change the code.

Raw findings per expert

storage (storage.md)

Findings: none

Simplifications: none

Verdict: APPROVE - The unit tests verify equality, hashing, prefix checks, and topic slicing for TargetKey without defects.

perf (perf.md)

Findings: none

Simplifications: none

Verdict: APPROVE - The pull request adds fast, zero-IO unit tests for TargetKey and introduces no performance issues.

distsys (distsys.md)

Findings: none

Simplifications: none

Verdict: APPROVE - The unit tests in `TargetKeyTest` verify equality, hash codes, prefix matching, and partition suffix slicing of `TargetKey`.

ecosystem (ecosystem.md)

Findings: none

Simplifications: none

Verdict: APPROVE - The PR adds clean unit tests for the package-private `TargetKey` helper without public API changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java SDK: add unit tests for TargetKey

2 participants