Add initial action to repository config

- Now RepositoryState can have initial action
  if it is an initial state.
- Implement all needed tests.
- Fixes #281
This commit is contained in:
Janne Valkealahti
2016-11-23 13:55:52 +00:00
parent ea511b8ed8
commit 0c3ea7fb2d
10 changed files with 188 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Reference;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
import org.springframework.statemachine.data.RepositoryAction;
import org.springframework.statemachine.data.RepositoryState;
import org.springframework.statemachine.state.PseudoStateKind;
@@ -59,6 +60,9 @@ public class RedisRepositoryState extends RepositoryState {
@Reference
private RedisRepositoryState parentState;
@Reference
private RedisRepositoryAction initialAction;
@Reference
private Set<RedisRepositoryAction> stateActions;
@@ -194,6 +198,15 @@ public class RedisRepositoryState extends RepositoryState {
this.initial = initial;
}
@Override
public RepositoryAction getInitialAction() {
return initialAction;
}
public void setInitialAction(RedisRepositoryAction initialAction) {
this.initialAction = initialAction;
}
@Override
public Set<RedisRepositoryAction> getStateActions() {
return stateActions;

View File

@@ -0,0 +1,27 @@
[
{
"@id": "1",
"_class": "org.springframework.statemachine.data.redis.RedisRepositoryAction",
"spel": "extendedState.variables.put('foo', 0)"
},
{
"@id": "2",
"_class": "org.springframework.statemachine.data.redis.RedisRepositoryState",
"initial": true,
"initialAction" : "1",
"state": "S1"
},
{
"@id": "3",
"_class": "org.springframework.statemachine.data.redis.RedisRepositoryState",
"initial": false,
"state": "S2"
},
{
"_class": "org.springframework.statemachine.data.redis.RedisRepositoryTransition",
"source": "2",
"target": "3",
"event": "E1",
"kind": "EXTERNAL"
}
]