Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Cosmos] Extract a StoreResult test factory to replace the 20-arg positional constructor in unit tests

Aperta
#49,433 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mbhaskar ci sta già lavorando.

Dal 9/6/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Cosmos

Summary

Follow-up from PR #48914 (review feedback from @kushagraThapar).

The 20-arg positional new StoreResult(...) constructor is repeated across many test methods (in ConsistencyWriterTest.java at lines ~667, 725, 757, 779, 834, 894, 903, 919, 947, and several more in QuorumReaderTest.java). Each invocation follows the same pattern: most arguments are constants/null/false, with only 2–3 meaningful per test (replica role, isThrottledException, isValid).

This positional-constructor accretion has been growing across multiple PRs and makes tests verbose and fragile.

Proposed change

Extract a StoreResultTestFactory (or builder) with named, intent-revealing methods, e.g.:

  • throttled429()
  • valid(int globalCommittedLsn)
  • unhealthy(replicaRole)

Benefits:

  • New tests become 1-line setup instead of ~20-line setup.
  • When the StoreResult constructor changes (e.g. adding a 21st arg), only the factory updates instead of N test sites.
  • Test intent becomes self-documenting (throttled429() reads as a behavior, not a 20-arg ctor invocation).

Scope

Test-only refactor; no production behavior change. Update existing StoreResult-based tests in:

  • sdk/cosmos/azure-cosmos-tests/.../directconnectivity/ConsistencyWriterTest.java
  • sdk/cosmos/azure-cosmos-tests/.../directconnectivity/QuorumReaderTest.java

Context

Reviewer noted this is "not a blocker for [PR #48914] but worth scheduling as a follow-up before the next test wave lands on top."

Lingua principale
Java
Stelle
2.6k
Fork
2.2k
Merge medio
1g 22h
PR unite (30g)
213

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 Azure/azure-sdk-for-java

Tutte le issue di Azure/azure-sdk-for-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.