Skip to content

feat(#158): DC→TP notification contract + TP-receiver stub#163

Merged
dfcoffin merged 2 commits into
mainfrom
feature/158-dc-tp-notification-contract
Jun 5, 2026
Merged

feat(#158): DC→TP notification contract + TP-receiver stub#163
dfcoffin merged 2 commits into
mainfrom
feature/158-dc-tp-notification-contract

Conversation

@dfcoffin

@dfcoffin dfcoffin commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Closes #158.

Pins the DataCustodian→ThirdParty BatchList notification seam with a single-source-of-truth wire codec, a repo-root contract fixture, and two-sided contract tests — the DC→TP analogue of #150/#160. Lightweight consumer-driven contract (no Spring Cloud, no WireMock); standalone EC2 services.

What changed

Shared codec — BatchListXmlCodec (openespi-common)
The canonical ESPI BatchList XML marshal/unmarshal codec, a stateless static utility mirroring EspiBatchUri. Both the DC sender and TP receiver route through it, so the wire format cannot drift between the two services. Wire type is the JAXB BatchListDto (<BatchList xmlns="http://naesb.org/espi">), never the JPA entity — per the project's JAXB/JPA separation rule.

DC sender — NotificationServiceImpl (deliverable #3, done properly)

  • Migrated off legacy RestTemplateRestClient.
  • Now marshals the DTO via the codec. The old path tried to marshal the JAXB-less BatchListEntity, which never serialized — so this also fixes a latent bug.
  • Resource URI built through EspiBatchUri.batchSubscription (Batch/Subscription/{id}?published-min=…&published-max=…).
  • POSTs application/atom+xml. Constructor adds no new injected bean (builds RestClient internally; a test ctor injects one) → zero wiring blast-radius.
  • Removed the now-unused RestTemplate bean from DC WebConfiguration.

TP receiver — NotificationController

Contract fixture

  • contracts/notification-batchlist.xml + README section documenting the endpoint path, application/atom+xml content type, and BatchList shape.

Tests

  • BatchListXmlCodecTest (common) — round-trip, prefix-agnostic DOM assertion of root element + namespace, and binds to the shared fixture.
  • NotificationServiceImplWireContractTest (common) — producer end-to-end: drives the real sender against a minimal standalone TP-receiver stub (a JDK HttpServer — no WireMock, no Spring, no Docker), asserting the bytes on the wire (path, content type, parsed Batch/Subscription URI). This is the issue's "TP-receiver stub" (deliverable Bump org.postgresql:postgresql from 42.7.4 to 42.7.7 in /openespi-datacustodian/OpenESPI-GreenButton-Workspace/OpenESPI-DataCustodian-java #2).
  • NotificationWireContractTest (thirdparty) — TP consumer binds its parsing logic to the same fixture.
  • Removed the obsolete @Disabled NotificationControllerTests (referenced the removed marshaller; tested nothing).

Verified locally: common (codec + producer stub tests pass, jar installed), thirdparty (consumer test passes), datacustodian (compiles; no test referenced the removed bean).

Out of scope (TP last — #146)

TP DB provisioning, fetch-back completion (empty access token / commented authorization lookup), re-enabling the DC sender's production callers.

🤖 Generated with Claude Code

dfcoffin and others added 2 commits June 5, 2026 13:35
Pin the DataCustodian→ThirdParty BatchList notification seam with a
single-source-of-truth wire codec, a repo-root contract fixture, and
two-sided contract tests — the DC→TP analogue of #150/#160.

- BatchListXmlCodec (openespi-common): the canonical ESPI BatchList XML
  marshal/unmarshal codec, a stateless static utility mirroring
  EspiBatchUri. Both the DC sender and TP receiver route through it so
  neither can drift.
- DC sender (NotificationServiceImpl): migrated off legacy RestTemplate
  to RestClient; now marshals the JAXB DTO (not the JAXB-less entity,
  which never serialized) and builds the resource URI via
  EspiBatchUri.batchSubscription. Constructor adds no new injected bean.
- TP receiver (NotificationController): unmarshals via the codec to
  BatchListDto (fixing a latent cast to the JAXB-less entity); fetch-back
  stays stubbed (TP last, #146).
- Removed the now-unused RestTemplate bean from DC WebConfiguration.
- contracts/notification-batchlist.xml + README section document the
  endpoint path, application/atom+xml content type, and BatchList shape.
- Tests: BatchListXmlCodecTest (round-trip + fixture, common),
  NotificationServiceImplWireContractTest (producer end-to-end against a
  JDK HttpServer TP-receiver stub — no new deps), NotificationWireContractTest
  (TP consumer binds to the fixture).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ired

With two explicit constructors (production + test-seam) and none annotated,
Spring could not select one ("No default constructor found"), failing every
full-context @SpringBootTest (DataCustodianApplication{H2,Mysql,Postgres}Test).
Annotate the production constructor so Spring uses it for autowiring.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfcoffin dfcoffin merged commit d2f87a2 into main Jun 5, 2026
4 checks passed
@dfcoffin dfcoffin deleted the feature/158-dc-tp-notification-contract branch June 5, 2026 18:55
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.

DC→TP notification contract test + TP-receiver stub

1 participant