elsa-core/test/unit
Sipke Schoorstra 6a3d65ff7e
feat(bpmn): the work binder and the elsa: binding format (#7946)
* feat(bpmn): bind BPMN work declarations to Elsa activities

Turns the reader's BpmnWorkBinding declarations into the activity nodes a
BpmnProcess scope runs. Six of the seven kinds bind automatically: TimerWait to
Delay, MessageWait/SignalWait to Event, MessagePublish to PublishEvent,
CallProcess to DispatchWorkflow, NestedProcess to a nested BpmnProcess. The
seventh, UnboundTask, is an authoring decision and is read from a new elsa:
vendor extension inside the document, so an exported .bpmn is self-contained.

Every binding for a scope is bound whatever its slot, so a ScopeListener needs
no special case. Each binding gets its own freshly built activity with a
scope-qualified id: ActivityVisitor skips an activity it has already collected,
so one instance shared between two scopes would leave the second scope with no
child in Elsa's identity graph.

The binder lives in Elsa.Bpmn.Interchange because BpmnWorkBinding is a
Bpmn.Interchange type; binding it in Elsa.Bpmn would pull the interchange
library into the execution module's closure, which is the split D12 draws.

Every ambiguity resolves loudly: an unbound task, a dead binding declaration, a
malformed ISO-8601 duration, a call activity with nothing to call, and an
activity type nothing registered all refuse at bind time rather than producing a
process that runs to completion doing none of what the document says.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(bpmn): declare document variables on the bound scope, refuse duplicate input names

BpmnWorkBinder.BindScope never copied BpmnProcessDefinition.Variables onto the
produced BpmnProcess's Elsa Variables, so a document-declared collection variable
was Absent to IBpmnVariableReader and a collection-mode multi-instance over it
faulted the element instead of running once per item. BindScope now declares an
Elsa Variable for each document variable, seeding the declared default as the
JsonElement it already is.

BpmnActivityBindingFormat.Read silently let a second <elsa:input name="..."> with
a duplicate name overwrite the first rather than refusing it, unlike every other
malformed-document case this binder already refuses. It now throws
BpmnBindingException naming the binding and the duplicated input, and the XML doc
now states that rule plus the (verified) XML text-node escaping that already
applies to input JSON.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(bpmn): carry every declared activity input through the binding format

BpmnActivityBindingFormat.Write only found properties whose CLR type derives
from Input, silently dropping attribute-declared inputs like Switch.Cases from
an export. Read accepted any <elsa:input name="..."> without checking the
activity declares it, so a mistyped or stale name imported silently with the
configuration missing since Elsa's deserializer ignores unknown members. Both
now go through IActivityDescriber.GetInputProperties, the same enumeration
ActivityDescriptor.Inputs is built from, so Write and Read agree on what an
activity's inputs are and Read refuses a name that enumeration does not
report.

Also makes BpmnWorkBinder.RefuseUnusedDeclarations filter its loop explicitly
with .Where(...) instead of an implicit if, per static analysis.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* refactor(bpmn): filter undeclared input names explicitly

Express the undeclared-input-name check as an explicit Where filter
instead of an implicit filter inside the loop body, and report every
undeclared name at once rather than only the first. Also fix the
refusal message, which previously named the activity type twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(bpmn): describe the input payload shape accurately

The XML doc on BpmnActivityBindingFormat claimed every <elsa:input> is the
{"typeName":...,"expression":...} wrapper a stored workflow definition uses.
That only holds for Input<T>-typed properties: an [Input]-attributed
plain-typed property such as Switch.Cases is serialized as its own JSON
shape (an array), not the wrapper, which Write already does correctly and
the round-trip test already covers. Correct the doc to describe the payload
as the configured activity serializer's output for that input, dependent on
how the activity declares it, and add a second short example showing the
attribute-declared shape.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 17:38:03 +02:00
..
Elsa.Activities.UnitTests Add OpenTelemetry workflow instrumentation (#7514) 2026-05-22 01:17:05 +02:00
Elsa.AI.Abstractions.UnitTests Implement Weaver AI Copilot core (#7523) 2026-06-04 11:35:44 +02:00
Elsa.AI.Copilot.UnitTests Use Copilot SDK for Weaver agent loop (#7700) 2026-06-08 00:35:47 +02:00
Elsa.AI.Host.UnitTests Increase AI host test coverage 2026-06-27 04:04:39 +02:00
Elsa.AI.Persistence.EFCore.UnitTests chore: apply safe dependency upgrades (#7896) 2026-07-26 21:42:27 +02:00
Elsa.Bpmn.Interchange.UnitTests feat(bpmn): the work binder and the elsa: binding format (#7946) 2026-08-14 17:38:03 +02:00
Elsa.Bpmn.UnitTests feat(bpmn): the BpmnProcess container activity (#7945) 2026-08-14 12:37:35 +02:00
Elsa.Common.UnitTests refactor: update package reference configuration 2026-08-03 13:15:18 +02:00
Elsa.Dashboard.Api.UnitTests [codex] Extract dashboard contributors into companion modules (#7692) 2026-06-05 14:30:52 +02:00
Elsa.Diagnostics.ConsoleLogs.UnitTests [codex] Fix diagnostics live feed regressions (#7548) 2026-05-31 09:40:02 +02:00
Elsa.Diagnostics.OpenTelemetry.UnitTests [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Elsa.Diagnostics.StructuredLogs.Persistence.Relational.UnitTests Fix structured log diagnostics registration 2026-05-17 08:42:23 +02:00
Elsa.Diagnostics.StructuredLogs.UnitTests Add structured log provider tests (#7449) 2026-05-16 09:23:31 +02:00
Elsa.Expressions.UnitTests [codex] Harden C# expression host-code execution (#7519) 2026-05-21 00:50:25 +02:00
Elsa.ExternalAuthentication.UnitTests Harden external identity race compensation 2026-08-02 23:19:49 +02:00
Elsa.Hosting.Management.UnitTests feat: introduce HTTP webhooks module 2026-08-03 02:08:15 +02:00
Elsa.Http.UnitTests Fix scheduling startup backlog catch-up 2026-06-21 19:43:09 +02:00
Elsa.Identity.UnitTests Harden external identity race compensation 2026-08-02 23:19:49 +02:00
Elsa.Mediator.UnitTests [codex] Fix diagnostics live feed regressions (#7548) 2026-05-31 09:40:02 +02:00
Elsa.Persistence.EFCore.UnitTests test: cover Oracle bulk upsert SQL generation 2026-07-11 14:35:36 +02:00
Elsa.Persistence.VNext.UnitTests chore: apply safe dependency upgrades (#7896) 2026-07-26 21:42:27 +02:00
Elsa.Platform.Integration.UnitTests Add Platform integration 2026-06-18 18:27:27 +02:00
Elsa.Resilience.Core.UnitTests Enhances distributed lock handling with resilience (#7161) 2025-12-29 19:53:48 +01:00
Elsa.SasTokens.UnitTests [codex] Harden initial security remediation slice (#7495) 2026-05-22 00:45:47 +02:00
Elsa.Scheduling.UnitTests address greptile review feedback (greploop iteration 1) 2026-06-21 19:43:09 +02:00
Elsa.Secrets.UnitTests Implement secret update functionality, add related tests, and update project references. 2026-06-01 23:47:05 +02:00
Elsa.Shells.Api.Tests feat: introduce HTTP webhooks module 2026-08-03 02:08:15 +02:00
Elsa.Tenants.UnitTests fix: restore request services after tenant middleware exceptions 2026-07-30 09:54:00 +03:00
Elsa.Workflows.Api.UnitTests Merge release/3.8.0 into main 2026-08-14 11:59:35 +02:00
Elsa.Workflows.Core.UnitTests Merge release/3.8.0 into main 2026-08-14 11:59:35 +02:00
Elsa.Workflows.Management.UnitTests Merge release/3.8.0 into main 2026-08-14 11:59:35 +02:00
Elsa.Workflows.Runtime.UnitTests Merge branch 'codex/auth-refinements' into release/3.8.0 2026-08-02 22:39:54 +02:00
Directory.Build.props