Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#49,433 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mbhaskar đang làm issue này rồi.

Từ ngày 9/6/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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."

Ngôn ngữ chính
Java
Star
2.6k
Fork
2.2k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
213

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/azure-sdk-for-java

Tất cả issue của Azure/azure-sdk-for-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.