Skip to content

refactor: dedup the resource layer + reach 100% enforced coverage#14

Merged
MarketDataDev03 merged 6 commits into
mainfrom
14_code_ajustment
Jun 26, 2026
Merged

refactor: dedup the resource layer + reach 100% enforced coverage#14
MarketDataDev03 merged 6 commits into
mainfrom
14_code_ajustment

Conversation

@MarketDataDev03

Copy link
Copy Markdown
Collaborator

refactor: dedup the resource layer + reach 100% enforced coverage

Branch 14_code_ajustmentmain · 5 commits · 50 files · +1407 −509

A pre-v1 hardening pass. No new endpoints and no public-API changes — this collapses duplicated
plumbing across the five resource façades, fills the integration-test gaps, and ratchets line
coverage to 100% with build-time enforcement. The per-resource series (utilities, options, stocks,
markets, funds) was already complete on main; this makes that code smaller and the safety net
tighter before tagging v1.

What's included

  • Resource-layer dedup (021edbe). The universal-param setters (dateFormat/mode/limit/
    offset) and the CSV/HTML execute paths were copy-pasted across every resource. They now live in
    two self-typed base types — ConfiguredResource and FormattedResource — plus a TextResponses
    helper for the CSV/HTML facets. Net −160 lines in that commit (15 files, +187/−347), public
    surface untouched.
  • Shared typed-JSON execute path (892a974). The per-resource JSON dispatch (build request →
    execute → envelope into the typed MarketDataResponse) is unified behind a JsonResponses helper
    and a single top-level ResponseFactory, applied across utilities/options/stocks/markets/funds.
  • Missing integration tests (5a792ba). Adds UtilitiesIntegrationTest (status / headers /
    user) and a CSV-smoke integration test per resource (funds/markets/options/stocks). The suite is
    33 IT methods, still env-gated behind MARKETDATA_RUN_INTEGRATION_TESTS.
  • 100% line coverage, enforced (c427ebb, 7dc5cdb). New unit tests across the client, request
    validation, parsers, resolutions, response predicates, the exception hierarchy, and the retry/
    transport/semaphore internals. The handful of genuinely unreachable defensive guards (e.g. a
    builder's empty-list check that the seeded builder(first, …) makes impossible) are marked with a
    new internal @Generated annotation so they don't dilute the metric. Coverage is now enforced via
    jacocoTestCoverageVerification (minimum = 1.0) wired into check — the build fails if line
    coverage drops below 100%.

Public API

Unchanged. Every refactor is internal: the new ConfiguredResource, FormattedResource,
TextResponses, JsonResponses, ResponseFactory, and Generated types are all package-private in
the com.marketdata.sdk root, consistent with ADR-007's single-package-internals boundary. The only
edits to public request classes (OptionsQuotesRequest, StockQuotesRequest, StrikeFilter) are
@Generated annotations on existing methods — no signatures added or changed.

Tests & coverage

  • 831 unit tests, all green.
  • 100% JaCoCo line coverage, now enforced on every check (PR builds included).
  • Spotless (Google Java Format) green.
  • ./gradlew check → exit 0 (unit tests + coverage verification + formatting; integration tests
    stay gated by the env var, so PR builds remain fast and don't need the live-API secret).

Notes

  • Introduces the @Generated coverage-exclusion convention. It's applied narrowly to provably
    unreachable lines; documenting when it's appropriate is a follow-up for the docs/ADR pass.
  • Not in this PR: the consumer-examples rewrite (clearer per-resource + cross-cutting examples,
    Kotlin quickstart) lives on a separate branch (15_improve_examples) and will land as its own PR.

Commits

Hash Summary
021edbe refactor: dedup universal-param setters into self-typed base
892a974 refactor: share typed JSON execute path across resources
5a792ba add missing IT
c427ebb improve coverage
7dc5cdb 100% coverage

@MarketDataDev03 MarketDataDev03 self-assigned this Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

The author of this PR, MarketDataDev03, is not an activated member of this organization on Codecov.
Please activate this user on Codecov to display this PR comment.
Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.
Please don't hesitate to email us at support@codecov.io with any questions.

@MarketDataDev03 MarketDataDev03 marked this pull request as ready for review June 24, 2026 12:59
Demo/unauthenticated responses carry x-api-ratelimit-limit=0,
remaining=0 with a future reset on every successful (203) call — the
API's "unmetered" signal, not an exhausted quota. The §10.3 preflight
gate read that remaining=0 as exhaustion and short-circuited every
request after the first demo response, breaking demo mode for the AAPL
options/stocks/funds data the API serves without a token.

Treat limit==0 as unmetered and allow the request; a genuine
exhaustion is limit>0 && remaining==0 (still blocked). Adds a covering
unit test (preflightAllowsWhenSnapshotIsUnmeteredDemo).

@MarketDataDev01 MarketDataDev01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed validation to allow demo mode to work after the first request.

@MarketDataDev03 MarketDataDev03 merged commit 235f7d0 into main Jun 26, 2026
5 checks passed
@MarketDataDev03 MarketDataDev03 deleted the 14_code_ajustment branch June 26, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants