• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aspectran / aspectran / #4732

30 Oct 2025 02:29PM UTC coverage: 37.85% (+0.2%) from 37.648%
#4732

push

github

topframe
Refactor AsEL evaluation, fix runtime bug, and enhance tests

This commit introduces a major refactoring to the AsEL evaluation mechanism to fix a critical bug, improve the overall design, and enhance test coverage.

The core issue was that tokens parsed at runtime (e.g., via `TokenParser.parse()`) could not be evaluated if they used directives like `#{field:...}`. This was because the token's `valueProvider` was only resolved during the initial configuration parsing phase.

Key changes:

- **Fix Runtime Token Evaluation:**
  The `TokenEvaluation.getBean()` method is now self-sufficient. It detects when a token's `valueProvider` is unresolved and resolves it on-the-fly using the current activity's class loader. This ensures that dynamically parsed tokens have the same capabilities as statically parsed ones.

- **Implement Strategy Pattern:**
  A `ValueProvider` interface and strategy classes (`FieldValueProvider`, etc.) have been introduced in a new `asel.bean` package. This encapsulates evaluation logic for different bean directive types, removing a large `if/else` block from `TokenEvaluation` and making the design cleaner and more extensible.

- **Centralize and Clean Up Logic:**
  - The `valueProvider` field in `Token` is now strongly-typed.
  - Duplicated logic in `RuleParsingContext` was removed by delegating to the central `Token.resolveValueProvider()` method.
  - Manual `valueProvider` resolution in `AbstractShellService` is no longer needed, which also fixes a class loader inconsistency issue.
  - `BeanReferenceInspector` was updated to work with the new `ValueProvider` strategies.

- **Enhance Test Coverage:**
  `TokenEvaluationTest` was significantly improved with new tests for bean (`#id`, `#class:`, `#field:`), property (`%`), and enum token evaluation, ensuring the new logic is correctly verified.

40 of 84 new or added lines in 8 files covered. (47.62%)

169 existing lines in 10 files now uncovered.

15677 of 41419 relevant lines covered (37.85%)

0.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.76
/core/src/main/java/com/aspectran/core/context/rule/parsing/RuleParsingContext.java


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc