Skip to content

feat(datacustodian): seed a deterministic ESPI sample dataset on the local profile (#253) - #261

Open
dfcoffin wants to merge 2 commits into
mainfrom
feat/253-dc-local-sample-data
Open

dfcoffin wants to merge 2 commits into
mainfrom
feat/253-dc-local-sample-data

Conversation

@dfcoffin

Copy link
Copy Markdown
Contributor

Closes #253.

What

On the local profile the Data Custodian now starts with a small, deterministic ESPI dataset, so the consent flow and every ESPI feed can be tested by hand right after scripts/local/start-all.sh.

LocalSampleDataSeedRunner:

  • Runs on @Profile("local") only.
  • Is idempotent.
  • Builds its ids as UUID v5 of fixed sample hrefs, so the ids, and the URLs built from them, stay the same across restarts.

It seeds:

  • RetailCustomer: customer / customer (ROLE_USER), owning one electricity UsagePoint. The UsagePoint has:
    • LocalTimeParameters for US Eastern;
    • an hourly kWh ReadingType;
    • a MeterReading with 2 daily IntervalBlocks of 24 hourly readings, with cost;
    • a UsageSummary and an ElectricPowerQualitySummary.
  • Customer, CustomerAccount, CustomerAgreement, ServiceLocation, Meter for one residential customer.
  • ApplicationInformation for the AS-seeded third_party client, with the TP's local redirect and notification URIs.

Where the values come from

The ESPI schema values are the most common shapes across the Green Button CMD certification test feeds:

  • ReadingType accumulationBehaviour 4, commodity 1, kind 12, uom 72, powerOfTenMultiplier -3, currency 840;
  • daily blocks of 24 hourly readings;
  • DST rules 360E2000 / B40E2000;
  • mains voltage 240000.

Every identifying value is synthetic (example.com, 555-01xx, SAMPLE-… numbers). Nothing is copied from a certification record.

The issue suggested a Flyway seed instead. This PR uses a runner, which does not depend on the local profile adopting Flyway (#241), and keeps the customer password bcrypt-encoded at runtime like DevSandboxAdminSeedRunner.

Defect found by the data

open-in-view is off. The IntervalBlock, UsageSummary and CustomerAccount controllers mapped entities to DTOs outside any session, so any non-empty feed returned 500 with a LazyInitializationException on intervalReadings, costAdditionalDetailLastPeriod or notifications. These three controllers are now @Transactional(readOnly = true). The other seeded feeds were not affected.

Tests

docs/LOCAL_TESTING.md gains a "Sample data" section and the customer login. The #253 blocker is removed.

🤖 Generated with Claude Code

dfcoffin and others added 2 commits November 15, 2026 01:20
…profile

LocalSampleDataSeedRunner (local profile only, idempotent, UUID v5 ids from fixed sample hrefs):
- RetailCustomer customer/customer (ROLE_USER) owning one electricity UsagePoint with
  LocalTimeParameters (US Eastern), an hourly kWh ReadingType, a MeterReading with 2 daily
  IntervalBlocks of 24 hourly readings with cost, a UsageSummary and an ElectricPowerQualitySummary.
- Customer, CustomerAccount, CustomerAgreement, ServiceLocation and Meter for one residential customer.
- ApplicationInformation for the AS-seeded third_party client with the TP's local URIs.
Schema values follow the most common shapes in the Green Button CMD certification test feeds; every
identifying value is synthetic (example.com, 555-01xx, SAMPLE- numbers).

The data exposed a real defect: with open-in-view off, the IntervalBlock, UsageSummary and
CustomerAccount controllers mapped entities outside any session, so a lazy collection
(intervalReadings, costAdditionalDetailLastPeriod, notifications) made every non-empty feed 500.
Those controllers now run read-only transactional.

LocalSampleDataSeedRunnerTest runs the seed against the Flyway-migrated H2 schema and checks that each
feed marshals its entries, the customer login and readings, and idempotency. Runbook and both smoke
scripts updated (new check: the IntervalBlock feed contains the sample data).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… database)

Every Spring test context in the DC module shares the in-memory testdb, so other tests can add
UsagePoint or ApplicationInformation rows before this one runs (CI order). Check that each feed
contains the seeded entries' stable ids instead of an exact entry total.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 local profile: seed a deterministic ESPI sample dataset (customer, usage, PII, ApplicationInformation) for manual testing

1 participant