Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The goal of this PR is to provide a way to set and retrieve the current FSM state during testing. In the current implementation, the FSM's state can be retrieved using the FSMConfig, but there is no way to explicitly transition the FSM into a particular state without exposing the FSMBuilder in the main source code.
To address this, the FSM Actor can no longer remain an anonymous class. As a result, the FSM class is now an abstract class that extends Actor.
The newly introduced FSMTestKit serves as a wrapper around the FSM, exposing only the necessary functionality, specifically: currentState and setState. Additionally, a new syntax, fsmTestKit, has been added to convert a ReplyingActor into an FSMTestKit, simplifying state manipulation for testing purposes.
Ideally, this TestKit should be moved into its own test library, perhaps something like cats_actors_testkit, rather than residing in the main cats_actors library. To achieve this, the project would need to be split into two submodules. However, given that we currently only have this class and its associated syntax, it may not be worth the effort at this point in time.
Example