OPEN - issue BATCH-679: Non-sequential execution Remove generic features of flow abstraction
This commit is contained in:
@@ -20,7 +20,7 @@ package org.springframework.batch.core.job.flow;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractState<T> implements State<T> {
|
||||
public abstract class AbstractState implements State {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -43,6 +43,6 @@ public abstract class AbstractState<T> implements State<T> {
|
||||
return getClass().getSimpleName()+": name=["+name+"]";
|
||||
}
|
||||
|
||||
public abstract String handle(T context) throws Exception;
|
||||
public abstract String handle(JobFlowExecutor executor) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ package org.springframework.batch.core.job.flow;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class DecisionState extends AbstractState<JobFlowExecutor> {
|
||||
public class DecisionState extends AbstractState {
|
||||
|
||||
private final JobExecutionDecider decider;
|
||||
|
||||
@@ -18,8 +18,8 @@ public class DecisionState extends AbstractState<JobFlowExecutor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(JobFlowExecutor context) throws Exception {
|
||||
return decider.decide(context.getJobExecution(), context.getStepExecution());
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
return decider.decide(executor.getJobExecution(), executor.getStepExecution());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import org.springframework.batch.core.JobExecution;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class EndState extends AbstractState<JobFlowExecutor> {
|
||||
public class EndState extends AbstractState {
|
||||
|
||||
private final BatchStatus status;
|
||||
|
||||
@@ -27,11 +27,11 @@ public class EndState extends AbstractState<JobFlowExecutor> {
|
||||
* is the first place we came after a restart we do nothing (otherwise the
|
||||
* same outcome that ended the job on the last run will occur).
|
||||
*
|
||||
* @see State#handle(Object)
|
||||
* @see State#handle(JobFlowExecutor)
|
||||
*/
|
||||
@Override
|
||||
public String handle(JobFlowExecutor context) throws Exception {
|
||||
JobExecution jobExecution = context.getJobExecution();
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
JobExecution jobExecution = executor.getJobExecution();
|
||||
// If there are no step executions, then we are at the beginning of a
|
||||
// restart
|
||||
if (!jobExecution.getStepExecutions().isEmpty()) {
|
||||
|
||||
@@ -19,9 +19,8 @@ package org.springframework.batch.core.job.flow;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface Flow<T> {
|
||||
public interface Flow {
|
||||
|
||||
/**
|
||||
* @return the name of the flow
|
||||
@@ -31,14 +30,14 @@ public interface Flow<T> {
|
||||
/**
|
||||
* @throws FlowExecutionException
|
||||
*/
|
||||
FlowExecution start(T context) throws FlowExecutionException;
|
||||
FlowExecution start(JobFlowExecutor executor) throws FlowExecutionException;
|
||||
|
||||
/**
|
||||
* @param stateName the name of the {@link State} to resume on
|
||||
* @param context the context to be passed into each {@link State} executed
|
||||
* @param executor the context to be passed into each {@link State} executed
|
||||
* @return a {@link FlowExecution} containing the exit status of the flow
|
||||
* @throws FlowExecutionException
|
||||
*/
|
||||
FlowExecution resume(String stateName, T context) throws FlowExecutionException;
|
||||
FlowExecution resume(String stateName, JobFlowExecutor executor) throws FlowExecutionException;
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 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.batch.core.job.flow;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface FlowExecutionListener {
|
||||
|
||||
/**
|
||||
* @param result
|
||||
*/
|
||||
void close(FlowExecution result);
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2007 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.batch.core.job.flow;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class FlowExecutionListenerSupport implements FlowExecutionListener {
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
* @see FlowExecutionListener#close(FlowExecution)
|
||||
*/
|
||||
public void close(FlowExecution result) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class FlowJob extends AbstractJob {
|
||||
|
||||
private Flow<JobFlowExecutor> flow;
|
||||
private Flow flow;
|
||||
|
||||
/**
|
||||
* Create a {@link FlowJob} with null name and no flow (invalid state).
|
||||
@@ -52,7 +52,7 @@ public class FlowJob extends AbstractJob {
|
||||
* Public setter for the flow.
|
||||
* @param flow the flow to set
|
||||
*/
|
||||
public void setFlow(Flow<JobFlowExecutor> flow) {
|
||||
public void setFlow(Flow flow) {
|
||||
this.flow = flow;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class FlowJob extends AbstractJob {
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
private class SimpleJobFlowExecutor extends FlowExecutionListenerSupport implements JobFlowExecutor {
|
||||
private class SimpleJobFlowExecutor implements JobFlowExecutor {
|
||||
|
||||
private final ThreadLocal<StepExecution> stepExecutionHolder = new ThreadLocal<StepExecution>();
|
||||
private final JobExecution execution;
|
||||
@@ -148,7 +148,6 @@ public class FlowJob extends AbstractJob {
|
||||
return stepExecutionHolder.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(FlowExecution result) {
|
||||
stepExecutionHolder.set(null);
|
||||
}
|
||||
|
||||
@@ -49,5 +49,11 @@ public interface JobFlowExecutor {
|
||||
* @return the latest {@link StepExecution} or null if there is none
|
||||
*/
|
||||
StepExecution getStepExecution();
|
||||
|
||||
/**
|
||||
* Chance to clean up resources at the end of a flow (whether it completed successfully or not).
|
||||
* @param result the final {@link FlowExecution}
|
||||
*/
|
||||
void close(FlowExecution result);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.batch.core.JobExecution;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class PauseState extends AbstractState<JobFlowExecutor> {
|
||||
public class PauseState extends AbstractState {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -17,9 +17,9 @@ public class PauseState extends AbstractState<JobFlowExecutor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(JobFlowExecutor context) throws Exception {
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
|
||||
JobExecution jobExecution = context.getJobExecution();
|
||||
JobExecution jobExecution = executor.getJobExecution();
|
||||
|
||||
// This state is just a toggle for the status of the job execution. If
|
||||
// not already paused we pause it, and expect the flow to respect the
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.xpath.XPath.Step;
|
||||
@@ -37,17 +38,17 @@ import com.sun.org.apache.xerces.internal.impl.xpath.XPath.Step;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
public class SimpleFlow implements Flow, InitializingBean {
|
||||
|
||||
private State<T> startState;
|
||||
private State startState;
|
||||
|
||||
private Map<String, SortedSet<StateTransition<T>>> transitionMap = new HashMap<String, SortedSet<StateTransition<T>>>();
|
||||
private Map<String, SortedSet<StateTransition>> transitionMap = new HashMap<String, SortedSet<StateTransition>>();
|
||||
|
||||
private Map<String, State<T>> stateMap = new HashMap<String, State<T>>();
|
||||
private Map<String, State> stateMap = new HashMap<String, State>();
|
||||
|
||||
private String startStateName;
|
||||
|
||||
private Collection<StateTransition<T>> stateTransitions = new HashSet<StateTransition<T>>();
|
||||
private Collection<StateTransition> stateTransitions = new HashSet<StateTransition>();
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
* Public setter for the stateTransitions.
|
||||
* @param stateTransitions the stateTransitions to set
|
||||
*/
|
||||
public void setStateTransitions(Collection<StateTransition<T>> stateTransitions) {
|
||||
public void setStateTransitions(Collection<StateTransition> stateTransitions) {
|
||||
|
||||
this.stateTransitions = stateTransitions;
|
||||
}
|
||||
@@ -96,29 +97,24 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Flow#start(Object)
|
||||
* @see Flow#start(JobFlowExecutor)
|
||||
*/
|
||||
public FlowExecution start(T context) throws FlowExecutionException {
|
||||
public FlowExecution start(JobFlowExecutor executor) throws FlowExecutionException {
|
||||
if (startState == null) {
|
||||
initializeTransitions();
|
||||
}
|
||||
State<T> state = startState;
|
||||
State state = startState;
|
||||
String stateName = state.getName();
|
||||
return resume(stateName, context);
|
||||
return resume(stateName, executor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Flow#resume(String, Object)
|
||||
* @see Flow#resume(String, JobFlowExecutor)
|
||||
*/
|
||||
public FlowExecution resume(String stateName, T context) throws FlowExecutionException {
|
||||
public FlowExecution resume(String stateName, JobFlowExecutor executor) throws FlowExecutionException {
|
||||
|
||||
String status = FlowExecution.UNKNOWN;
|
||||
State<T> state = stateMap.get(stateName);
|
||||
|
||||
FlowExecutionListener listener = new FlowExecutionListenerSupport();
|
||||
if (context instanceof FlowExecutionListener) {
|
||||
listener = (FlowExecutionListener)context;
|
||||
}
|
||||
State state = stateMap.get(stateName);
|
||||
|
||||
// Terminate if there are no more states
|
||||
while (state != null) {
|
||||
@@ -126,10 +122,10 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
stateName = state.getName();
|
||||
|
||||
try {
|
||||
status = state.handle(context);
|
||||
status = state.handle(executor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
listener.close(new FlowExecution(stateName, status));
|
||||
executor.close(new FlowExecution(stateName, status));
|
||||
throw new FlowExecutionException(String.format("Ended flow=%s at state=%s with exception", name,
|
||||
stateName), e);
|
||||
}
|
||||
@@ -139,7 +135,7 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
}
|
||||
|
||||
FlowExecution result = new FlowExecution(stateName, status);
|
||||
listener.close(result);
|
||||
executor.close(result);
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -148,7 +144,7 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
* @return the next {@link Step} (or null if this is the end)
|
||||
* @throws JobExecutionException
|
||||
*/
|
||||
private State<T> nextState(String stateName, String status) throws FlowExecutionException {
|
||||
private State nextState(String stateName, String status) throws FlowExecutionException {
|
||||
|
||||
// Special status value indicating that a state wishes to pause
|
||||
// execution
|
||||
@@ -156,7 +152,7 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<StateTransition<T>> set = transitionMap.get(stateName);
|
||||
Set<StateTransition> set = transitionMap.get(stateName);
|
||||
|
||||
if (set == null) {
|
||||
throw new FlowExecutionException(String.format("No transitions found in flow=%s for state=%s", getName(),
|
||||
@@ -164,7 +160,7 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
}
|
||||
|
||||
String next = null;
|
||||
for (StateTransition<T> stateTransition : set) {
|
||||
for (StateTransition stateTransition : set) {
|
||||
if (stateTransition.matches(status)) {
|
||||
if (stateTransition.isEnd()) {
|
||||
// End of job
|
||||
@@ -199,14 +195,14 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
stateMap.clear();
|
||||
boolean hasEndStep = false;
|
||||
|
||||
for (StateTransition<T> stateTransition : stateTransitions) {
|
||||
State<T> state = stateTransition.getState();
|
||||
for (StateTransition stateTransition : stateTransitions) {
|
||||
State state = stateTransition.getState();
|
||||
stateMap.put(state.getName(), state);
|
||||
}
|
||||
|
||||
for (StateTransition<T> stateTransition : stateTransitions) {
|
||||
for (StateTransition stateTransition : stateTransitions) {
|
||||
|
||||
State<T> state = stateTransition.getState();
|
||||
State state = stateTransition.getState();
|
||||
|
||||
if (!stateTransition.isEnd()) {
|
||||
|
||||
@@ -223,9 +219,9 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
|
||||
String name = state.getName();
|
||||
|
||||
SortedSet<StateTransition<T>> set = transitionMap.get(name);
|
||||
SortedSet<StateTransition> set = transitionMap.get(name);
|
||||
if (set == null) {
|
||||
set = new TreeSet<StateTransition<T>>();
|
||||
set = new TreeSet<StateTransition>();
|
||||
transitionMap.put(name, set);
|
||||
}
|
||||
set.add(stateTransition);
|
||||
@@ -253,12 +249,12 @@ public class SimpleFlow<T> implements Flow<T>, InitializingBean {
|
||||
|
||||
Set<String> nextStateNames = new HashSet<String>();
|
||||
|
||||
for (StateTransition<T> stateTransition : stateTransitions) {
|
||||
for (StateTransition stateTransition : stateTransitions) {
|
||||
nextStateNames.add(stateTransition.getNext());
|
||||
}
|
||||
|
||||
for (StateTransition<T> stateTransition : stateTransitions) {
|
||||
State<T> state = stateTransition.getState();
|
||||
for (StateTransition stateTransition : stateTransitions) {
|
||||
State state = stateTransition.getState();
|
||||
if (!nextStateNames.contains(state.getName())) {
|
||||
if (startState != null && !startState.getName().equals(state.getName())) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.core.task.TaskRejectedException;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class SplitState<T> extends AbstractState<T> {
|
||||
public class SplitState extends AbstractState {
|
||||
|
||||
private final Collection<Flow<T>> flows;
|
||||
private final Collection<Flow> flows;
|
||||
|
||||
private TaskExecutor taskExecutor = new SyncTaskExecutor();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SplitState<T> extends AbstractState<T> {
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public SplitState(Collection<Flow<T>> flows, String name) {
|
||||
public SplitState(Collection<Flow> flows, String name) {
|
||||
super(name);
|
||||
this.flows = flows;
|
||||
}
|
||||
@@ -59,18 +59,18 @@ public class SplitState<T> extends AbstractState<T> {
|
||||
* Execute the flows in parallel by passing them to the {@link TaskExecutor}
|
||||
* and wait for all of them to finish before proceeding.
|
||||
*
|
||||
* @see State#handle(Object)
|
||||
* @see State#handle(JobFlowExecutor)
|
||||
*/
|
||||
@Override
|
||||
public String handle(final T context) throws Exception {
|
||||
public String handle(final JobFlowExecutor executor) throws Exception {
|
||||
|
||||
Collection<FutureTask<FlowExecution>> tasks = new ArrayList<FutureTask<FlowExecution>>();
|
||||
|
||||
for (final Flow<T> flow : flows) {
|
||||
for (final Flow flow : flows) {
|
||||
|
||||
final FutureTask<FlowExecution> task = new FutureTask<FlowExecution>(new Callable<FlowExecution>() {
|
||||
public FlowExecution call() throws Exception {
|
||||
return flow.start(context);
|
||||
return flow.start(executor);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.springframework.batch.core.job.flow;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface State<T> {
|
||||
public interface State {
|
||||
|
||||
/**
|
||||
* The name of the state. Should be unique within a flow.
|
||||
@@ -38,10 +38,10 @@ public interface State<T> {
|
||||
* {@link State} instances, so implementations should be careful that the
|
||||
* context is thread safe, or used in a thread safe manner.
|
||||
*
|
||||
* @param context the context passed in by the caller
|
||||
* @param executor the context passed in by the caller
|
||||
* @return a status for the execution
|
||||
* @throws Exception if anything goes wrong
|
||||
*/
|
||||
String handle(T context) throws Exception;
|
||||
String handle(JobFlowExecutor executor) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.springframework.util.StringUtils;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
public class StateTransition implements Comparable<StateTransition> {
|
||||
|
||||
private final State<T> state;
|
||||
private final State state;
|
||||
|
||||
private final String pattern;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* @param state the {@link State} used to generate the outcome for this
|
||||
* transition
|
||||
*/
|
||||
public static <T> StateTransition<T> createEndStateTransition(State<T> state) {
|
||||
public static StateTransition createEndStateTransition(State state) {
|
||||
return createStateTransition(state, null, null);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* @param pattern the pattern to match in the exit status of the
|
||||
* {@link State}
|
||||
*/
|
||||
public static <T> StateTransition<T> createEndStateTransition(State<T> state, String pattern) {
|
||||
public static StateTransition createEndStateTransition(State state, String pattern) {
|
||||
return createStateTransition(state, pattern, null);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* transition
|
||||
* @param next the name of the next {@link State} to execute
|
||||
*/
|
||||
public static <T> StateTransition<T> createStateTransition(State<T> state, String next) {
|
||||
public static StateTransition createStateTransition(State state, String next) {
|
||||
return createStateTransition(state, null, next);
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* {@link State}
|
||||
* @param next the name of the next {@link State} to execute
|
||||
*/
|
||||
public static <T> StateTransition<T> createStateTransition(State<T> state, String pattern, String next) {
|
||||
return new StateTransition<T>(state, pattern, next);
|
||||
public static StateTransition createStateTransition(State state, String pattern, String next) {
|
||||
return new StateTransition(state, pattern, next);
|
||||
}
|
||||
|
||||
private StateTransition(State<T> state, String pattern, String next) {
|
||||
private StateTransition(State state, String pattern, String next) {
|
||||
super();
|
||||
if (!StringUtils.hasText(pattern)) {
|
||||
this.pattern = "*";
|
||||
@@ -103,7 +103,7 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* Public getter for the State.
|
||||
* @return the State
|
||||
*/
|
||||
public State<T> getState() {
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class StateTransition<T> implements Comparable<StateTransition<T>> {
|
||||
* fo? > foo.
|
||||
* @see Comparable#compareTo(Object)
|
||||
*/
|
||||
public int compareTo(StateTransition<T> other) {
|
||||
public int compareTo(StateTransition other) {
|
||||
String value = other.pattern;
|
||||
if (pattern.equals(value)) {
|
||||
return 0;
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.springframework.batch.core.Step;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StepState extends AbstractState<JobFlowExecutor> {
|
||||
public class StepState extends AbstractState {
|
||||
|
||||
private final Step step;
|
||||
|
||||
@@ -22,8 +22,8 @@ public class StepState extends AbstractState<JobFlowExecutor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(JobFlowExecutor context) throws Exception {
|
||||
return context.executeStep(step);
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
return executor.executeStep(step);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.job.flow.FlowExecution;
|
||||
import org.springframework.batch.core.job.flow.FlowExecutionException;
|
||||
import org.springframework.batch.core.job.flow.FlowExecutionListenerSupport;
|
||||
import org.springframework.batch.core.job.flow.SimpleFlow;
|
||||
import org.springframework.batch.core.job.flow.StateTransition;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -37,34 +32,34 @@ import org.springframework.batch.core.job.flow.StateTransition;
|
||||
*/
|
||||
public class BasicFlowTests {
|
||||
|
||||
private SimpleFlow<Object> flow = new SimpleFlow<Object>("job");
|
||||
private SimpleFlow flow = new SimpleFlow("job");
|
||||
|
||||
private Object executor = "data";
|
||||
private JobFlowExecutor executor = new JobFlowExecutorSupport();
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testEmptySteps() throws Exception {
|
||||
flow.setStateTransitions(Collections.<StateTransition<Object>> emptySet());
|
||||
flow.setStateTransitions(Collections.<StateTransition> emptySet());
|
||||
flow.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoNextStepSpecified() throws Exception {
|
||||
flow.setStateTransitions(Collections.singleton(StateTransition.createStateTransition(new StateSupport<Object>(
|
||||
flow.setStateTransitions(Collections.singleton(StateTransition.createStateTransition(new StateSupport(
|
||||
"step"), "foo")));
|
||||
flow.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoStartStep() throws Exception {
|
||||
flow.setStateTransitions(collect(StateTransition.createStateTransition(new StateSupport<Object>("step"),
|
||||
flow.setStateTransitions(collect(StateTransition.createStateTransition(new StateSupport("step"),
|
||||
FlowExecution.FAILED, "step"), StateTransition
|
||||
.createEndStateTransition(new StateSupport<Object>("step"))));
|
||||
.createEndStateTransition(new StateSupport("step"))));
|
||||
flow.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoEndStep() throws Exception {
|
||||
flow.setStateTransitions(Collections.singleton(StateTransition.createStateTransition(new StateSupport<Object>(
|
||||
flow.setStateTransitions(Collections.singleton(StateTransition.createStateTransition(new StateSupport(
|
||||
"step"), FlowExecution.FAILED, "step")));
|
||||
flow.setStartStateName("step");
|
||||
flow.afterPropertiesSet();
|
||||
@@ -109,7 +104,7 @@ public class BasicFlowTests {
|
||||
.singleton(StateTransition.createEndStateTransition(new StubState("step1"))));
|
||||
flow.afterPropertiesSet();
|
||||
final List<FlowExecution> list = new ArrayList<FlowExecution>();
|
||||
executor = new FlowExecutionListenerSupport() {
|
||||
executor = new JobFlowExecutorSupport() {
|
||||
@Override
|
||||
public void close(FlowExecution result) {
|
||||
list.add(result);
|
||||
@@ -156,7 +151,7 @@ public class BasicFlowTests {
|
||||
public void testFailedStep() throws Exception {
|
||||
flow.setStateTransitions(collect(StateTransition.createStateTransition(new StubState("step1") {
|
||||
@Override
|
||||
public String handle(Object executor) {
|
||||
public String handle(JobFlowExecutor executor) {
|
||||
return FlowExecution.FAILED;
|
||||
}
|
||||
}, "step2"), StateTransition.createEndStateTransition(new StubState("step2"))));
|
||||
@@ -185,7 +180,7 @@ public class BasicFlowTests {
|
||||
private boolean paused = false;
|
||||
|
||||
@Override
|
||||
public String handle(Object executor) throws Exception {
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
if (!paused) {
|
||||
paused = true;
|
||||
return FlowExecution.PAUSED;
|
||||
@@ -204,23 +199,23 @@ public class BasicFlowTests {
|
||||
assertEquals("step3", execution.getName());
|
||||
}
|
||||
|
||||
private Collection<StateTransition<Object>> collect(StateTransition<Object> s1, StateTransition<Object> s2) {
|
||||
Collection<StateTransition<Object>> list = new ArrayList<StateTransition<Object>>();
|
||||
private Collection<StateTransition> collect(StateTransition s1, StateTransition s2) {
|
||||
Collection<StateTransition> list = new ArrayList<StateTransition>();
|
||||
list.add(s1);
|
||||
list.add(s2);
|
||||
return list;
|
||||
}
|
||||
|
||||
private Collection<StateTransition<Object>> collect(StateTransition<Object> s1, StateTransition<Object> s2,
|
||||
StateTransition<Object> s3) {
|
||||
Collection<StateTransition<Object>> list = collect(s1, s2);
|
||||
private Collection<StateTransition> collect(StateTransition s1, StateTransition s2,
|
||||
StateTransition s3) {
|
||||
Collection<StateTransition> list = collect(s1, s2);
|
||||
list.add(s3);
|
||||
return list;
|
||||
}
|
||||
|
||||
private Collection<StateTransition<Object>> collect(StateTransition<Object> s1, StateTransition<Object> s2,
|
||||
StateTransition<Object> s3, StateTransition<Object> s4) {
|
||||
Collection<StateTransition<Object>> list = collect(s1, s2, s3);
|
||||
private Collection<StateTransition> collect(StateTransition s1, StateTransition s2,
|
||||
StateTransition s3, StateTransition s4) {
|
||||
Collection<StateTransition> list = collect(s1, s2, s3);
|
||||
list.add(s4);
|
||||
return list;
|
||||
}
|
||||
@@ -229,7 +224,7 @@ public class BasicFlowTests {
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
private static class StubState extends StateSupport<Object> {
|
||||
private static class StubState extends StateSupport {
|
||||
|
||||
/**
|
||||
* @param string
|
||||
|
||||
@@ -63,8 +63,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testTwoSteps() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2"))));
|
||||
flow.setStateTransitions(transitions);
|
||||
@@ -77,8 +77,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testFailedStep() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StepSupport("step1") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
@@ -99,8 +99,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testStoppingStep() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StepSupport("step1") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
@@ -124,8 +124,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testEndStateStopped() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end"));
|
||||
transitions.add(StateTransition.createStateTransition(new EndState(BatchStatus.STOPPED, "end"), "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2"))));
|
||||
@@ -143,8 +143,8 @@ public class FlowJobTests {
|
||||
}
|
||||
|
||||
public void testEndStateFailed() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end"));
|
||||
transitions.add(StateTransition.createStateTransition(new EndState(BatchStatus.FAILED, "end"), "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2"))));
|
||||
@@ -158,8 +158,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testEndStateStoppedWithRestart() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end"));
|
||||
transitions.add(StateTransition.createStateTransition(new EndState(BatchStatus.STOPPED, "end"), "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2"))));
|
||||
@@ -181,8 +181,8 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testBranching() throws Exception {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "step2"));
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "COMPLETED",
|
||||
"step3"));
|
||||
@@ -199,7 +199,7 @@ public class FlowJobTests {
|
||||
|
||||
@Test
|
||||
public void testBasicFlow() throws Throwable {
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Step step = new StubStep("step");
|
||||
flow.setStateTransitions(Collections.singleton(StateTransition.createEndStateTransition(new StepState(step),
|
||||
"*")));
|
||||
@@ -214,7 +214,7 @@ public class FlowJobTests {
|
||||
@Test
|
||||
public void testDecisionFlow() throws Throwable {
|
||||
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
public String decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
assertNotNull(stepExecution);
|
||||
@@ -222,7 +222,7 @@ public class FlowJobTests {
|
||||
}
|
||||
};
|
||||
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "*", "decision"));
|
||||
transitions.add(StateTransition.createStateTransition(new DecisionState(decider, "decision"), "*", "step2"));
|
||||
transitions.add(StateTransition
|
||||
@@ -246,8 +246,8 @@ public class FlowJobTests {
|
||||
@Test
|
||||
public void testPauseFlow() throws Throwable {
|
||||
|
||||
SimpleFlow<JobFlowExecutor> flow = new SimpleFlow<JobFlowExecutor>("job");
|
||||
Collection<StateTransition<JobFlowExecutor>> transitions = new ArrayList<StateTransition<JobFlowExecutor>>();
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
Collection<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "*", "pause"));
|
||||
transitions.add(StateTransition.createStateTransition(new PauseState("pause"), "*", "step2"));
|
||||
transitions.add(StateTransition.createEndStateTransition(new StepState(new StubStep("step2")), "*"));
|
||||
|
||||
@@ -41,4 +41,7 @@ public class JobFlowExecutorSupport implements JobFlowExecutor {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void close(FlowExecution result) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ import java.util.Collection;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.job.flow.Flow;
|
||||
import org.springframework.batch.core.job.flow.FlowExecution;
|
||||
import org.springframework.batch.core.job.flow.SplitState;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
|
||||
|
||||
@@ -37,15 +34,13 @@ public class SplitStateTests {
|
||||
@Test
|
||||
public void testBasicHandling() throws Exception {
|
||||
|
||||
Collection<Flow<Object>> flows = new ArrayList<Flow<Object>>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Flow<Object> flow1 = EasyMock.createMock(Flow.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Flow<Object> flow2 = EasyMock.createMock(Flow.class);
|
||||
Collection<Flow> flows = new ArrayList<Flow>();
|
||||
Flow flow1 = EasyMock.createMock(Flow.class);
|
||||
Flow flow2 = EasyMock.createMock(Flow.class);
|
||||
flows.add(flow1);
|
||||
flows.add(flow2);
|
||||
|
||||
SplitState<Object> state = new SplitState<Object>(flows, "foo");
|
||||
SplitState state = new SplitState(flows, "foo");
|
||||
|
||||
EasyMock.expect(flow1.start(null)).andReturn(new FlowExecution("step1", FlowExecution.COMPLETED));
|
||||
EasyMock.expect(flow2.start(null)).andReturn(new FlowExecution("step1", FlowExecution.COMPLETED));
|
||||
@@ -61,15 +56,13 @@ public class SplitStateTests {
|
||||
@Test
|
||||
public void testConcurrentHandling() throws Exception {
|
||||
|
||||
Collection<Flow<Object>> flows = new ArrayList<Flow<Object>>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Flow<Object> flow1 = EasyMock.createMock(Flow.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Flow<Object> flow2 = EasyMock.createMock(Flow.class);
|
||||
Collection<Flow> flows = new ArrayList<Flow>();
|
||||
Flow flow1 = EasyMock.createMock(Flow.class);
|
||||
Flow flow2 = EasyMock.createMock(Flow.class);
|
||||
flows.add(flow1);
|
||||
flows.add(flow2);
|
||||
|
||||
SplitState<Object> state = new SplitState<Object>(flows, "foo");
|
||||
SplitState state = new SplitState(flows, "foo");
|
||||
state.setTaskExecutor(new SimpleAsyncTaskExecutor());
|
||||
|
||||
EasyMock.expect(flow1.start(null)).andReturn(new FlowExecution("step1", FlowExecution.COMPLETED));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.core.job.flow.State;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StateSupport<T> extends AbstractState<T> {
|
||||
public class StateSupport extends AbstractState {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -35,7 +35,7 @@ public class StateSupport<T> extends AbstractState<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(T context) throws Exception {
|
||||
public String handle(JobFlowExecutor executor) throws Exception {
|
||||
return FlowExecution.COMPLETED;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.job.flow.StateTransition;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -30,96 +29,96 @@ public class StateTransitionTests {
|
||||
|
||||
@Test
|
||||
public void testIsEnd() {
|
||||
StateTransition<String> transition = StateTransition.createEndStateTransition(null, "");
|
||||
StateTransition transition = StateTransition.createEndStateTransition(null, "");
|
||||
assertTrue(transition.isEnd());
|
||||
assertNull(transition.getNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesStar() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesNull() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, null, "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, null, "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesEmpty() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "", "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesExact() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesWildcard() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN*", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN*", "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesPlaceholder() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
assertTrue(transition.matches("CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrderingEqual() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
assertEquals(0, transition.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrderingMoreGeneral() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
StateTransition<String> other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
StateTransition other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
assertEquals(1, transition.compareTo(other));
|
||||
assertEquals(-1, other.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrderingMostGeneral() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
StateTransition<String> other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
StateTransition other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
assertEquals(1, transition.compareTo(other));
|
||||
assertEquals(-1, other.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubstringAndWildcard() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN*", "start");
|
||||
StateTransition<String> other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN*", "start");
|
||||
StateTransition other = StateTransition.createStateTransition(null, "CONTINUABLE", "start");
|
||||
assertEquals(1, transition.compareTo(other));
|
||||
assertEquals(-1, other.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrderingMostToNextGeneral() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
StateTransition<String> other = StateTransition.createStateTransition(null, "C?", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "*", "start");
|
||||
StateTransition other = StateTransition.createStateTransition(null, "C?", "start");
|
||||
assertEquals(1, transition.compareTo(other));
|
||||
assertEquals(-1, other.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleOrderingAdjacent() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CON*", "start");
|
||||
StateTransition<String> other = StateTransition.createStateTransition(null, "CON?", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CON*", "start");
|
||||
StateTransition other = StateTransition.createStateTransition(null, "CON?", "start");
|
||||
assertEquals(1, transition.compareTo(other));
|
||||
assertEquals(-1, other.compareTo(transition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
StateTransition<String> transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
StateTransition transition = StateTransition.createStateTransition(null, "CONTIN???LE", "start");
|
||||
String string = transition.toString();
|
||||
assertTrue("Wrong string: " + string, string.contains("Transition"));
|
||||
assertTrue("Wrong string: " + string, string.contains("start"));
|
||||
|
||||
Reference in New Issue
Block a user