test_class.declarator: executionService
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ExecutionService executionService;
test_class.type: ExecutionService
test_class.var_name: executionService
test_class.declarator: outBuffer
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private OutboundBuffer outBuffer;
test_class.type: OutboundBuffer
test_class.var_name: outBuffer
test_class.declarator: inBuffer
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private InBuffer inBuffer;
test_class.type: InBuffer
test_class.var_name: inBuffer
test_class.declarator: converter
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ExecutionMessageConverter converter;
test_class.type: ExecutionMessageConverter
test_class.var_name: converter
test_class.declarator: endExecutionCallback
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private EndExecutionCallback endExecutionCallback;
test_class.type: EndExecutionCallback
test_class.var_name: endExecutionCallback
test_class.declarator: executionMessage
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ExecutionMessage executionMessage;
test_class.type: ExecutionMessage
test_class.var_name: executionMessage
test_class.declarator: recoveryFlag
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AtomicBoolean recoveryFlag;
test_class.type: AtomicBoolean
test_class.var_name: recoveryFlag
test_class.declarator: queueStateIdGenerator
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private QueueStateIdGeneratorService queueStateIdGenerator;
test_class.type: QueueStateIdGeneratorService
test_class.var_name: queueStateIdGenerator
test_class.declarator: workerConfigurationService
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private WorkerConfigurationService workerConfigurationService;
test_class.type: WorkerConfigurationService
test_class.var_name: workerConfigurationService
test_class.declarator: suspendedExecutionService
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SuspendedExecutionService suspendedExecutionService;
test_class.type: SuspendedExecutionService
test_class.var_name: suspendedExecutionService
test_class.declarator: workerManager
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private WorkerManager workerManager;
test_class.type: WorkerManager
test_class.var_name: workerManager
test_class.declarator: executionQueueService
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ExecutionQueueService executionQueueService;
test_class.type: ExecutionQueueService
test_class.var_name: executionQueueService
test_class.file: worker/worker-manager/score-worker-manager-impl/src/test/java/io/cloudslang/worker/management/services/SimpleExecutionRunnableTest.java
test_class.identifier: SimpleExecutionRunnableTest
test_case.body: @Test
      public void testRun() throws Exception {
          Execution execution = new Execution();
          when(converter.extractExecution(any(Payload.class))).thenReturn(execution);
  
          final List<ExecutionMessage> buffer = new ArrayList<>();
  
          doAnswer(invocation -> {
              for (Object message : invocation.getArguments()) {
                  buffer.add((ExecutionMessage) message);
              }
              return null;
          }).when(outBuffer).put(any(ExecutionMessage[].class));
  
          when(workerManager.isFromCurrentThreadPool(anyString())).thenReturn(true);
  
          SimpleExecutionRunnable simpleExecutionRunnable = new SimpleExecutionRunnable(executionService, outBuffer,
                  inBuffer, converter, endExecutionCallback, queueStateIdGenerator, "stam", workerConfigurationService,
                  workerManager);
  
          ExecutionMessage executionMessage = new ExecutionMessage();
          executionMessage.setMsgId(String.valueOf(100L));
          simpleExecutionRunnable.setExecutionMessage(executionMessage);
          simpleExecutionRunnable.run();
          verify(executionService, times(1)).execute(execution);
  
          Assert.assertFalse(buffer.isEmpty());
          assertEquals(ExecStatus.FINISHED, buffer.get(0).getStatus());
  
          assertEquals(ExecStatus.FINISHED, buffer.get(0).getStatus());
          assertEquals(0, this.executionMessage.getMsgSeqId());
      }
