Skip to content

test(admin): add unit tests for VariableUtils - #4779

Open
gaoxiaolei-s59 wants to merge 1 commit into
alibaba:mainfrom
gaoxiaolei-s59:test-admin-variable-utils
Open

test(admin): add unit tests for VariableUtils#4779
gaoxiaolei-s59 wants to merge 1 commit into
alibaba:mainfrom
gaoxiaolei-s59:test-admin-variable-utils

Conversation

@gaoxiaolei-s59

Copy link
Copy Markdown
Contributor

Why

spring-ai-alibaba-admin-server-core's VariableUtils implements the variable-resolution core used by workflow nodes — ${...} expression parsing, nested payload path get/set, workflow-context resolution (valueFrom input/refer), type coercion (convertValueByType), and variable identification in prompt text — but currently has no test coverage.

What

Adds VariableUtilsTests (32 tests, pure JUnit 5, no mocks) covering every public method:

  • getExpressionFromBracket: wrapper stripping, plain expressions, blank input
  • getValueFromPayload / getValueStringFromPayload: top-level and nested paths, missing paths, illegal-character expressions, scalar vs JSON stringification
  • setValueForPayload: top-level/nested writes, invalid input
  • getValueFromContext / getValueStringFromContext: input vs refer sources, blank valueFrom default, payload-expression fallback, null handling
  • convertValueByType: String/Number/Boolean/Object/typed arrays, null passthrough, BizException on unconvertible values
  • identifyVariableListFromText / identifyVariableSetFromText: ordering, duplicates, deduplication, no-variable text

Verification

mvn -pl spring-ai-alibaba-admin-server-core -am test -Dtest=VariableUtilsTests
Tests run: 32, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS

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