Java SDK: add unit tests for TargetKey
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Read TargetKey.java under foreign/java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/, paying attention to of(byte[]), topic(), startsWith and equals/hashCode, which compare only the first length bytes. Use BigIntegerMessageIdTest.java as the style reference, then add TargetKeyTest.java in the same package under src/test. Done when the four listed cases pass with ./gradlew :iggy:test --tests '*TargetKeyTest' and ./gradlew spotlessCheck passes in foreign/java.
Written by the indexing model from the issue text.
Description
Description
TargetKey in foreign/java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/TargetKey.java has no unit test. It holds the target bytes of a partition request, or their stream and topic prefix, and PollRouter uses it as a map key. It has of(byte[]), topic() (the same bytes without the trailing four-byte partition id), startsWith(TargetKey), equals and hashCode. Equality compares only the first length bytes, so a change to the prefix handling would break route lookups without any test failing.
Affected area / component
Java SDK
Proposed solution
Add TargetKeyTest.java under foreign/java/java-sdk/src/test/java/org/apache/iggy/client/async/tcp/, in the same package so it can reach the package-private class. BigIntegerMessageIdTest.java shows the JUnit 5 and AssertJ style. Use small hand-built byte arrays.
- Two keys over equal arrays are equal and have equal hash codes, and keys over different arrays are not equal.
topic()of a key built from the stream and topic bytes plus four bytes equalsofover the stream and topic bytes alone.startsWithis true for a prefix and for the key itself, and false for a longer key or a different prefix.equalsreturns false fornulland for another type.
How to test: ./gradlew :iggy:test --tests '*TargetKeyTest' and ./gradlew spotlessCheck pass in foreign/java.
Good first issue
- I think this could be a good first issue for a new contributor
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 548
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 194
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iggy
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
go good first issue test
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
good first issue javascript test
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
good first issue javascript test
Difficulty 2/5 Half a day Newbie friendliness 85/100
Maintainers usually reply within 2 days
Similar issues
-
bug triaged tui ux wontfix
Difficulty 2/5 Half a day Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
bevyengine/bevy#26642 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day