5016

Bind, Run, Rebind

integration-event
bindsubscription
manual-binding
state-lifecycle
test-doubles

Bind, Run, Rebind

Your team ships a small transformation pipeline that deliberately knows nothing about transformations: a caller plugs a transformer into the engine for the duration of one run, runs a batch of items, and unplugs it. The same session then runs the next batch with a different transformer — a pattern you will meet again the day you mock an external dependency in an AL test. The whole exercise is lifecycle discipline: two runs in one session must never see each other's state, and a run that dies halfway must never poison the run that retries after it.

Requirements

Create a codeunit named "Bound Pipeline Engine" with exactly these public procedures and, declared inside the same codeunit, exactly this integration event — the grading tests subscribe to it by this name and signature:

procedure Run(Items: List of [Text])
procedure GetProcessedCount(): Integer
procedure GetResult(Position: Integer): Text

[IntegrationEvent(false, false)]
local procedure OnTransformItem(Item: Text; var Result: Text; var Handled: Boolean)

Engine rules:

  1. Run walks the items in input order and publishes OnTransformItem once per item, with Result empty and Handled false on the way in — for every item, not just the first.
  2. If a subscriber set Handled, the engine appends that item's Result — exactly the text the subscriber wrote, the engine adds nothing of its own — to the run log.
  3. If no subscriber set Handled, the engine raises an error whose text contains No transformer is bound for item X, where X is that item's text (matched as a substring, so extra words around it are fine — the phrase itself is exact).
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 13 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade