test(intent): cover calculatedActionOnCreate on a to-one relation - #6699
Merged
Conversation
The keyword landed in #6681 without an IntentEmissionCoverageIT case, which engine-intent/CLAUDE.md requires of every new keyword in the same PR. This pays that back. The fixture gains Tariff + Quote, where Quote.Tariff declares `calculatedActionOnCreate: QuoteTariffAction`, plus the hand-written custom/QuoteTariffAction.java the contract requires - written into the emission-test project by the IT itself, since a generated repository referencing a missing class fails the whole client-Java batch and with it every REST assertion in this gate. That coupling is why the case was deferred; carrying the class as part of the fixture is what makes it safe. Three layers, because no one of them alone catches this keyword's regression: - the .model property attribute; - the repository's `entity.Tariff = Beans.get(QuoteTariffAction.class) .calculate(entity);` plus the decoded imports: line - THE regression, since a relation is an ordinary property in the .model but only fields used to carry the calculated attributes into it, so the keyword parsed and validated while the emitted repository had no assignment at all and the create stored null with every pipeline step green; - the runtime, both directions of the documented contract: a create that OMITS the FK comes back carrying the base-flagged tariff, and one that SUPPLIES a tariff keeps it ("an explicit pick always wins"). The base tariff is seeded as row 2, not row 1, so the runtime assertion cannot be satisfied by a first row or a stray column default - only by the action having run and matched on `base`. The runtime layer earned its place while writing this: annotating the action with org.springframework.stereotype.Component instead of the SDK's org.eclipse.dirigible.sdk.component.Component compiles cleanly and then fails every create with "No qualifying bean of type custom.QuoteTariffAction available". An emission-only case - the cheaper option - would have passed while the feature was dead at runtime. Verified: IntentEmissionCoverageIT green (Tests run: 1, Failures: 0, Errors: 0). Both new assertion groups were also observed FAILING first - the emission group on a wrong model filename, the runtime group on the 500 above - so neither is passing vacuously. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pays back the coverage owed by #6681.
engine-intent/CLAUDE.mdrequires every new keyword to extendIntentEmissionCoverageITin the same PR; that one merged without it, and the doc recorded the debt.What it covers
The fixture gains
Tariff+Quote, whereQuote.TariffdeclarescalculatedActionOnCreate: QuoteTariffAction, plus the hand-writtencustom/QuoteTariffAction.javathe contract requires.The class is written into the emission-test project by the IT itself. That coupling is exactly why the case was deferred: a generated repository referencing a missing class fails the whole client-Java batch and with it every REST assertion in this gate. Carrying the class as part of the fixture is what makes it safe.
Three layers, because no one of them alone catches this keyword's regression:
.model"calculatedActionOnCreate": "QuoteTariffAction"entity.Tariff = Beans.get(QuoteTariffAction.class).calculate(entity);in the repository, plus the decodedimports:linebase-flagged tariff; one that SUPPLIES a tariff keeps itThe middle row is the regression. A relation is an ordinary property in the
.model, but only fields used to carry the calculated attributes into it — so the keyword parsed, validated and reached the.intentwhile the emitted repository contained no assignment at all, and the create stored null with every pipeline step green. Asserting the.modelalone would not have caught it: that layer was already fine.The base tariff is seeded as row 2, not row 1, so the runtime assertion cannot be satisfied by a first row or a stray column default — only by the action having run and matched on
base.Why the runtime layer is not redundant
It earned its place while this was being written. Annotating the action with
org.springframework.stereotype.Componentinstead of the SDK'sorg.eclipse.dirigible.sdk.component.Componentcompiles cleanly and then fails every create withNo qualifying bean of type 'custom.QuoteTariffAction' available. An emission-only case — the cheaper option — would have passed while the feature was dead at runtime.Verification
IntentEmissionCoverageITgreen:Tests run: 1, Failures: 0, Errors: 0.Both new assertion groups were also observed failing first, so neither passes vacuously:
app.modelvsemission.model);Re-run after rebasing onto current
master, and the installed15.0.0-SNAPSHOTtemplate jars were diffed against the working tree to confirm the run used currentRepository.java.template,EntityController.java.templateanddocument-page.js.templaterather than stale artifacts.🤖 Generated with Claude Code