mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-1955 - Add back to processes
This commit is contained in:
@ -122,6 +122,12 @@ public class RunProcessAction
|
||||
UUIDAndTypeStateKey stateKey = new UUIDAndTypeStateKey(UUID.fromString(runProcessInput.getProcessUUID()), StateType.PROCESS_STATUS);
|
||||
ProcessState processState = primeProcessState(runProcessInput, stateKey, process);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// these should always be clear when we're starting a run - so make sure they haven't leaked from previous //
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
processState.clearNextStepName();
|
||||
processState.clearBackStepName();
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// if process is 'basepull' style, keep track of 'now' //
|
||||
/////////////////////////////////////////////////////////
|
||||
@ -188,14 +194,35 @@ public class RunProcessAction
|
||||
private void runLinearStepLoop(QProcessMetaData process, ProcessState processState, UUIDAndTypeStateKey stateKey, RunProcessInput runProcessInput, RunProcessOutput runProcessOutput) throws Exception
|
||||
{
|
||||
String lastStepName = runProcessInput.getStartAfterStep();
|
||||
String startAtStep = runProcessInput.getStartAtStep();
|
||||
|
||||
while(true)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// always refresh the step list - as any step that runs can modify it (in the process state). //
|
||||
// this is why we don't do a loop over the step list - as we'd get ConcurrentModificationExceptions. //
|
||||
// deal with if we were told, from the input, to start After a step, or start At a step. //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
List<QStepMetaData> stepList = getAvailableStepList(processState, process, lastStepName);
|
||||
List<QStepMetaData> stepList;
|
||||
if(startAtStep == null)
|
||||
{
|
||||
stepList = getAvailableStepList(processState, process, lastStepName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
stepList = getAvailableStepList(processState, process, startAtStep, true);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// clear this field - so after we run a step, we'll then loop in last-step mode. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
startAtStep = null;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// if we're going to run a backend step now, let it see that this is a step-back //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
processState.setIsStepBack(true);
|
||||
}
|
||||
|
||||
if(stepList.isEmpty())
|
||||
{
|
||||
break;
|
||||
@ -232,7 +259,18 @@ public class RunProcessAction
|
||||
//////////////////////////////////////////////////
|
||||
throw (new QException("Unsure how to run a step of type: " + step.getClass().getName()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// only let this value be set for the original back step - don't let it stick around. //
|
||||
// if a process wants to keep track of this itself, it can, but in a different slot. //
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
processState.setIsStepBack(false);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// in case we broke from the loop above (e.g., by going directly into a frontend step), once again make sure to lower this flag. //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
processState.setIsStepBack(false);
|
||||
}
|
||||
|
||||
|
||||
@ -264,6 +302,12 @@ public class RunProcessAction
|
||||
processFrontendStepFieldDefaultValues(processState, step);
|
||||
processFrontendComponents(processState, step);
|
||||
processState.setNextStepName(step.getName());
|
||||
|
||||
if(StringUtils.hasContent(step.getBackStepName()) && processState.getBackStepName().isEmpty())
|
||||
{
|
||||
processState.setBackStepName(step.getBackStepName());
|
||||
}
|
||||
|
||||
return LoopTodo.BREAK;
|
||||
}
|
||||
case SKIP ->
|
||||
@ -317,6 +361,7 @@ public class RunProcessAction
|
||||
// else run the given lastStepName //
|
||||
/////////////////////////////////////
|
||||
processState.clearNextStepName();
|
||||
processState.clearBackStepName();
|
||||
step = process.getStep(lastStepName);
|
||||
if(step == null)
|
||||
{
|
||||
@ -398,6 +443,7 @@ public class RunProcessAction
|
||||
// its sub-steps, or, to fall out of the loop and end the process. //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
processState.clearNextStepName();
|
||||
processState.clearBackStepName();
|
||||
runStateMachineStep(nextStepName.get(), process, processState, stateKey, runProcessInput, runProcessOutput, stackDepth + 1);
|
||||
return;
|
||||
}
|
||||
@ -621,8 +667,10 @@ public class RunProcessAction
|
||||
|
||||
/*******************************************************************************
|
||||
** Get the list of steps which are eligible to run.
|
||||
**
|
||||
** lastStep will be included in the list, or not, based on includeLastStep.
|
||||
*******************************************************************************/
|
||||
private List<QStepMetaData> getAvailableStepList(ProcessState processState, QProcessMetaData process, String lastStep) throws QException
|
||||
static List<QStepMetaData> getAvailableStepList(ProcessState processState, QProcessMetaData process, String lastStep, boolean includeLastStep) throws QException
|
||||
{
|
||||
if(lastStep == null)
|
||||
{
|
||||
@ -649,6 +697,10 @@ public class RunProcessAction
|
||||
if(stepName.equals(lastStep))
|
||||
{
|
||||
foundLastStep = true;
|
||||
if(includeLastStep)
|
||||
{
|
||||
validStepNames.add(stepName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (stepNamesToSteps(process, validStepNames));
|
||||
@ -660,7 +712,7 @@ public class RunProcessAction
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private List<QStepMetaData> stepNamesToSteps(QProcessMetaData process, List<String> stepNames) throws QException
|
||||
private static List<QStepMetaData> stepNamesToSteps(QProcessMetaData process, List<String> stepNames) throws QException
|
||||
{
|
||||
List<QStepMetaData> result = new ArrayList<>();
|
||||
|
||||
|
@ -40,6 +40,8 @@ public class ProcessState implements Serializable
|
||||
private Map<String, Serializable> values = new HashMap<>();
|
||||
private List<String> stepList = new ArrayList<>();
|
||||
private Optional<String> nextStepName = Optional.empty();
|
||||
private Optional<String> backStepName = Optional.empty();
|
||||
private boolean isStepBack = false;
|
||||
|
||||
private ProcessMetaDataAdjustment processMetaDataAdjustment = null;
|
||||
|
||||
@ -122,6 +124,39 @@ public class ProcessState implements Serializable
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for backStepName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public Optional<String> getBackStepName()
|
||||
{
|
||||
return backStepName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for backStepName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setBackStepName(String backStepName)
|
||||
{
|
||||
this.backStepName = Optional.of(backStepName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** clear out the value of backStepName (set the Optional to empty)
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void clearBackStepName()
|
||||
{
|
||||
this.backStepName = Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for stepList
|
||||
**
|
||||
@ -176,4 +211,35 @@ public class ProcessState implements Serializable
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for isStepBack
|
||||
*******************************************************************************/
|
||||
public boolean getIsStepBack()
|
||||
{
|
||||
return (this.isStepBack);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for isStepBack
|
||||
*******************************************************************************/
|
||||
public void setIsStepBack(boolean isStepBack)
|
||||
{
|
||||
this.isStepBack = isStepBack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for isStepBack
|
||||
*******************************************************************************/
|
||||
public ProcessState withIsStepBack(boolean isStepBack)
|
||||
{
|
||||
this.isStepBack = isStepBack;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -419,6 +419,17 @@ public class RunBackendStepInput extends AbstractActionInput
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Accessor for processState's isStepBack attribute
|
||||
**
|
||||
*******************************************************************************/
|
||||
public boolean getIsStepBack()
|
||||
{
|
||||
return processState.getIsStepBack();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Accessor for processState - protected, because we generally want to access
|
||||
** its members through wrapper methods, we think
|
||||
|
@ -49,6 +49,7 @@ public class RunProcessInput extends AbstractActionInput
|
||||
private ProcessState processState;
|
||||
private FrontendStepBehavior frontendStepBehavior = FrontendStepBehavior.BREAK;
|
||||
private String startAfterStep;
|
||||
private String startAtStep;
|
||||
private String processUUID;
|
||||
private AsyncJobCallback asyncJobCallback;
|
||||
|
||||
@ -451,4 +452,35 @@ public class RunProcessInput extends AbstractActionInput
|
||||
{
|
||||
return asyncJobCallback;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for startAtStep
|
||||
*******************************************************************************/
|
||||
public String getStartAtStep()
|
||||
{
|
||||
return (this.startAtStep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for startAtStep
|
||||
*******************************************************************************/
|
||||
public void setStartAtStep(String startAtStep)
|
||||
{
|
||||
this.startAtStep = startAtStep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for startAtStep
|
||||
*******************************************************************************/
|
||||
public RunProcessInput withStartAtStep(String startAtStep)
|
||||
{
|
||||
this.startAtStep = startAtStep;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -48,6 +48,7 @@ public class QFrontendStepMetaData extends QStepMetaData
|
||||
private Map<String, QFieldMetaData> formFieldMap;
|
||||
|
||||
private String format;
|
||||
private String backStepName;
|
||||
|
||||
private List<QHelpContent> helpContents;
|
||||
|
||||
@ -436,4 +437,35 @@ public class QFrontendStepMetaData extends QStepMetaData
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for backStepName
|
||||
*******************************************************************************/
|
||||
public String getBackStepName()
|
||||
{
|
||||
return (this.backStepName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for backStepName
|
||||
*******************************************************************************/
|
||||
public void setBackStepName(String backStepName)
|
||||
{
|
||||
this.backStepName = backStepName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for backStepName
|
||||
*******************************************************************************/
|
||||
public QFrontendStepMetaData withBackStepName(String backStepName)
|
||||
{
|
||||
this.backStepName = backStepName;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,10 +23,15 @@ package com.kingsrook.qqq.backend.core.actions.processes;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessState;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReferenceLambda;
|
||||
@ -35,6 +40,8 @@ import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaD
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QFrontendStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QStateMachineStep;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MultiLevelMapHelper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -73,14 +80,14 @@ class RunProcessActionTest extends BaseTest
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// two-steps - a, points at b; b has no next-step, so it exits //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
.addStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
log.add("in StepA");
|
||||
runBackendStepOutput.getProcessState().setNextStepName("b");
|
||||
}))))
|
||||
|
||||
.addStep(QStateMachineStep.backendOnly("b", new QBackendStepMetaData().withName("bBackend")
|
||||
.withStep(QStateMachineStep.backendOnly("b", new QBackendStepMetaData().withName("bBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
log.add("in StepB");
|
||||
@ -109,8 +116,8 @@ class RunProcessActionTest extends BaseTest
|
||||
{
|
||||
QProcessMetaData process = new QProcessMetaData().withName("test")
|
||||
|
||||
.addStep(QStateMachineStep.frontendOnly("a", new QFrontendStepMetaData().withName("aFrontend")).withDefaultNextStepName("b"))
|
||||
.addStep(QStateMachineStep.frontendOnly("b", new QFrontendStepMetaData().withName("bFrontend")))
|
||||
.withStep(QStateMachineStep.frontendOnly("a", new QFrontendStepMetaData().withName("aFrontend")).withDefaultNextStepName("b"))
|
||||
.withStep(QStateMachineStep.frontendOnly("b", new QFrontendStepMetaData().withName("bFrontend")))
|
||||
|
||||
.withStepFlow(ProcessStepFlow.STATE_MACHINE);
|
||||
|
||||
@ -150,7 +157,7 @@ class RunProcessActionTest extends BaseTest
|
||||
// since it never goes to the frontend, it'll stack overflow //
|
||||
// (though we'll catch it ourselves before JVM does) //
|
||||
///////////////////////////////////////////////////////////////
|
||||
.addStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
log.add("in StepA");
|
||||
@ -193,14 +200,14 @@ class RunProcessActionTest extends BaseTest
|
||||
// since it never goes to the frontend, it'll stack overflow //
|
||||
// (though we'll catch it ourselves before JVM does) //
|
||||
///////////////////////////////////////////////////////////////
|
||||
.addStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withStep(QStateMachineStep.backendOnly("a", new QBackendStepMetaData().withName("aBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
log.add("in StepA");
|
||||
runBackendStepOutput.getProcessState().setNextStepName("b");
|
||||
}))))
|
||||
|
||||
.addStep(QStateMachineStep.backendOnly("b", new QBackendStepMetaData().withName("bBackend")
|
||||
.withStep(QStateMachineStep.backendOnly("b", new QBackendStepMetaData().withName("bBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
log.add("in StepB");
|
||||
@ -238,7 +245,7 @@ class RunProcessActionTest extends BaseTest
|
||||
{
|
||||
QProcessMetaData process = new QProcessMetaData().withName("test")
|
||||
|
||||
.addStep(QStateMachineStep.frontendThenBackend("a",
|
||||
.withStep(QStateMachineStep.frontendThenBackend("a",
|
||||
new QFrontendStepMetaData().withName("aFrontend"),
|
||||
new QBackendStepMetaData().withName("aBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
@ -247,7 +254,7 @@ class RunProcessActionTest extends BaseTest
|
||||
runBackendStepOutput.getProcessState().setNextStepName("b");
|
||||
}))))
|
||||
|
||||
.addStep(QStateMachineStep.frontendThenBackend("b",
|
||||
.withStep(QStateMachineStep.frontendThenBackend("b",
|
||||
new QFrontendStepMetaData().withName("bFrontend"),
|
||||
new QBackendStepMetaData().withName("bBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
@ -256,7 +263,7 @@ class RunProcessActionTest extends BaseTest
|
||||
runBackendStepOutput.getProcessState().setNextStepName("c");
|
||||
}))))
|
||||
|
||||
.addStep(QStateMachineStep.frontendThenBackend("c",
|
||||
.withStep(QStateMachineStep.frontendThenBackend("c",
|
||||
new QFrontendStepMetaData().withName("cFrontend"),
|
||||
new QBackendStepMetaData().withName("cBackend")
|
||||
.withCode(new QCodeReferenceLambda<BackendStep>((runBackendStepInput, runBackendStepOutput) ->
|
||||
@ -265,7 +272,7 @@ class RunProcessActionTest extends BaseTest
|
||||
runBackendStepOutput.getProcessState().setNextStepName("d");
|
||||
}))))
|
||||
|
||||
.addStep(QStateMachineStep.frontendOnly("d",
|
||||
.withStep(QStateMachineStep.frontendOnly("d",
|
||||
new QFrontendStepMetaData().withName("dFrontend")))
|
||||
|
||||
.withStepFlow(ProcessStepFlow.STATE_MACHINE);
|
||||
@ -321,7 +328,132 @@ class RunProcessActionTest extends BaseTest
|
||||
runProcessOutput = new RunProcessAction().execute(input);
|
||||
assertEquals(List.of("in StepA", "in StepB", "in StepC"), log);
|
||||
assertThat(runProcessOutput.getProcessState().getNextStepName()).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testGoingBack() throws QException
|
||||
{
|
||||
AtomicInteger backCount = new AtomicInteger(0);
|
||||
Map<String, Integer> stepRunCounts = new HashMap<>();
|
||||
|
||||
BackendStep backendStep = (runBackendStepInput, runBackendStepOutput) ->
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// shared backend-step lambda, that will do the same thing for both - but using step name to count how many times each is executed. //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
MultiLevelMapHelper.getOrPutAndIncrement(stepRunCounts, runBackendStepInput.getStepName());
|
||||
if(runBackendStepInput.getIsStepBack())
|
||||
{
|
||||
backCount.incrementAndGet();
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// normal flow here: a -> b -> c //
|
||||
// but, b can go back to a, as in: a -> b -> a -> b -> c //
|
||||
///////////////////////////////////////////////////////////
|
||||
QProcessMetaData process = new QProcessMetaData().withName("test")
|
||||
.withStep(new QBackendStepMetaData()
|
||||
.withName("a")
|
||||
.withCode(new QCodeReferenceLambda<>(backendStep)))
|
||||
.withStep(new QFrontendStepMetaData()
|
||||
.withName("b")
|
||||
.withBackStepName("a"))
|
||||
.withStep(new QBackendStepMetaData()
|
||||
.withName("c")
|
||||
.withCode(new QCodeReferenceLambda<>(backendStep)))
|
||||
.withStepFlow(ProcessStepFlow.LINEAR);
|
||||
|
||||
QContext.getQInstance().addProcess(process);
|
||||
|
||||
RunProcessInput input = new RunProcessInput();
|
||||
input.setProcessName("test");
|
||||
input.setFrontendStepBehavior(RunProcessInput.FrontendStepBehavior.BREAK);
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// start the process - we should be sent to b (frontend) //
|
||||
///////////////////////////////////////////////////////////
|
||||
RunProcessOutput runProcessOutput = new RunProcessAction().execute(input);
|
||||
assertThat(runProcessOutput.getProcessState().getNextStepName())
|
||||
.isPresent().get()
|
||||
.isEqualTo("b");
|
||||
|
||||
assertEquals(0, backCount.get());
|
||||
assertEquals(Map.of("a", 1), stepRunCounts);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// resume after b, but in back-mode - should end up back at b //
|
||||
////////////////////////////////////////////////////////////////
|
||||
input.setStartAfterStep(null);
|
||||
input.setStartAtStep("a");
|
||||
runProcessOutput = new RunProcessAction().execute(input);
|
||||
assertThat(runProcessOutput.getProcessState().getNextStepName())
|
||||
.isPresent().get()
|
||||
.isEqualTo("b");
|
||||
|
||||
assertEquals(1, backCount.get());
|
||||
assertEquals(Map.of("a", 2), stepRunCounts);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// resume after b, in regular (forward) mode - should wrap up the process //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
input.setStartAfterStep("b");
|
||||
input.setStartAtStep(null);
|
||||
runProcessOutput = new RunProcessAction().execute(input);
|
||||
assertThat(runProcessOutput.getProcessState().getNextStepName())
|
||||
.isEmpty();
|
||||
|
||||
assertEquals(1, backCount.get());
|
||||
assertEquals(Map.of("a", 2, "c", 1), stepRunCounts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testGetAvailableStepList() throws QException
|
||||
{
|
||||
QProcessMetaData process = new QProcessMetaData()
|
||||
.withStep(new QBackendStepMetaData().withName("A"))
|
||||
.withStep(new QBackendStepMetaData().withName("B"))
|
||||
.withStep(new QBackendStepMetaData().withName("C"))
|
||||
.withStep(new QBackendStepMetaData().withName("D"))
|
||||
.withStep(new QBackendStepMetaData().withName("E"));
|
||||
|
||||
ProcessState processState = new ProcessState();
|
||||
processState.setStepList(process.getStepList().stream().map(s -> s.getName()).toList());
|
||||
|
||||
assertStepListNames(List.of("A", "B", "C", "D", "E"), RunProcessAction.getAvailableStepList(processState, process, null, false));
|
||||
assertStepListNames(List.of("A", "B", "C", "D", "E"), RunProcessAction.getAvailableStepList(processState, process, null, true));
|
||||
|
||||
assertStepListNames(List.of("B", "C", "D", "E"), RunProcessAction.getAvailableStepList(processState, process, "A", false));
|
||||
assertStepListNames(List.of("A", "B", "C", "D", "E"), RunProcessAction.getAvailableStepList(processState, process, "A", true));
|
||||
|
||||
assertStepListNames(List.of("D", "E"), RunProcessAction.getAvailableStepList(processState, process, "C", false));
|
||||
assertStepListNames(List.of("C", "D", "E"), RunProcessAction.getAvailableStepList(processState, process, "C", true));
|
||||
|
||||
assertStepListNames(Collections.emptyList(), RunProcessAction.getAvailableStepList(processState, process, "E", false));
|
||||
assertStepListNames(List.of("E"), RunProcessAction.getAvailableStepList(processState, process, "E", true));
|
||||
|
||||
assertStepListNames(Collections.emptyList(), RunProcessAction.getAvailableStepList(processState, process, "Z", false));
|
||||
assertStepListNames(Collections.emptyList(), RunProcessAction.getAvailableStepList(processState, process, "Z", true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
private void assertStepListNames(List<String> expectedNames, List<QStepMetaData> actualSteps)
|
||||
{
|
||||
assertEquals(expectedNames, actualSteps.stream().map(s -> s.getName()).toList());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user