From c98fc80bf6db2f9dc3a550ada95fb8d09fc93541 Mon Sep 17 00:00:00 2001 From: adriana-corui <54841592+adriana-corui@users.noreply.github.com> Date: Fri, 5 Aug 2022 08:57:53 +0300 Subject: [PATCH] worker group on simple loops fix (#1367) * worker group on simple loops fix * worker group on simple loops fix --- .../lang/runtime/steps/AbstractExecutionData.java | 6 ++++-- .../lang/runtime/steps/StepExecutionDataTest.java | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java index f975795419..02d7f15235 100644 --- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java +++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/AbstractExecutionData.java @@ -203,14 +203,16 @@ protected static boolean handleEndLoopCondition(RunEnvironment runEnv, if (langVariables.containsKey(LoopCondition.LOOP_CONDITION_KEY)) { LoopCondition loopCondition = (LoopCondition) langVariables.get(LoopCondition.LOOP_CONDITION_KEY).get(); if (!shouldBreakLoop(breakOn, executableReturnValues) && loopCondition.hasMore()) { - runEnv.putNextStepPosition(previousStepId); + // setWorkerGroupStep will always precede beginStep in execution plan + final Long workerGroupStepPosition = previousStepId != null ? previousStepId - 1 : null; + runEnv.putNextStepPosition(workerGroupStepPosition); runEnv.getStack().pushContext(flowContext); throwEventOutputEnd( runEnv, executionRuntimeServices, nodeName, publishValues, - previousStepId, + workerGroupStepPosition, new ReturnValues(publishValues, executableReturnValues.getResult()), ExecutionParametersConsts.DEFAULT_ROI_VALUE, contextAccessor, diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java index 107b311a15..5b633b0137 100644 --- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java +++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/StepExecutionDataTest.java @@ -49,9 +49,7 @@ import io.cloudslang.score.lang.ExecutionRuntimeServices; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.python.google.common.collect.Lists; import org.springframework.beans.factory.annotation.Autowired; @@ -518,7 +516,7 @@ public void whenLoopConditionIsOfForTypeStartStepWillIncrementIt() { } @Test - public void whenLoopConditionHasMoreEndStepSetNextPositionIdToBeginStep() throws Exception { + public void whenLoopConditionHasMoreEndStepSetNextPositionIdToSetWorkerStep() throws Exception { RunEnvironment runEnv = new RunEnvironment(); runEnv.putReturnValues(new ReturnValues(new HashMap(), "SUCCESS")); HashMap stepNavigationValues = new HashMap<>(); @@ -529,11 +527,11 @@ public void whenLoopConditionHasMoreEndStepSetNextPositionIdToBeginStep() throws context.putLanguageVariable(LoopCondition.LOOP_CONDITION_KEY, ValueFactory.create(mockLoopCondition)); when(mockLoopCondition.hasMore()).thenReturn(true); - Long previousStepId = 1L; + Long previousStepId = 2L; stepExecutionData.endStep(runEnv, new ArrayList(), stepNavigationValues, createRuntimeServices(), previousStepId, new ArrayList(), "stepName", false); - assertEquals(previousStepId, runEnv.removeNextStepPosition()); + assertEquals(Long.valueOf(previousStepId - 1), runEnv.removeNextStepPosition()); assertEquals(context, runEnv.getStack().popContext()); }