Skip to content

test(intent): cover calculatedActionOnCreate on a to-one relation - #6699

Merged
delchev merged 1 commit into
masterfrom
test/intent-relation-calculated-action
Aug 13, 2026
Merged

test(intent): cover calculatedActionOnCreate on a to-one relation#6699
delchev merged 1 commit into
masterfrom
test/intent-relation-calculated-action

Conversation

@delchev

@delchev delchev commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Pays back the coverage owed by #6681. engine-intent/CLAUDE.md requires every new keyword to extend IntentEmissionCoverageIT in the same PR; that one merged without it, and the doc recorded the debt.

What it covers

The fixture gains Tariff + Quote, where Quote.Tariff declares calculatedActionOnCreate: QuoteTariffAction, plus the hand-written custom/QuoteTariffAction.java the 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:

layer assertion
.model the relation property carries "calculatedActionOnCreate": "QuoteTariffAction"
generated code entity.Tariff = Beans.get(QuoteTariffAction.class).calculate(entity); in the repository, plus the decoded imports: line
runtime a create that OMITS the FK returns the base-flagged tariff; one that SUPPLIES a tariff keeps it

The 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 .intent while the emitted repository contained no assignment at all, and the create stored null with every pipeline step green. Asserting the .model alone 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.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.

Verification

IntentEmissionCoverageIT green: Tests run: 1, Failures: 0, Errors: 0.

Both new assertion groups were also observed failing first, so neither passes vacuously:

  • the emission group, on a wrong model filename (app.model vs emission.model);
  • the runtime group, on the 500 described above.

Re-run after rebasing onto current master, and the installed 15.0.0-SNAPSHOT template jars were diffed against the working tree to confirm the run used current Repository.java.template, EntityController.java.template and document-page.js.template rather than stale artifacts.

🤖 Generated with Claude Code

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>
@delchev
delchev merged commit 9d97a5b into master Aug 13, 2026
10 checks passed
@delchev
delchev deleted the test/intent-relation-calculated-action branch August 13, 2026 06:54
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