test_case.class_method_signature: SimpleExecutionRunnableTest.testRun()
test_case.full_signature: @Test public void testRun()
test_case.identifier: testRun
test_case.invocations: thenReturn when extractExecution any put when doAnswer getArguments add any thenReturn when isFromCurrentThreadPool anyString setMsgId valueOf setExecutionMessage run execute verify times assertFalse isEmpty assertEquals getStatus get assertEquals getStatus get assertEquals getMsgSeqId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRun()
focal_class.declarator: logger = Logger.getLogger(SimpleExecutionRunnable.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(SimpleExecutionRunnable.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: WORKER_EXECUTION_INTERVAL = Integer.getInteger("worker.executionIntervalSeconds", 60) * 1_000L
focal_class.modifier: private static final
focal_class.original_string: private static final long WORKER_EXECUTION_INTERVAL = Integer.getInteger("worker.executionIntervalSeconds", 60) * 1_000L;
focal_class.type: long
focal_class.var_name: WORKER_EXECUTION_INTERVAL
focal_class.declarator: executionService
focal_class.modifier: private final
focal_class.original_string: private final ExecutionService executionService;
focal_class.type: ExecutionService
focal_class.var_name: executionService
focal_class.declarator: outBuffer
focal_class.modifier: private final
focal_class.original_string: private final OutboundBuffer outBuffer;
focal_class.type: OutboundBuffer
focal_class.var_name: outBuffer
focal_class.declarator: inBuffer
focal_class.modifier: private final
focal_class.original_string: private final InBuffer inBuffer;
focal_class.type: InBuffer
focal_class.var_name: inBuffer
focal_class.declarator: converter
focal_class.modifier: private final
focal_class.original_string: private final ExecutionMessageConverter converter;
focal_class.type: ExecutionMessageConverter
focal_class.var_name: converter
focal_class.declarator: endExecutionCallback
focal_class.modifier: private final
focal_class.original_string: private final EndExecutionCallback endExecutionCallback;
focal_class.type: EndExecutionCallback
focal_class.var_name: endExecutionCallback
focal_class.declarator: executionMessage
focal_class.modifier: private
focal_class.original_string: private ExecutionMessage executionMessage;
focal_class.type: ExecutionMessage
focal_class.var_name: executionMessage
focal_class.declarator: queueStateIdGeneratorService
focal_class.modifier: private final
focal_class.original_string: private final QueueStateIdGeneratorService queueStateIdGeneratorService;
focal_class.type: QueueStateIdGeneratorService
focal_class.var_name: queueStateIdGeneratorService
focal_class.declarator: workerUUID
focal_class.modifier: private final
focal_class.original_string: private final String workerUUID;
focal_class.type: String
focal_class.var_name: workerUUID
focal_class.declarator: workerConfigurationService
focal_class.modifier: private final
focal_class.original_string: private final WorkerConfigurationService workerConfigurationService;
focal_class.type: WorkerConfigurationService
focal_class.var_name: workerConfigurationService
focal_class.declarator: isRecoveryDisabled
focal_class.modifier: private final
focal_class.original_string: private final boolean isRecoveryDisabled;
focal_class.type: boolean
focal_class.var_name: isRecoveryDisabled
focal_class.declarator: workerManager
focal_class.modifier: private final
focal_class.original_string: private final WorkerManager workerManager;
focal_class.type: WorkerManager
focal_class.var_name: workerManager
focal_class.file: worker/worker-manager/score-worker-manager-impl/src/main/java/io/cloudslang/worker/management/services/SimpleExecutionRunnable.java
focal_class.identifier: SimpleExecutionRunnable
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: SimpleExecutionRunnable.SimpleExecutionRunnable(ExecutionService executionService,
                                     OutboundBuffer outBuffer,
                                     InBuffer inBuffer,
                                     ExecutionMessageConverter converter,
                                     EndExecutionCallback endExecutionCallback,
                                     QueueStateIdGeneratorService queueStateIdGeneratorService,
                                     String workerUUID,
                                     WorkerConfigurationService workerConfigurationService,
                                     WorkerManager workerManager)
focal_class.full_signature: public  SimpleExecutionRunnable(ExecutionService executionService,
                                     OutboundBuffer outBuffer,
                                     InBuffer inBuffer,
                                     ExecutionMessageConverter converter,
                                     EndExecutionCallback endExecutionCallback,
                                     QueueStateIdGeneratorService queueStateIdGeneratorService,
                                     String workerUUID,
                                     WorkerConfigurationService workerConfigurationService,
                                     WorkerManager workerManager)
focal_class.identifier: SimpleExecutionRunnable
focal_class.modifiers: public
focal_class.parameters: (ExecutionService executionService,
                                     OutboundBuffer outBuffer,
                                     InBuffer inBuffer,
                                     ExecutionMessageConverter converter,
                                     EndExecutionCallback endExecutionCallback,
                                     QueueStateIdGeneratorService queueStateIdGeneratorService,
                                     String workerUUID,
                                     WorkerConfigurationService workerConfigurationService,
                                     WorkerManager workerManager)
focal_class.signature:  SimpleExecutionRunnable(ExecutionService executionService,
                                     OutboundBuffer outBuffer,
                                     InBuffer inBuffer,
                                     ExecutionMessageConverter converter,
                                     EndExecutionCallback endExecutionCallback,
                                     QueueStateIdGeneratorService queueStateIdGeneratorService,
                                     String workerUUID,
                                     WorkerConfigurationService workerConfigurationService,
                                     WorkerManager workerManager)
focal_class.class_method_signature: SimpleExecutionRunnable.getExecutionMessage()
focal_class.full_signature: public ExecutionMessage getExecutionMessage()
focal_class.identifier: getExecutionMessage
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ExecutionMessage
focal_class.signature: ExecutionMessage getExecutionMessage()
focal_class.class_method_signature: SimpleExecutionRunnable.setExecutionMessage(ExecutionMessage executionMessage)
focal_class.full_signature: public void setExecutionMessage(ExecutionMessage executionMessage)
focal_class.identifier: setExecutionMessage
focal_class.modifiers: public
focal_class.parameters: (ExecutionMessage executionMessage)
focal_class.return: void
focal_class.signature: void setExecutionMessage(ExecutionMessage executionMessage)
focal_class.class_method_signature: SimpleExecutionRunnable.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: SimpleExecutionRunnable.executeRegularStep(Execution execution)
focal_class.full_signature: private void executeRegularStep(Execution execution)
focal_class.identifier: executeRegularStep
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: void
focal_class.signature: void executeRegularStep(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.shouldStop(Execution nextStepExecution, long startTime)
focal_class.full_signature: private boolean shouldStop(Execution nextStepExecution, long startTime)
focal_class.identifier: shouldStop
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution, long startTime)
focal_class.return: boolean
focal_class.signature: boolean shouldStop(Execution nextStepExecution, long startTime)
focal_class.class_method_signature: SimpleExecutionRunnable.isMiRunning(Execution nextStepExecution)
focal_class.full_signature: private boolean isMiRunning(Execution nextStepExecution)
focal_class.identifier: isMiRunning
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isMiRunning(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.preconditionNotFulfilled(Execution nextStepExecution)
focal_class.full_signature: private boolean preconditionNotFulfilled(Execution nextStepExecution)
focal_class.identifier: preconditionNotFulfilled
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean preconditionNotFulfilled(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.isExecutionPaused(Execution nextStepExecution)
focal_class.full_signature: private boolean isExecutionPaused(Execution nextStepExecution)
focal_class.identifier: isExecutionPaused
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isExecutionPaused(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.isRecoveryCheckpoint(Execution nextStepExecution)
focal_class.full_signature: private boolean isRecoveryCheckpoint(Execution nextStepExecution)
focal_class.identifier: isRecoveryCheckpoint
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isRecoveryCheckpoint(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.isPersistStep(Execution nextStepExecution)
focal_class.full_signature: private boolean isPersistStep(Execution nextStepExecution)
focal_class.identifier: isPersistStep
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isPersistStep(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.isSplitStep(Execution nextStepExecution)
focal_class.full_signature: private boolean isSplitStep(Execution nextStepExecution)
focal_class.identifier: isSplitStep
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isSplitStep(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.shouldChangeWorkerGroup(Execution nextStepExecution)
focal_class.full_signature: private boolean shouldChangeWorkerGroup(Execution nextStepExecution)
focal_class.identifier: shouldChangeWorkerGroup
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean shouldChangeWorkerGroup(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.isStickyToThisWorker(String groupName)
focal_class.full_signature: private boolean isStickyToThisWorker(String groupName)
focal_class.identifier: isStickyToThisWorker
focal_class.modifiers: private
focal_class.parameters: (String groupName)
focal_class.return: boolean
focal_class.signature: boolean isStickyToThisWorker(String groupName)
focal_class.class_method_signature: SimpleExecutionRunnable.isOldThread()
focal_class.full_signature: private boolean isOldThread()
focal_class.identifier: isOldThread
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isOldThread()
focal_class.class_method_signature: SimpleExecutionRunnable.isExecutionCancelled(Execution execution)
focal_class.full_signature: private boolean isExecutionCancelled(Execution execution)
focal_class.identifier: isExecutionCancelled
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: boolean
focal_class.signature: boolean isExecutionCancelled(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.isCancelledExecution(Execution execution)
focal_class.full_signature: private boolean isCancelledExecution(Execution execution)
focal_class.identifier: isCancelledExecution
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: boolean
focal_class.signature: boolean isCancelledExecution(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.isRunningTooLong(long startTime, Execution nextStepExecution)
focal_class.full_signature: private boolean isRunningTooLong(long startTime, Execution nextStepExecution)
focal_class.identifier: isRunningTooLong
focal_class.modifiers: private
focal_class.parameters: (long startTime, Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isRunningTooLong(long startTime, Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.createTerminatedExecutionMessage(Execution nextStepExecution)
focal_class.full_signature: private ExecutionMessage createTerminatedExecutionMessage(Execution nextStepExecution)
focal_class.identifier: createTerminatedExecutionMessage
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: ExecutionMessage
focal_class.signature: ExecutionMessage createTerminatedExecutionMessage(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.createPendingExecutionMessage(Execution nextStepExecution)
focal_class.full_signature: private ExecutionMessage createPendingExecutionMessage(Execution nextStepExecution)
focal_class.identifier: createPendingExecutionMessage
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: ExecutionMessage
focal_class.signature: ExecutionMessage createPendingExecutionMessage(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.createInProgressExecutionMessage(Execution nextStepExecution)
focal_class.full_signature: private ExecutionMessage createInProgressExecutionMessage(Execution nextStepExecution)
focal_class.identifier: createInProgressExecutionMessage
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: ExecutionMessage
focal_class.signature: ExecutionMessage createInProgressExecutionMessage(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.executeSplitStep(Execution execution)
focal_class.full_signature: private void executeSplitStep(Execution execution)
focal_class.identifier: executeSplitStep
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: void
focal_class.signature: void executeSplitStep(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.executeParallelAndNonBlocking(Execution execution)
focal_class.full_signature: private void executeParallelAndNonBlocking(Execution execution)
focal_class.identifier: executeParallelAndNonBlocking
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: void
focal_class.signature: void executeParallelAndNonBlocking(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.executeMiStep(Execution execution)
focal_class.full_signature: private void executeMiStep(Execution execution)
focal_class.identifier: executeMiStep
focal_class.modifiers: private
focal_class.parameters: (Execution execution)
focal_class.return: void
focal_class.signature: void executeMiStep(Execution execution)
focal_class.class_method_signature: SimpleExecutionRunnable.isExecutionTerminating(Execution nextStepExecution)
focal_class.full_signature: private boolean isExecutionTerminating(Execution nextStepExecution)
focal_class.identifier: isExecutionTerminating
focal_class.modifiers: private
focal_class.parameters: (Execution nextStepExecution)
focal_class.return: boolean
focal_class.signature: boolean isExecutionTerminating(Execution nextStepExecution)
focal_class.class_method_signature: SimpleExecutionRunnable.getSplitId(List<Execution> newExecutions)
focal_class.full_signature: private String getSplitId(List<Execution> newExecutions)
focal_class.identifier: getSplitId
focal_class.modifiers: private
focal_class.parameters: (List<Execution> newExecutions)
focal_class.return: String
focal_class.signature: String getSplitId(List<Execution> newExecutions)
focal_method.body: @Override
      public void run() {
          String executionId = executionMessage.getMsgId();
  
          // We are renaming the thread for logging/monitoring purposes
          String origThreadName = currentThread().getName();
          currentThread().setName(origThreadName + "_" + executionId);
          Execution execution = null;
          try {
              // If we got here because of te shortcut we have the object
              // If we got here form DB - we need to extract the object from bytes
              execution = (executionMessage.getExecutionObject() != null) ? executionMessage.getExecutionObject()
                      : converter.extractExecution(executionMessage.getPayload());
  
              // Check which logic to trigger - regular execution or split
              if (executionService.isSplitStep(execution)) {
                  executeSplitStep(execution);
              } else {
                  executeRegularStep(execution);
              }
          } catch (InterruptedException interruptedException) {
  
              // Not old thread and interrupted by cancel
              if (workerManager.isFromCurrentThreadPool(currentThread().getName()) && isExecutionCancelled(execution)) {
                  if (logger.isDebugEnabled()) {
                      logger.debug("Execution is interrupted...");
                  }
              } else {
                  logger.error("Execution thread is interrupted!!! Exiting...", interruptedException);
              }
          } catch (Exception ex) {
              logger.error("Error during execution!!!", ex);
              // Set status FAILED
              executionMessage.setStatus(ExecStatus.FAILED);
              executionMessage
                      .incMsgSeqId();    // New status must be with incremented msg_seq_id - otherwise will be recovered and we will get duplications
              // Send only one execution message back - the new one was not created because of error
              try {
                  if (executionMessage.getPayload() == null) {
                      // This is done since we could get here from InBuffer shortcut - so no payload... and for FAILED message we need to set the payload
                      executionMessage.setPayload(converter.createPayload(execution));
                  }
                  outBuffer.put(executionMessage);
              } catch (InterruptedException e) {
                  logger.warn("Thread was interrupted! Exiting the execution... ", ex);
              }
          } finally {
              endExecutionCallback.endExecution(parseLong(executionId));
              // Rename the thread back
              currentThread().setName(origThreadName);
          }
      }
focal_method.class_method_signature: SimpleExecutionRunnable.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: getMsgId getName currentThread setName currentThread getExecutionObject getExecutionObject extractExecution getPayload isSplitStep executeSplitStep executeRegularStep isFromCurrentThreadPool getName currentThread isExecutionCancelled isDebugEnabled debug error error setStatus incMsgSeqId getPayload setPayload createPayload put warn endExecution parseLong setName currentThread
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()