Skip to content

COG-1145: W0 smoke suite — admin REST + Boot 1.5 golden JSON fixtures - #346

Open
patrickbradley-cog wants to merge 3 commits into
devin/cog-1141-w0-testcontainers-mysql-harness-for-springboottest-boot-154from
devin/cog-1145-w0-smoke-suite-admin-rest-capture-golden-json-fixtures
Open

patrickbradley-cog wants to merge 3 commits into
devin/cog-1141-w0-testcontainers-mysql-harness-for-springboottest-boot-154from
devin/cog-1145-w0-smoke-suite-admin-rest-capture-golden-json-fixtures

Conversation

@patrickbradley-cog

@patrickbradley-cog patrickbradley-cog commented Sep 30, 2026 •

Copy link
Copy Markdown

Summary

Linear: COG-1145

Stacked on #335 (COG-1141 Testcontainers harness) — base is devin/cog-1141-w0-testcontainers-mysql-harness-for-springboottest-boot-154; retarget to master when #335 merges. Test-only; no production code, Boot or Java changes.

Captures today's (Boot 1.5.4 / Jackson 2.8) admin REST contract as golden JSON, plus a public parse-equivalence comparator that later waves assert against.

com.userFront.golden.JsonParseEquivalence (public API for later waves)

JsonParseEquivalence.create()            // "date" is a date field by default
    .withDateFields("created")           // more instant-compared fields
    .ignoringValuesOf("id", "userId")    // presence + JSON type only
    .assertEquivalent(expectedJson, actualJson);
  • objects: exact field-name sets (missing and unexpected fields fail); arrays: same length/order
  • numbers by value (1000.00 == 1000)
  • date fields by instant: epoch millis (what Boot 1.5 actually emits) == ...+0000 == ...+00:00 == ...Z; offset-less/unparseable strings fail
  • reports every difference as $.path: ... in one assertion

GoldenFixtures: assertMatches(BOOT15, name, actualNode, equivalence) reads classpath:/golden/boot15/<name>.json; -Dgolden.update=true rewrites the files under src/test/resources/golden/boot15/ instead.

AdminRestSmokeTest extends AbstractIntegrationTest (as ROLE_ADMIN via MockMvc):

endpoint assertion
GET /api/user/all full body read + parsed, matches user-all.json
GET /api/user/primary/transaction?username= user-primary-transaction.json
GET /api/user/savings/transaction?username= user-savings-transaction.json
GET /api/appointment/all appointment-all.json
GET /api/user/{u}/disable, /enable 200, empty body, enabled flips in DB
all of the above as ROLE_USER 403, and the toggle user stays enabled

Notes for reviewers / later waves:

  • Fixture contents: bodies as served, restricted to the adminsmoke-* rows this class seeds (other smoke classes share the JVM/context/DB), transaction and appointment rows sorted by date (their queries have no ORDER BY, so wire order is not part of the contract), pretty-printed with exact decimals. Generated id/userId are presence+type only; account numbers, balances, dates and the (fake) exposed password hash are seeded with fixed values, so fixtures are deterministic regardless of test order.
  • Seeding goes straight through the DAOs with fixed account numbers 91145001..6, not signup, to avoid the static account-number counter bug (COG-1179). Unique adminsmoke- usernames, so no clash with smokeuser in COG-1144: W0 smoke suite for appointment create/list/confirm #108/COG-1142: W0 smoke suite — signup, login, logout, remember-me (MockMvc) #109.
  • recipientList: RECIPIENT_LIST_IN_USER_ALL = true records that User.recipientList is serialised today. It also appears in the nested user of /api/appointment/all. COG-1150 (COG-1150: W1 · User + UserRole GenerationType.IDENTITY and @JsonIgnore on recipientList #341) must flip the constant and regenerate both user-all.json and appointment-all.json (-Dgolden.update=true) with a note in its PR body.
  • enable/disable verb: the single toggleUser(username, action) helper builds the request (currently get(...)); COG-1154 only needs to change that line.
  • /api/user/all is fully serialised and parsed, so W5's open-in-view=false will surface a LazyInitializationException on recipientList here.

Verification (Temurin 8u504 + Docker, mysql:5.7.44 Testcontainer)

mvn -B -f UserFront/pom.xml verify:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 - in com.userFront.UserFrontApplicationTests
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0 - in com.userFront.AdminRestSmokeTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0 - in com.userFront.golden.JsonParseEquivalenceTest
Tests run: 16, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS

Comparator drift checks against the real endpoint (fixture edited temporarily, then restored):

  • dates rewritten as "2017-06-15T10:15:30.000+00:00" / "2017-06-16T09:00:00Z" → passes (epoch ms served vs ISO in fixture)
  • one date shifted 1s (+0000) and one balance changed →
java.lang.AssertionError: JSON documents are not parse-equivalent:
  $[0].availableBalance: expected 2000.01 but was 2000.00
  $[0].date: expected instant 2017-06-15T10:15:31Z ("2017-06-15T10:15:31+0000") but was 2017-06-15T10:15:30Z (1497521730000)

Same-JVM coexistence with the sibling smoke classes (copied temporarily from the COG-1142/1143/1144 branches into a scratch worktree): AdminRestSmokeTest 7/7 green alongside MoneyMovementSmokeTest, AppointmentSmokeTest, AuthSmokeTest. AuthSmokeTest fails 5/5 when run after MoneyMovementSmokeTest with or without this class present (signup hits COG-1179); AdminRestSmokeTest,AuthSmokeTest together are both green — so that interaction is pre-existing and not caused here.

Link to Devin session: https://app.devin.ai/sessions/030cd558f2f149b383bc2f6f651361e5
Open in Devin Desktop: https://app.devin.ai/desktop/session/030cd558f2f149b383bc2f6f651361e5?variant=devin
Requested by: @patrickbradley-cog


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Devin Review (Staging)


Devin Review

…arse-equivalence comparator

Co-Authored-By: patrick.bradley <patrick.bradley@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: patrick.bradley <patrick.bradley@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: patrick.bradley <patrick.bradley@cognition.ai>
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.

1 participant