zjncs opened a new pull request, #5698:
URL: https://github.com/apache/rocketmq-dashboard/pull/5698
### What
`ToolInvocation` — the pairing of a request context with its handler — had
no test. This adds `ToolInvocationTest` with 5 tests pinning its two
load-bearing contracts.
### Why
The class documents that *input conversion is deferred until the preview or
terminal invocation so failures remain inside the validation and audit chain*.
Nothing pinned that: a refactor that converted eagerly would move
malformed-argument failures outside the audited path silently. The preview type
guard — only a `MutationToolHandler` can preview — was equally unpinned.
### What is pinned
- **deferred conversion**: assembling the invocation with a malformed
argument never throws; the failure surfaces from `execute()` as an
`IllegalArgumentException`;
- `execute()` converts the business input through the handler's input type,
delegates with the untouched context, and returns the handler's result;
- control fields (`dry_run`/`reason`/`confirm_token`) never reach the
handler input;
- `preview()` rejects a non-mutation handler with the
`IllegalStateException` naming the offending tool;
- `preview()` converts the input and delegates to the mutation handler's
preview, returning its plan.
### Verification
- New tests on unmodified code: **5/5 green** (`mvn test
-Dtest=ToolInvocationTest`).
- Discriminating mutations on `ToolInvocation`, build result verified red
each time:
1. the preview type guard removed so a plain handler is cast — the guard
test reddens (ClassCastException instead of the documented
IllegalStateException);
2. preview routed through `execute` instead of the handler's preview — the
delegation test reddens;
3. `invoke` skipping `convertInput` and passing null — caught by the
conversion, control-field, and deferral tests together.
- Restored: 5/5 green. Test-only change; no product code touched.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]