Lift requirement of enums for states and events

- Relasing the use of enums where applicable
- Fixes #69
This commit is contained in:
Janne Valkealahti
2015-06-03 18:26:21 +01:00
parent 7dc56c4867
commit 1648b39de1
39 changed files with 597 additions and 296 deletions

View File

@@ -23,7 +23,7 @@ import org.springframework.statemachine.support.AbstractStateMachine;
import org.springframework.statemachine.transition.Transition;
/**
* Specialisation of a {@link StateMachine} using enums
* Specialisation of a {@link StateMachine} using objects
* as its {@link State} and event types.
*
* @author Janne Valkealahti
@@ -31,7 +31,7 @@ import org.springframework.statemachine.transition.Transition;
* @param <S> the type of state
* @param <E> the type of event
*/
public class EnumStateMachine<S extends Enum<S>, E extends Enum<E>> extends AbstractStateMachine<S, E> {
public class ObjectStateMachine<S, E> extends AbstractStateMachine<S, E> {
/**
* Instantiates a new enum state machine.
@@ -40,7 +40,7 @@ public class EnumStateMachine<S extends Enum<S>, E extends Enum<E>> extends Abst
* @param transitions the transitions
* @param initialState the initial state
*/
public EnumStateMachine(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions,
public ObjectStateMachine(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions,
State<S, E> initialState) {
super(states, transitions, initialState);
}
@@ -55,7 +55,7 @@ public class EnumStateMachine<S extends Enum<S>, E extends Enum<E>> extends Abst
* @param initialEvent the initial event
* @param extendedState the extended state
*/
public EnumStateMachine(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions,
public ObjectStateMachine(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions,
State<S, E> initialState, Transition<S, E> initialTransition,
Message<E> initialEvent, ExtendedState extendedState) {
super(states, transitions, initialState, initialTransition, initialEvent, extendedState);

View File

@@ -0,0 +1,81 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.statemachine.config;
import org.springframework.statemachine.config.builders.StateMachineConfigBuilder;
import org.springframework.statemachine.config.builders.StateMachineConfigurer;
import org.springframework.statemachine.config.builders.StateMachineStateBuilder;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder;
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
import org.springframework.statemachine.config.common.annotation.AnnotationBuilder;
import org.springframework.statemachine.config.common.annotation.ObjectPostProcessor;
/**
* Adapter base implementation for {@link StateMachineConfigurer}.
*
* @author Janne Valkealahti
*
* @param <S> the type of state
* @param <E> the type of event
*/
public abstract class AbstractStateMachineConfigurerAdapter<S, E> implements StateMachineConfigurer<S, E> {
private StateMachineTransitionBuilder<S, E> transitionBuilder;
private StateMachineStateBuilder<S, E> stateBuilder;
@Override
public final void init(StateMachineConfigBuilder<S, E> config) throws Exception {
config.setSharedObject(StateMachineTransitionBuilder.class, getStateMachineTransitionBuilder());
config.setSharedObject(StateMachineStateBuilder.class, getStateMachineStateBuilder());
}
@Override
public void configure(StateMachineConfigBuilder<S, E> config) throws Exception {
}
@Override
public void configure(StateMachineStateConfigurer<S, E> states) throws Exception {
}
@Override
public void configure(StateMachineTransitionConfigurer<S, E> transitions) throws Exception {
}
@Override
public boolean isAssignable(AnnotationBuilder<StateMachineConfig<S, E>> builder) {
return builder instanceof StateMachineConfigBuilder;
}
protected final StateMachineTransitionBuilder<S, E> getStateMachineTransitionBuilder() throws Exception {
if (transitionBuilder != null) {
return transitionBuilder;
}
transitionBuilder = new StateMachineTransitionBuilder<S, E>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configure(transitionBuilder);
return transitionBuilder;
}
protected final StateMachineStateBuilder<S, E> getStateMachineStateBuilder() throws Exception {
if (stateBuilder != null) {
return stateBuilder;
}
stateBuilder = new StateMachineStateBuilder<S, E>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configure(stateBuilder);
return stateBuilder;
}
}

View File

@@ -25,7 +25,8 @@ import java.util.Map.Entry;
import java.util.Stack;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.messaging.Message;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.builders.StateMachineStates;
@@ -36,7 +37,6 @@ import org.springframework.statemachine.region.Region;
import org.springframework.statemachine.state.ChoicePseudoState;
import org.springframework.statemachine.state.ChoicePseudoState.ChoiceStateData;
import org.springframework.statemachine.state.DefaultPseudoState;
import org.springframework.statemachine.state.EnumState;
import org.springframework.statemachine.state.ForkPseudoState;
import org.springframework.statemachine.state.HistoryPseudoState;
import org.springframework.statemachine.state.JoinPseudoState;
@@ -70,7 +70,7 @@ import org.springframework.util.ObjectUtils;
* @param <S> the type of state
* @param <E> the type of event
*/
public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> extends LifecycleObjectSupport implements
public abstract class AbstractStateMachineFactory<S, E> extends LifecycleObjectSupport implements
StateMachineFactory<S, E> {
private final StateMachineTransitions<S, E> stateMachineTransitions;
@@ -85,7 +85,7 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
* @param stateMachineTransitions the state machine transitions
* @param stateMachineStates the state machine states
*/
public EnumStateMachineFactory(StateMachineTransitions<S, E> stateMachineTransitions,
public AbstractStateMachineFactory(StateMachineTransitions<S, E> stateMachineTransitions,
StateMachineStates<S, E> stateMachineStates) {
this.stateMachineTransitions = stateMachineTransitions;
this.stateMachineStates = stateMachineStates;
@@ -162,15 +162,8 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
Collection<State<S, E>> states = new ArrayList<State<S, E>>();
states.add(rstate);
Transition<S, E> initialTransition = new InitialTransition<S, E>(rstate);
EnumStateMachine<S, E> m = new EnumStateMachine<S, E>(states, new ArrayList<Transition<S, E>>(), rstate,
initialTransition, null, defaultExtendedState);
if (contextEvents != null) {
m.setContextEventsEnabled(contextEvents);
}
if (getBeanFactory() != null) {
m.setBeanFactory(getBeanFactory());
}
m.afterPropertiesSet();
StateMachine<S, E> m = buildStateMachineInternal(states, new ArrayList<Transition<S, E>>(), rstate,
initialTransition, null, defaultExtendedState, null, contextEvents, getBeanFactory());
machine = m;
}
} else {
@@ -284,7 +277,7 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
}
private static <S extends Enum<S>, E extends Enum<E>> StateMachine<S, E> buildMachine(
private StateMachine<S, E> buildMachine(
Map<Object, StateMachine<S, E>> machineMap, Map<S, State<S, E>> stateMap,
Collection<StateData<S, E>> stateDatas, Collection<TransitionData<S, E>> transitionsData,
BeanFactory beanFactory, Boolean contextEvents, DefaultExtendedState defaultExtendedState,
@@ -340,8 +333,8 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
} else if (stateData.getPseudoStateKind() == PseudoStateKind.CHOICE) {
continue;
}
state = new EnumState<S, E>(stateData.getState(), stateData.getDeferred(),
stateData.getEntryActions(), stateData.getExitActions(), pseudoState);
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
stateData.getExitActions(), pseudoState);
if (stateData.isInitial()) {
initialState = state;
initialAction = stateData.getInitialAction();
@@ -361,8 +354,8 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
choices.add(new ChoiceStateData<S, E>(stateMap.get(c.getTarget()), c.getGuard()));
}
PseudoState<S, E> pseudoState = new ChoicePseudoState<S, E>(choices);
state = new EnumState<S, E>(stateData.getState(), stateData.getDeferred(),
stateData.getEntryActions(), stateData.getExitActions(), pseudoState);
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
stateData.getExitActions(), pseudoState);
states.add(state);
stateMap.put(stateData.getState(), state);
} else if (stateData.getPseudoStateKind() == PseudoStateKind.FORK) {
@@ -373,8 +366,8 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
forks.add(stateMap.get(fs));
}
PseudoState<S, E> pseudoState = new ForkPseudoState<S, E>(forks);
state = new EnumState<S, E>(stateData.getState(), stateData.getDeferred(),
stateData.getEntryActions(), stateData.getExitActions(), pseudoState);
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
stateData.getExitActions(), pseudoState);
states.add(state);
stateMap.put(stateData.getState(), state);
} else if (stateData.getPseudoStateKind() == PseudoStateKind.JOIN) {
@@ -404,8 +397,8 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
}
}
JoinPseudoState<S, E> pseudoState = new JoinPseudoState<S, E>(joins);
state = new EnumState<S, E>(stateData.getState(), stateData.getDeferred(),
stateData.getEntryActions(), stateData.getExitActions(), pseudoState);
state = buildStateInternal(stateData.getState(), stateData.getDeferred(), stateData.getEntryActions(),
stateData.getExitActions(), pseudoState);
states.add(state);
stateMap.put(stateData.getState(), state);
@@ -457,19 +450,18 @@ public class EnumStateMachineFactory<S extends Enum<S>, E extends Enum<E>> exten
}
Transition<S, E> initialTransition = new InitialTransition<S, E>(initialState, initialAction);
EnumStateMachine<S, E> machine = new EnumStateMachine<S, E>(states, transitions, initialState,
initialTransition, null, defaultExtendedState);
machine.setHistoryState(historyState);
if (contextEvents != null) {
machine.setContextEventsEnabled(contextEvents);
}
if (beanFactory != null) {
machine.setBeanFactory(beanFactory);
}
machine.afterPropertiesSet();
StateMachine<S, E> machine = buildStateMachineInternal(states, transitions, initialState, initialTransition, null,
defaultExtendedState, historyState, contextEvents, beanFactory);
return machine;
}
protected abstract StateMachine<S, E> buildStateMachineInternal(Collection<State<S, E>> states, Collection<Transition<S, E>> transitions,
State<S, E> initialState, Transition<S, E> initialTransition,
Message<E> initialEvent, ExtendedState extendedState, PseudoState<S, E> historyState, Boolean contextEventsEnabled, BeanFactory beanFactory);
protected abstract State<S, E> buildStateInternal(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
PseudoState<S, E> pseudoState);
private Iterator<Node<StateData<S, E>>> buildStateDataIterator() {
Tree<StateData<S, E>> tree = new Tree<StateData<S, E>>();

View File

@@ -15,6 +15,16 @@
*/
package org.springframework.statemachine.config;
import org.springframework.statemachine.config.builders.StateMachineConfigurer;
/**
* Base implementation of a {@link StateMachineConfigurer} using enums.
*
* @author Janne Valkealahti
*
* @param <S> the type of state
* @param <E> the type of event
*/
public class EnumStateMachineConfigurerAdapter<S extends Enum<S>, E extends Enum<E>> extends StateMachineConfigurerAdapter<S, E> {
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.statemachine.config;
import java.util.Collection;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.messaging.Message;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.builders.StateMachineStates;
import org.springframework.statemachine.config.builders.StateMachineTransitions;
import org.springframework.statemachine.state.ObjectState;
import org.springframework.statemachine.state.PseudoState;
import org.springframework.statemachine.state.State;
import org.springframework.statemachine.transition.Transition;
/**
* Implementation of a {@link StateMachineFactory} which know the actual types of
* {@link State} and {@link StateMachine}.
*
* @author Janne Valkealahti
*
* @param <S> the type of state
* @param <E> the type of event
*/
public class ObjectStateMachineFactory<S, E> extends AbstractStateMachineFactory<S, E> {
public ObjectStateMachineFactory(StateMachineTransitions<S, E> stateMachineTransitions,
StateMachineStates<S, E> stateMachineStates) {
super(stateMachineTransitions, stateMachineStates);
}
@Override
protected StateMachine<S, E> buildStateMachineInternal(Collection<State<S, E>> states,
Collection<Transition<S, E>> transitions, State<S, E> initialState, Transition<S, E> initialTransition,
Message<E> initialEvent, ExtendedState extendedState, PseudoState<S, E> historyState, Boolean contextEventsEnabled, BeanFactory beanFactory) {
ObjectStateMachine<S, E> machine = new ObjectStateMachine<S, E>(states, transitions, initialState, initialTransition, initialEvent,
extendedState);
machine.setHistoryState(historyState);
if (contextEventsEnabled != null) {
machine.setContextEventsEnabled(contextEventsEnabled);
}
if (beanFactory != null) {
machine.setBeanFactory(beanFactory);
}
machine.afterPropertiesSet();
return machine;
}
@Override
protected State<S, E> buildStateInternal(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions,
Collection<? extends Action<S, E>> exitActions, PseudoState<S, E> pseudoState) {
return new ObjectState<S, E>(id, deferred, entryActions, exitActions, pseudoState);
}
}

View File

@@ -15,67 +15,16 @@
*/
package org.springframework.statemachine.config;
import org.springframework.statemachine.config.builders.StateMachineConfigBuilder;
import org.springframework.statemachine.config.builders.StateMachineConfigurer;
import org.springframework.statemachine.config.builders.StateMachineStateBuilder;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
import org.springframework.statemachine.config.builders.StateMachineTransitionBuilder;
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
import org.springframework.statemachine.config.common.annotation.AnnotationBuilder;
import org.springframework.statemachine.config.common.annotation.ObjectPostProcessor;
/**
* Adapter implementation for {@link StateMachineConfigurer}.
*
* Base implementation of a {@link StateMachineConfigurer} using objects.
*
* @author Janne Valkealahti
*
* @param <S> the type of state
* @param <E> the type of event
*/
public class StateMachineConfigurerAdapter<S, E> implements StateMachineConfigurer<S, E> {
private StateMachineTransitionBuilder<S, E> transitionBuilder;
private StateMachineStateBuilder<S, E> stateBuilder;
@Override
public final void init(StateMachineConfigBuilder<S, E> config) throws Exception {
config.setSharedObject(StateMachineTransitionBuilder.class, getStateMachineTransitionBuilder());
config.setSharedObject(StateMachineStateBuilder.class, getStateMachineStateBuilder());
}
@Override
public void configure(StateMachineConfigBuilder<S, E> config) throws Exception {
}
@Override
public void configure(StateMachineStateConfigurer<S, E> states) throws Exception {
}
@Override
public void configure(StateMachineTransitionConfigurer<S, E> transitions) throws Exception {
}
@Override
public boolean isAssignable(AnnotationBuilder<StateMachineConfig<S, E>> builder) {
return builder instanceof StateMachineConfigBuilder;
}
protected final StateMachineTransitionBuilder<S, E> getStateMachineTransitionBuilder() throws Exception {
if (transitionBuilder != null) {
return transitionBuilder;
}
transitionBuilder = new StateMachineTransitionBuilder<S, E>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configure(transitionBuilder);
return transitionBuilder;
}
protected final StateMachineStateBuilder<S, E> getStateMachineStateBuilder() throws Exception {
if (stateBuilder != null) {
return stateBuilder;
}
stateBuilder = new StateMachineStateBuilder<S, E>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
configure(stateBuilder);
return stateBuilder;
}
public class StateMachineConfigurerAdapter<S extends Object, E extends Object> extends AbstractStateMachineConfigurerAdapter<S, E> {
}

View File

@@ -26,7 +26,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineFactory;
import org.springframework.statemachine.config.ObjectStateMachineFactory;
import org.springframework.statemachine.config.StateMachineConfig;
import org.springframework.statemachine.config.builders.StateMachineConfigBuilder;
import org.springframework.statemachine.config.builders.StateMachineStates;
@@ -45,7 +45,7 @@ public class StateMachineConfiguration<S extends Enum<S>, E extends Enum<E>> ext
protected BeanDefinition buildBeanDefinition(AnnotationMetadata importingClassMetadata,
Class<? extends Annotation> namedAnnotation) throws Exception {
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder
.rootBeanDefinition(StateMachineDelegatingFactoryBean2.class);
.rootBeanDefinition(StateMachineDelegatingFactoryBean.class);
AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(
EnableStateMachine.class.getName(), false));
Boolean contextEvents = attributes.getBoolean("contextEvents");
@@ -64,13 +64,13 @@ public class StateMachineConfiguration<S extends Enum<S>, E extends Enum<E>> ext
return types;
}
private static class StateMachineDelegatingFactoryBean2<S extends Enum<S>, E extends Enum<E>>
private static class StateMachineDelegatingFactoryBean<S extends Enum<S>, E extends Enum<E>>
extends BeanDelegatingFactoryBean<StateMachine<S, E>,StateMachineConfigBuilder<S, E>,StateMachineConfig<S, E>> {
private String clazzName;
private Boolean contextEvents;
public StateMachineDelegatingFactoryBean2(StateMachineConfigBuilder<S, E> builder, Class<StateMachine<S, E>> clazz,
public StateMachineDelegatingFactoryBean(StateMachineConfigBuilder<S, E> builder, Class<StateMachine<S, E>> clazz,
String clazzName, Boolean contextEvents) {
super(builder, clazz);
this.clazzName = clazzName;
@@ -88,7 +88,7 @@ public class StateMachineConfiguration<S extends Enum<S>, E extends Enum<E>> ext
StateMachineConfig<S, E> stateMachineConfig = getBuilder().getOrBuild();
StateMachineTransitions<S, E> stateMachineTransitions = stateMachineConfig.getTransitions();
StateMachineStates<S, E> stateMachineStates = stateMachineConfig.getStates();
EnumStateMachineFactory<S, E> stateMachineFactory = new EnumStateMachineFactory<S, E>(
ObjectStateMachineFactory<S, E> stateMachineFactory = new ObjectStateMachineFactory<S, E>(
stateMachineTransitions, stateMachineStates);
stateMachineFactory.setBeanFactory(getBeanFactory());
stateMachineFactory.setContextEventsEnabled(contextEvents);

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.statemachine.config.EnableStateMachineFactory;
import org.springframework.statemachine.config.EnumStateMachineFactory;
import org.springframework.statemachine.config.ObjectStateMachineFactory;
import org.springframework.statemachine.config.StateMachineConfig;
import org.springframework.statemachine.config.StateMachineFactory;
import org.springframework.statemachine.config.builders.StateMachineConfigBuilder;
@@ -109,7 +109,7 @@ public class StateMachineFactoryConfiguration<S extends Enum<S>, E extends Enum<
StateMachineConfig<S, E> stateMachineConfig = builder.getOrBuild();
StateMachineTransitions<S, E> stateMachineTransitions = stateMachineConfig.getTransitions();
StateMachineStates<S, E> stateMachineStates = stateMachineConfig.getStates();
EnumStateMachineFactory<S,E> enumStateMachineFactory = new EnumStateMachineFactory<S, E>(stateMachineTransitions, stateMachineStates);
ObjectStateMachineFactory<S,E> enumStateMachineFactory = new ObjectStateMachineFactory<S, E>(stateMachineTransitions, stateMachineStates);
enumStateMachineFactory.setBeanFactory(beanFactory);
enumStateMachineFactory.setContextEventsEnabled(contextEvents);
this.stateMachineFactory = enumStateMachineFactory;

View File

@@ -17,7 +17,6 @@ package org.springframework.statemachine.state;
import java.util.Collection;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.region.Region;
@@ -30,7 +29,7 @@ import org.springframework.statemachine.region.Region;
* @param <S> the type of state
* @param <E> the type of event
*/
public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSimpleState<S, E> {
public class EnumState<S extends Enum<S>, E extends Enum<E>> extends ObjectState<S, E> {
/**
* Instantiates a new enum state.
@@ -117,30 +116,4 @@ public class EnumState<S extends Enum<S>, E extends Enum<E>> extends AbstractSim
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
}
@Override
public void exit(StateContext<S, E> context) {
Collection<? extends Action<S, E>> actions = getExitActions();
if (actions != null) {
for (Action<S, E> action : actions) {
action.execute(context);
}
}
}
@Override
public void entry(StateContext<S, E> context) {
Collection<? extends Action<S, E>> actions = getEntryActions();
if (actions != null) {
for (Action<S, E> action : actions) {
action.execute(context);
}
}
}
@Override
public String toString() {
return "EnumState [getIds()=" + getIds() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
+ ", toString()=" + super.toString() + "]";
}
}

View File

@@ -0,0 +1,146 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.statemachine.state;
import java.util.Collection;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.region.Region;
/**
* A {@link State} implementation where state and event is object based.
*
* @author Janne Valkealahti
*
* @param <S> the type of state
* @param <E> the type of event
*/
public class ObjectState<S, E> extends AbstractSimpleState<S, E> {
/**
* Instantiates a new object state.
*
* @param id the id
*/
public ObjectState(S id) {
super(id);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param pseudoState the pseudo state
*/
public ObjectState(S id, PseudoState<S, E> pseudoState) {
super(id, pseudoState);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param deferred the deferred
*/
public ObjectState(S id, Collection<E> deferred) {
super(id, deferred);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param deferred the deferred
* @param entryActions the entry actions
* @param exitActions the exit actions
*/
public ObjectState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions) {
super(id, deferred, entryActions, exitActions);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param deferred the deferred
* @param entryActions the entry actions
* @param exitActions the exit actions
* @param pseudoState the pseudo state
*/
public ObjectState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
PseudoState<S, E> pseudoState) {
super(id, deferred, entryActions, exitActions, pseudoState);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param deferred the deferred
* @param entryActions the entry actions
* @param exitActions the exit actions
* @param pseudoState the pseudo state
* @param regions the regions
*/
public ObjectState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
PseudoState<S, E> pseudoState, Collection<Region<S, E>> regions) {
super(id, deferred, entryActions, exitActions, pseudoState, regions);
}
/**
* Instantiates a new object state.
*
* @param id the id
* @param deferred the deferred
* @param entryActions the entry actions
* @param exitActions the exit actions
* @param pseudoState the pseudo state
* @param submachine the submachine
*/
public ObjectState(S id, Collection<E> deferred, Collection<? extends Action<S, E>> entryActions, Collection<? extends Action<S, E>> exitActions,
PseudoState<S, E> pseudoState, StateMachine<S, E> submachine) {
super(id, deferred, entryActions, exitActions, pseudoState, submachine);
}
@Override
public void exit(StateContext<S, E> context) {
Collection<? extends Action<S, E>> actions = getExitActions();
if (actions != null) {
for (Action<S, E> action : actions) {
action.execute(context);
}
}
}
@Override
public void entry(StateContext<S, E> context) {
Collection<? extends Action<S, E>> actions = getEntryActions();
if (actions != null) {
for (Action<S, E> action : actions) {
action.execute(context);
}
}
}
@Override
public String toString() {
return "ObjectState [getIds()=" + getIds() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode()
+ ", toString()=" + super.toString() + "]";
}
}

View File

@@ -75,7 +75,7 @@ public class EnumStateMachineTests extends AbstractStateMachineTests {
transitions.add(transitionFromS2ToS3);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();
@@ -148,7 +148,7 @@ public class EnumStateMachineTests extends AbstractStateMachineTests {
// create machine
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();
@@ -189,7 +189,7 @@ public class EnumStateMachineTests extends AbstractStateMachineTests {
transitions.add(transitionInternalSI);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();

View File

@@ -42,6 +42,7 @@ import org.springframework.statemachine.event.StateMachineEventPublisherConfigur
import org.springframework.statemachine.region.Region;
import org.springframework.statemachine.state.DefaultPseudoState;
import org.springframework.statemachine.state.EnumState;
import org.springframework.statemachine.state.ObjectState;
import org.springframework.statemachine.state.PseudoState;
import org.springframework.statemachine.state.PseudoStateKind;
import org.springframework.statemachine.state.RegionState;
@@ -103,7 +104,7 @@ public class RegionMachineTests extends AbstractStateMachineTests {
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
Transition<TestStates,TestEvents> initialTransition = new InitialTransition<TestStates,TestEvents>(stateSI);
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI, initialTransition, null, null);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI, initialTransition, null, null);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();
@@ -167,7 +168,7 @@ public class RegionMachineTests extends AbstractStateMachineTests {
new DefaultExternalTransition<TestStates,TestEvents>(stateS111, stateS112, null, TestEvents.E2, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E2));
transitions11.add(transitionFromS111ToS112);
Transition<TestStates,TestEvents> initialTransition11 = new InitialTransition<TestStates,TestEvents>(stateS111);
EnumStateMachine<TestStates, TestEvents> machine11 = new EnumStateMachine<TestStates, TestEvents>(states11, transitions11, stateS111, initialTransition11, null, null);
ObjectStateMachine<TestStates, TestEvents> machine11 = new ObjectStateMachine<TestStates, TestEvents>(states11, transitions11, stateS111, initialTransition11, null, null);
machine11.setTaskExecutor(taskExecutor);
machine11.afterPropertiesSet();
@@ -179,7 +180,7 @@ public class RegionMachineTests extends AbstractStateMachineTests {
new DefaultExternalTransition<TestStates,TestEvents>(stateSI, stateS111, null, TestEvents.E3, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E3));
transitions12.add(transitionFromSIToS121);
Transition<TestStates,TestEvents> initialTransition12 = new InitialTransition<TestStates,TestEvents>(stateS121);
EnumStateMachine<TestStates, TestEvents> machine12 = new EnumStateMachine<TestStates, TestEvents>(states12, transitions12, stateS121, initialTransition12, null, null);
ObjectStateMachine<TestStates, TestEvents> machine12 = new ObjectStateMachine<TestStates, TestEvents>(states12, transitions12, stateS121, initialTransition12, null, null);
machine12.setTaskExecutor(taskExecutor);
machine12.afterPropertiesSet();
@@ -195,7 +196,7 @@ public class RegionMachineTests extends AbstractStateMachineTests {
new DefaultExternalTransition<TestStates,TestEvents>(stateSI, stateR, null, TestEvents.E1, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E1));
transitions.add(transitionFromSIToRegionstate);
Transition<TestStates,TestEvents> initialTransition = new InitialTransition<TestStates,TestEvents>(stateR);
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateR, initialTransition, null, null);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateR, initialTransition, null, null);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
@@ -230,8 +231,8 @@ public class RegionMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
TestStateMachineListener listener = context.getBean(TestStateMachineListener.class);
machine.addStateListener(listener);
@@ -260,12 +261,13 @@ public class RegionMachineTests extends AbstractStateMachineTests {
public void testRegionsInNestedState() throws Exception {
context.register(StateMachineEventPublisherConfiguration.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
Collection<Object> states = TestUtils.readField("states", machine);
assertThat(states.size(), is(3));
assertThat(states, containsInAnyOrder(instanceOf(EnumState.class), instanceOf(EnumState.class), instanceOf(RegionState.class)));
assertThat(states, containsInAnyOrder(instanceOf(ObjectState.class), instanceOf(ObjectState.class), instanceOf(RegionState.class)));
TestStateMachineListener listener = context.getBean(TestStateMachineListener.class);
machine.addStateListener(listener);
machine.start();
@@ -281,8 +283,8 @@ public class RegionMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
TestSleepAction action1 = context.getBean("action1", TestSleepAction.class);
TestSleepAction action2 = context.getBean("action2", TestSleepAction.class);
@@ -321,8 +323,8 @@ public class RegionMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
TestSleepAction action1 = context.getBean("action1", TestSleepAction.class);
TestSleepAction action2 = context.getBean("action2", TestSleepAction.class);

View File

@@ -44,8 +44,8 @@ public class RelayTests extends AbstractStateMachineTests {
public void testRelayFromSubmachine() throws Exception {
context.register(Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
TestStateMachineListener listener = new TestStateMachineListener();
machine.addStateListener(listener);

View File

@@ -27,7 +27,7 @@ import org.springframework.core.task.TaskExecutor;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.config.EnableStateMachineFactory;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
import org.springframework.statemachine.config.EnumStateMachineFactory;
import org.springframework.statemachine.config.ObjectStateMachineFactory;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
@@ -38,8 +38,8 @@ public class StateMachineFactoryTests extends AbstractStateMachineTests {
public void testMachineFromFactory() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class);
EnumStateMachineFactory<TestStates, TestEvents> stateMachineFactory =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, EnumStateMachineFactory.class);
ObjectStateMachineFactory<TestStates, TestEvents> stateMachineFactory =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, ObjectStateMachineFactory.class);
StateMachine<TestStates,TestEvents> machine = stateMachineFactory.getStateMachine();
machine.start();

View File

@@ -37,6 +37,7 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
import org.springframework.statemachine.listener.StateMachineListenerAdapter;
@@ -56,8 +57,8 @@ public class StateMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("foo", "jee1").build());
@@ -120,8 +121,8 @@ public class StateMachineTests extends AbstractStateMachineTests {
public void testForkJoin() throws Exception {
context.register(BaseConfig.class, Config3.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
@@ -152,6 +153,28 @@ public class StateMachineTests extends AbstractStateMachineTests {
assertThat(machine.getState().getIds(), containsInAnyOrder(TestStates.S4));
}
@Test
public void testStringStatesAndEvents() throws Exception {
context.register(Config4.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
StateMachine<String, String> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, StateMachine.class);
TestListener2 listener = new TestListener2();
machine.addStateListener(listener);
assertThat(machine, notNullValue());
machine.start();
listener.reset(1);
machine.sendEvent(MessageBuilder.withPayload("E1").setHeader("foo", "jee1").build());
assertThat(listener.stateChangedLatch.await(2, TimeUnit.SECONDS), is(true));
assertThat(listener.stateChangedCount, is(1));
assertThat(machine.getState().getIds(), containsInAnyOrder("S1"));
}
private static class LoggingAction implements Action<TestStates, TestEvents> {
private static final Log log = LogFactory.getLog(StateMachineTests.LoggingAction.class);
@@ -353,6 +376,30 @@ public class StateMachineTests extends AbstractStateMachineTests {
}
@Configuration
@EnableStateMachine
static class Config4 extends StateMachineConfigurerAdapter<String, String> {
@Override
public void configure(StateMachineStateConfigurer<String, String> states) throws Exception {
states
.withStates()
.initial("SI")
.state("S1")
.state("S2");
}
@Override
public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
transitions
.withExternal()
.source("SI")
.target("S1")
.event("E1");
}
}
private static class TestListener extends StateMachineListenerAdapter<TestStates, TestEvents> {
volatile CountDownLatch stateChangedLatch = new CountDownLatch(1);
@@ -382,4 +429,33 @@ public class StateMachineTests extends AbstractStateMachineTests {
}
private static class TestListener2 extends StateMachineListenerAdapter<String, String> {
volatile CountDownLatch stateChangedLatch = new CountDownLatch(1);
volatile CountDownLatch transitionLatch = new CountDownLatch(0);
volatile int stateChangedCount = 0;
@Override
public void stateChanged(State<String, String> from, State<String, String> to) {
stateChangedCount++;
stateChangedLatch.countDown();
}
@Override
public void transition(Transition<String, String> transition) {
transitionLatch.countDown();
}
public void reset(int c1) {
reset(c1, 0);
}
public void reset(int c1, int c2) {
stateChangedLatch = new CountDownLatch(c1);
transitionLatch = new CountDownLatch(c2);
stateChangedCount = 0;
}
}
}

View File

@@ -94,7 +94,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
Collection<State<TestStates,TestEvents>> substates111 = new ArrayList<State<TestStates,TestEvents>>();
substates111.add(stateS111);
Collection<Transition<TestStates,TestEvents>> subtransitions111 = new ArrayList<Transition<TestStates,TestEvents>>();
EnumStateMachine<TestStates, TestEvents> submachine11 = new EnumStateMachine<TestStates, TestEvents>(substates111, subtransitions111, stateS111);
ObjectStateMachine<TestStates, TestEvents> submachine11 = new ObjectStateMachine<TestStates, TestEvents>(substates111, subtransitions111, stateS111);
// submachine 1
TestEntryAction entryActionS11 = new TestEntryAction("S11");
@@ -108,7 +108,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
Collection<State<TestStates,TestEvents>> substates11 = new ArrayList<State<TestStates,TestEvents>>();
substates11.add(stateS11);
Collection<Transition<TestStates,TestEvents>> subtransitions11 = new ArrayList<Transition<TestStates,TestEvents>>();
EnumStateMachine<TestStates, TestEvents> submachine1 = new EnumStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS11);
ObjectStateMachine<TestStates, TestEvents> submachine1 = new ObjectStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS11);
// machine
TestEntryAction entryActionS1 = new TestEntryAction("S1");
@@ -125,7 +125,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
DefaultExternalTransition<TestStates,TestEvents> transitionFromS111ToS1 =
new DefaultExternalTransition<TestStates,TestEvents>(stateS111, stateS1, null, TestEvents.E1, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E1));
transitions.add(transitionFromS111ToS1);
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
@@ -200,7 +200,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
substates11.add(stateS111);
substates11.add(stateS112);
Collection<Transition<TestStates,TestEvents>> subtransitions11 = new ArrayList<Transition<TestStates,TestEvents>>();
EnumStateMachine<TestStates, TestEvents> submachine11 = new EnumStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS111);
ObjectStateMachine<TestStates, TestEvents> submachine11 = new ObjectStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS111);
// machine
TestEntryAction entryActionS1 = new TestEntryAction("S1");
@@ -217,7 +217,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
DefaultExternalTransition<TestStates,TestEvents> transitionFromS111ToS112 =
new DefaultExternalTransition<TestStates,TestEvents>(stateS111, stateS112, null, TestEvents.E1, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E1));
transitions.add(transitionFromS111ToS112);
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
@@ -284,7 +284,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
Collection<State<TestStates,TestEvents>> substates111 = new ArrayList<State<TestStates,TestEvents>>();
substates111.add(stateS111);
Collection<Transition<TestStates,TestEvents>> subtransitions111 = new ArrayList<Transition<TestStates,TestEvents>>();
EnumStateMachine<TestStates, TestEvents> submachine11 = new EnumStateMachine<TestStates, TestEvents>(substates111, subtransitions111, stateS111);
ObjectStateMachine<TestStates, TestEvents> submachine11 = new ObjectStateMachine<TestStates, TestEvents>(substates111, subtransitions111, stateS111);
// submachine 1
TestEntryAction entryActionS11 = new TestEntryAction("S11");
@@ -298,7 +298,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
Collection<State<TestStates,TestEvents>> substates11 = new ArrayList<State<TestStates,TestEvents>>();
substates11.add(stateS11);
Collection<Transition<TestStates,TestEvents>> subtransitions11 = new ArrayList<Transition<TestStates,TestEvents>>();
EnumStateMachine<TestStates, TestEvents> submachine1 = new EnumStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS11);
ObjectStateMachine<TestStates, TestEvents> submachine1 = new ObjectStateMachine<TestStates, TestEvents>(substates11, subtransitions11, stateS11);
// machine
TestEntryAction entryActionS1 = new TestEntryAction("S1");
@@ -315,7 +315,7 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
DefaultLocalTransition<TestStates,TestEvents> transitionFromS11ToS1 =
new DefaultLocalTransition<TestStates,TestEvents>(stateS111, stateS1, null, TestEvents.E1, null, new EventTrigger<TestStates,TestEvents>(TestEvents.E1));
transitions.add(transitionFromS11ToS1);
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateS1);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
@@ -350,8 +350,8 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
@@ -386,8 +386,8 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine, notNullValue());
@@ -400,8 +400,8 @@ public class SubStateMachineTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates2,TestEvents2> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates2,TestEvents2> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine, notNullValue());
assertThat(machine.getState().getIds(), contains(TestStates2.IDLE, TestStates2.CLOSED));

View File

@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -45,8 +45,8 @@ public class MethodAnnotationTests extends AbstractStateMachineTests {
public void testMethodAnnotations() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, BeanConfig1.class, Config1.class);
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(context.containsBean("fooMachine"), is(true));
machine.start();
@@ -66,8 +66,8 @@ public class MethodAnnotationTests extends AbstractStateMachineTests {
public void testMethodAnnotations2() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(BaseConfig.class, BeanConfig2.class, Config1.class);
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(context.containsBean("fooMachine"), is(true));
machine.start();

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
@@ -56,8 +56,8 @@ public class ConfigurationTests extends AbstractStateMachineTests {
context.register(Config1.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
TestAction testAction = context.getBean("testAction", TestAction.class);
TestGuard testGuard = context.getBean("testGuard", TestGuard.class);
@@ -71,8 +71,8 @@ public class ConfigurationTests extends AbstractStateMachineTests {
context.register(Config4.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
}
@@ -82,8 +82,8 @@ public class ConfigurationTests extends AbstractStateMachineTests {
context.register(Config6.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
}
@@ -93,8 +93,8 @@ public class ConfigurationTests extends AbstractStateMachineTests {
context.register(Config7.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
}
@@ -104,8 +104,8 @@ public class ConfigurationTests extends AbstractStateMachineTests {
context.register(Config8.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
}

View File

@@ -28,7 +28,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -53,8 +53,8 @@ public class ContextEventTests extends AbstractStateMachineTests {
public void contextEventsEnabled() throws Exception {
context.register(BaseConfig.class, StateMachineEventPublisherConfiguration.class, Config.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
machine.sendEvent(TestEvents.E1);
StateMachineApplicationEventListener listener = context.getBean(StateMachineApplicationEventListener.class);
@@ -67,8 +67,8 @@ public class ContextEventTests extends AbstractStateMachineTests {
public void contextEventsDisabled() throws Exception {
context.register(BaseConfig.class, StateMachineEventPublisherConfiguration.class, Config.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
machine.sendEvent(TestEvents.E1);
StateMachineApplicationEventListener listener = context.getBean(StateMachineApplicationEventListener.class);

View File

@@ -32,7 +32,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -59,8 +59,8 @@ public class StateMachineEventTests extends AbstractStateMachineTests {
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
TestEventListener listener = context.getBean(TestEventListener.class);
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine, notNullValue());
machine.sendEvent(TestEvents.E1);
@@ -81,8 +81,8 @@ public class StateMachineEventTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine, notNullValue());

View File

@@ -32,7 +32,7 @@ import org.springframework.statemachine.AbstractStateMachineTests.TestAction;
import org.springframework.statemachine.AbstractStateMachineTests.TestEvents;
import org.springframework.statemachine.AbstractStateMachineTests.TestGuard;
import org.springframework.statemachine.AbstractStateMachineTests.TestStates;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -51,8 +51,8 @@ public class GuardTests {
@Test
public void testGuardEvaluated() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestGuard testGuard = ctx.getBean("testGuard", TestGuard.class);
TestAction testAction = ctx.getBean("testAction", TestAction.class);
assertThat(testGuard, notNullValue());
@@ -70,8 +70,8 @@ public class GuardTests {
@Test
public void testGuardDenyAction() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config2.class);
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestGuard testGuard = ctx.getBean("testGuard", TestGuard.class);
TestAction testAction = ctx.getBean("testAction", TestAction.class);
assertThat(testGuard, notNullValue());

View File

@@ -34,7 +34,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -69,8 +69,8 @@ public class SpelExpressionGuardTests extends AbstractStateMachineTests {
public void testGuardDenyStateChange() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(BaseConfig.class, Config1.class);
assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.S1));

View File

@@ -35,7 +35,7 @@ import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
@@ -60,8 +60,8 @@ public class ListenerTests extends AbstractStateMachineTests {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
TestStateMachineListener listener = new TestStateMachineListener();
@@ -87,8 +87,8 @@ public class ListenerTests extends AbstractStateMachineTests {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config2.class);
assertTrue(ctx.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestStateMachineListener listener = new TestStateMachineListener();
machine.addStateListener(listener);

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
@@ -52,8 +52,8 @@ public class AnnotatedMethodTests extends AbstractStateMachineTests {
public void testSimpleMachine() throws Exception {
context.register(Config1.class, BeanConfig1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
Bean1 bean1 = context.getBean(Bean1.class);
machine.start();
assertThat(bean1.onMethod0Latch.await(2, TimeUnit.SECONDS), is(true));
@@ -66,8 +66,8 @@ public class AnnotatedMethodTests extends AbstractStateMachineTests {
public void testRegions() throws Exception {
context.register(Config2.class, BeanConfig1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
Bean1 bean1 = context.getBean(Bean1.class);
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -88,8 +88,8 @@ public class AnnotatedMethodTests extends AbstractStateMachineTests {
public void testViaJoin() throws Exception {
context.register(Config3.class, BeanConfig1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
Bean1 bean1 = context.getBean(Bean1.class);
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -110,8 +110,8 @@ public class AnnotatedMethodTests extends AbstractStateMachineTests {
public void testViaJoinSuper() throws Exception {
context.register(Config4.class, BeanConfig1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
Bean1 bean1 = context.getBean(Bean1.class);
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -132,8 +132,8 @@ public class AnnotatedMethodTests extends AbstractStateMachineTests {
public void testViaForkSuper() throws Exception {
context.register(Config5.class, BeanConfig1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
Bean1 bean1 = context.getBean(Bean1.class);
machine.start();
machine.sendEvent(TestEvents.E1);

View File

@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -49,8 +49,8 @@ public class ChoiceStateTests extends AbstractStateMachineTests {
public void testFirst() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("choice", "s30").build());
@@ -63,8 +63,8 @@ public class ChoiceStateTests extends AbstractStateMachineTests {
public void testThen1() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("choice", "s31").build());
@@ -77,8 +77,8 @@ public class ChoiceStateTests extends AbstractStateMachineTests {
public void testThen2() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).setHeader("choice", "s32").build());
@@ -91,8 +91,8 @@ public class ChoiceStateTests extends AbstractStateMachineTests {
public void testLast() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());

View File

@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -50,8 +50,8 @@ public class EndStateTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine, notNullValue());
assertThat(machine.isComplete(), is(false));
@@ -73,8 +73,8 @@ public class EndStateTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates3,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates3,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
machine.sendEvent(TestEvents.E1);
assertThat(machine.getState().getIds(), contains(TestStates3.READY));
@@ -86,8 +86,8 @@ public class EndStateTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
@SuppressWarnings("unchecked")
EnumStateMachine<TestStates3,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates3,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
machine.sendEvent(TestEvents.E1);
assertThat(machine.getState().getIds(), contains(TestStates3.READY));

View File

@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -50,8 +50,8 @@ public class ForkStateTests extends AbstractStateMachineTests {
public void testForkEventPassed() throws Exception {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
@@ -84,8 +84,8 @@ public class ForkStateTests extends AbstractStateMachineTests {
public void testForkToSuperEventNotPassed() throws Exception {
context.register(BaseConfig.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
@@ -116,8 +116,8 @@ public class ForkStateTests extends AbstractStateMachineTests {
public void testForkToSuperAndSubEventPassed() throws Exception {
context.register(BaseConfig.class, Config3.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -43,8 +43,8 @@ public class HistoryStateTests extends AbstractStateMachineTests {
public void testShallowInSubmachine() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -60,8 +60,8 @@ public class HistoryStateTests extends AbstractStateMachineTests {
public void testDeep() {
context.register(BaseConfig.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -77,8 +77,8 @@ public class HistoryStateTests extends AbstractStateMachineTests {
public void testShallow() {
context.register(BaseConfig.class, Config3.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);

View File

@@ -25,7 +25,7 @@ import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -46,8 +46,8 @@ public class InitialStateTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config1.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.S1));
}
@@ -64,8 +64,8 @@ public class InitialStateTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config3.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.SI));
machine.sendEvent(TestEvents.E1);

View File

@@ -29,7 +29,7 @@ import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
@@ -50,8 +50,8 @@ public class JoinStateTests extends AbstractStateMachineTests {
public void testJoin() throws Exception {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
listener.reset(1);
@@ -83,8 +83,8 @@ public class JoinStateTests extends AbstractStateMachineTests {
public void testJoinLoopTwice() throws Exception {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
assertThat(machine, notNullValue());
@@ -124,8 +124,8 @@ public class JoinStateTests extends AbstractStateMachineTests {
public void testJoinSuper() throws Exception {
context.register(BaseConfig.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
listener.reset(1);
@@ -157,8 +157,8 @@ public class JoinStateTests extends AbstractStateMachineTests {
public void testJoinSuperLoopTwice() throws Exception {
context.register(BaseConfig.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
assertThat(machine, notNullValue());

View File

@@ -25,7 +25,7 @@ import java.util.Collection;
import org.junit.Test;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.region.Region;
import org.springframework.statemachine.transition.DefaultExternalTransition;
import org.springframework.statemachine.transition.Transition;
@@ -69,7 +69,7 @@ public class RegionStateTests extends AbstractStateMachineTests {
transitions.add(transitionFromS2ToS3);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();

View File

@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -50,8 +50,8 @@ public class StateActionTests extends AbstractStateMachineTests {
@SuppressWarnings("unchecked")
public void testStateEntryExit() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config1.class);
EnumStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
ctx.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestExitAction testExitAction = ctx.getBean("testExitAction", TestExitAction.class);
TestEntryAction testEntryAction = ctx.getBean("testEntryAction", TestEntryAction.class);
assertThat(testExitAction, notNullValue());

View File

@@ -28,7 +28,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.TestUtils;
@@ -83,7 +83,7 @@ public class SubmachineStateTests extends AbstractStateMachineTests {
transitions.add(transitionFromS2ToS3);
SyncTaskExecutor taskExecutor = new SyncTaskExecutor();
EnumStateMachine<TestStates, TestEvents> machine = new EnumStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
ObjectStateMachine<TestStates, TestEvents> machine = new ObjectStateMachine<TestStates, TestEvents>(states, transitions, stateSI);
machine.setTaskExecutor(taskExecutor);
machine.afterPropertiesSet();
machine.start();
@@ -103,8 +103,8 @@ public class SubmachineStateTests extends AbstractStateMachineTests {
public void testFromSimpleToOtherSubstate() {
context.register(BaseConfig.class, Config1.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -120,8 +120,8 @@ public class SubmachineStateTests extends AbstractStateMachineTests {
public void testAllSubmachinesRunningInitialsTakesToDeep() throws Exception {
context.register(BaseConfig.class, Config2.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -146,8 +146,8 @@ public class SubmachineStateTests extends AbstractStateMachineTests {
public void testAllSubmachinesRunningInitialsNotTakeToDeep() throws Exception {
context.register(BaseConfig.class, Config3.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);
@@ -172,8 +172,8 @@ public class SubmachineStateTests extends AbstractStateMachineTests {
public void testAllSubmachinesStopped() throws Exception {
context.register(BaseConfig.class, Config3.class);
context.refresh();
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
assertThat(machine, notNullValue());
machine.start();
machine.sendEvent(TestEvents.E1);

View File

@@ -34,7 +34,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.statemachine.AbstractStateMachineTests;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -64,8 +64,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
TestListener listener = new TestListener();
machine.addStateListener(listener);
@@ -86,8 +86,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config3.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.S2));
}
@@ -99,8 +99,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
// end state terminates sm so state is null
assertThat(machine.getState(), nullValue());
@@ -114,8 +114,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config5.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.S1));
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());
@@ -128,8 +128,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config6.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
assertThat(machine.getState().getIds(), contains(TestStates.S1));
machine.sendEvent(MessageBuilder.withPayload(TestEvents.E1).build());
@@ -142,8 +142,8 @@ public class TransitionTests extends AbstractStateMachineTests {
context.register(BaseConfig.class, Config2.class);
context.refresh();
assertTrue(context.containsBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE));
EnumStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
ObjectStateMachine<TestStates,TestEvents> machine =
context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
machine.start();
TestExitAction testExitAction = context.getBean("testExitAction", TestExitAction.class);
TestEntryAction testEntryAction = context.getBean("testEntryAction", TestEntryAction.class);

View File

@@ -33,7 +33,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.listener.StateMachineListener;
@@ -238,7 +238,7 @@ public class CdPlayerTests {
context = new AnnotationConfigApplicationContext();
context.register(CommonConfiguration.class, Application.class, TestConfig.class);
context.refresh();
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
player = context.getBean(CdPlayer.class);
library = context.getBean(Library.class);
listener = context.getBean(TestListener.class);

View File

@@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.listener.StateMachineListener;
@@ -310,7 +310,7 @@ public class ShowcaseTests {
context = new AnnotationConfigApplicationContext();
context.register(CommonConfiguration.class, Application.class, Config.class);
context.refresh();
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
listener = context.getBean(TestListener.class);
machine.start();
}

View File

@@ -31,7 +31,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.listener.StateMachineListener;
@@ -121,7 +121,7 @@ public class TasksTests {
context = new AnnotationConfigApplicationContext();
context.register(CommonConfiguration.class, Application.class, TestConfig.class);
context.refresh();
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
tasks = context.getBean(Tasks.class);
listener = context.getBean(TestListener.class);
machine.start();

View File

@@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.listener.StateMachineListener;
@@ -139,7 +139,7 @@ public class TurnstileTests {
context = new AnnotationConfigApplicationContext();
context.register(CommonConfiguration.class, Application.class, Config.class, StateMachineCommands.class);
context.refresh();
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
listener = context.getBean(TestListener.class);
commands = context.getBean(StateMachineCommands.class);
}

View File

@@ -30,7 +30,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.statemachine.EnumStateMachine;
import org.springframework.statemachine.ObjectStateMachine;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.StateMachineSystemConstants;
import org.springframework.statemachine.listener.StateMachineListener;
@@ -168,7 +168,7 @@ public class WasherTests {
context = new AnnotationConfigApplicationContext();
context.register(CommonConfiguration.class, Application.class, Config.class);
context.refresh();
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, EnumStateMachine.class);
machine = context.getBean(StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, ObjectStateMachine.class);
listener = context.getBean(TestListener.class);
machine.start();
}