Java SDK: add unit tests for TargetKey

Aperta Adatta ai principianti
#5,034 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
testing

Direzione di ricerca

Leggi TargetKey.java sotto foreign/java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/, prestando attenzione a of(byte[]), topic(), startsWith ed equals/hashCode, che confrontano solo i primi length byte. Usa BigIntegerMessageIdTest.java come riferimento di stile, poi aggiungi TargetKeyTest.java nello stesso package sotto src/test. È completato quando i quattro casi elencati passano con ./gradlew :iggy:test --tests '*TargetKeyTest' e ./gradlew spotlessCheck passa in foreign/java.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue java test
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 equals of over the stream and topic bytes alone.
  • startsWith is true for a prefix and for the key itself, and false for a longer key or a different prefix.
  • equals returns false for null and 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
Lingua principale
Rust
Stelle
5.3k
Fork
548
Merge medio
2g 20h
PR unite (30g)
194

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iggy

Tutte le issue di apache/iggy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.