Pause delivery execution if test session was paused.
@param TestExecutionPausedEvent $event
963583
public function catchSessionPause(TestExecutionPausedEvent $event)
    {
        $deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($event->getTestExecutionId());
        /** @var DeliveryExecutionStateService $service */
        $requestParams = \Context::getInstance()->getRequest()->getParameters();
        $reason = null;
        if (isset($requestParams['reason'])) {
            $reason = $requestParams['reason'];
        }
        if ($deliveryExecution->getState()->getUri() !== DeliveryExecution::STATE_PAUSED) {
            $this->pause($deliveryExecution, $reason);
        }
    }
1226336
public function onRestoreStarted(RestoreEvent $event)
    {
        $database = $event->getDatabase();
        if ($database->getWithDefault('state', BackupStatus::STATE_SUCCESS) === BackupStatus::STATE_FAILED) {
            $this->output->writeln('  <info>Bypassed</info>');

            $event->stopPropagation();
        }
    }
927572
function pause() {
        $this->paused = true;
        
        if($this->started && !$this->closed) {
            $this->driver->pauseStreamConsumption();
        }
    }
950186
private static function createErrorMessage($deliveryExecution, $action)
    {
        if ($deliveryExecution->getState()->getUri() === DeliveryExecution::STATE_FINISHED) {
            $errorMsg = __('%s could not be %s because it is finished. Please refresh your data.', $deliveryExecution->getLabel(), $action);
        } else if ($deliveryExecution->getState()->getUri() === DeliveryExecution::STATE_TERMINATED) {
            $errorMsg = __('%s could not be %s because it is terminated. Please refresh your data.', $deliveryExecution->getLabel(), $action);
        } else {
            $errorMsg = __('%s could not be %s.', $deliveryExecution->getLabel(), $action);
        }

        return $errorMsg;
    }
1214714
private function setExitCode(ExecutableTest $test)
    {
        $exit = $test->getExitCode();
        if ($exit > $this->exitcode) {
            $this->exitcode = $exit;
        }
    }
319755
public void delayEvent(PvmExecutionImpl targetScope, VariableEvent variableEvent) {
    DelayedVariableEvent delayedVariableEvent = new DelayedVariableEvent(targetScope, variableEvent);
    delayEvent(delayedVariableEvent);
  }
788087
protected boolean handlePausedFlow(Execution execution) throws InterruptedException {
        String branchId = execution.getSystemContext().getBranchId();
        PauseReason reason = findPauseReason(execution.getExecutionId(), branchId);
        if (reason != null) { // need to pause the execution
            pauseFlow(reason, execution);
            return true;
        }
        return false;
    }
650028
public function handleQueryExecute(QueryExecuteEvent $event)
    {
        $query = $event->getQuery();
        $locale = $query->getLocale();
        $phpcrResult = $query->getPhpcrQuery()->execute();

        $event->setResult(
            new QueryResultCollection($phpcrResult, $this->eventDispatcher, $locale, $event->getOptions())
        );
    }
771922
@Override
    public void pause() throws PauseableComponentException {
        try {
            if (ivState == ACTIVE_STATE) {
                deactivateEndpoint();
            } else if (ivState == INACTIVE_STATE) {
                Tr.info(tc, "MDB_ENDPOINT_ALREADY_INACTIVE_CNTR4117I", beanMetaData.enterpriseBeanName, beanMetaData.getModuleMetaData().getName(),
                        beanMetaData.getModuleMetaData().getApplicationMetaData().getName());
            } else {
                throw new PauseableComponentException(Tr.formatMessage(tc, "MDB_ENDPOINT_DID_NOT_PAUSE_CNTR4119W", beanMetaData.enterpriseBeanName,
                                                                       beanMetaData.getModuleMetaData().getName(),
                                                                       beanMetaData.getModuleMetaData().getApplicationMetaData().getName()));
            }
        } catch (ResourceException re) {
            throw new PauseableComponentException(re);
        }

    }
492115
public void waitForEachEventLoop() throws InterruptedException, ExecutionException
    {
        for (EventExecutor exec : serverGroup.clientToProxyWorkerPool)
        {
            exec.submit(() -> {
                // Do nothing.
            }).get();
        }
    }
1082146
public void eventCancelledByEventGateway(DelegateExecution execution) {
    Context.getCommandContext().getExecutionEntityManager().deleteExecutionAndRelatedData((ExecutionEntity) execution, 
        DeleteReason.EVENT_BASED_GATEWAY_CANCEL, false);
  }
1294554
public function onDeliveryCreated(DeliveryCreatedEvent $event)
    {
        $delivery = $this->getResource($event->getDeliveryUri());

        $proctoredByDefault = $this->isProctoredByDefault();

        $delivery->editPropertyValues($this->getProperty(ProctorService::ACCESSIBLE_PROCTOR), (
        $proctoredByDefault ? ProctorService::ACCESSIBLE_PROCTOR_ENABLED : ProctorService::ACCESSIBLE_PROCTOR_DISABLED
        ));
    }
1284030
@Override
    public void doExecute(TestContext context) {
        try {
            Message receivedMessage;
            String selector = MessageSelectorBuilder.build(messageSelector, messageSelectorMap, context);

            //receive message either selected or plain with message receiver
            if (StringUtils.hasText(selector)) {
                receivedMessage = receiveSelected(context, selector);
            } else {
                receivedMessage = receive(context);
            }

            if (receivedMessage == null) {
                throw new CitrusRuntimeException("Failed to receive message - message is not available");
            }

            //validate the message
            validateMessage(receivedMessage, context);
        } catch (IOException e) {
            throw new CitrusRuntimeException(e);
        }
    }
1035799
public function onBuildKernel(PreBuildKernelEvent $event)
    {
        if (!$this->enabled) {
            return;
        }

        if (!isset($this->options['extensions'])) {
            return;
        }

        $settings = ['site.ini/ExtensionSettings/ActiveExtensions' => $this->options['extensions']];

        $event->getParameters()->set(
            'injected-merge-settings',
            $settings + (array)$event->getParameters()->get('injected-merge-settings')
        );
    }
415776
private static function adjustDeliveryExecutions($deliveryExecutions) {

        /** @var TestSessionConnectivityStatusService $testSessionConnectivityStatusService */
        $testSessionConnectivityStatusService = ServiceManager::getServiceManager()->get(TestSessionConnectivityStatusService::SERVICE_ID);

        $executions = [];
        foreach ($deliveryExecutions as $cachedData) {

            $state = [
                'status' => $cachedData[DeliveryMonitoringService::STATUS],
                'progress' => $cachedData[DeliveryMonitoringService::CURRENT_ASSESSMENT_ITEM]
            ];

            $testTaker = [];
            $extraFields = [];

            /* @var $user User */
            $testTaker['id'] = $cachedData[DeliveryMonitoringService::TEST_TAKER];
            $testTaker['test_taker_last_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]):'';
            $testTaker['test_taker_first_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]):'';

            foreach(self::_getUserExtraFields() as $field){
                $extraFields[$field['id']] = isset($cachedData[$field['id']]) ? _dh($cachedData[$field['id']]) : '';
            }

            $online = null;
            if ($testSessionConnectivityStatusService->hasOnlineMode()) {
                $rawConnectivity = isset($cachedData[DeliveryMonitoringService::CONNECTIVITY]) ? $cachedData[DeliveryMonitoringService::CONNECTIVITY] : false;
                $online = $testSessionConnectivityStatusService->isOnline($cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID], $rawConnectivity);
            }

            if (isset($cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY]) && $online) {
                $lastActivity = $cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY];
            } else {
                $lastActivity = null;
            }

            $executionState = $cachedData[DeliveryMonitoringService::STATUS];
            $extraTime = (isset($cachedData[DeliveryMonitoringService::EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::EXTRA_TIME]) : 0;
            $remaining = self::getRemainingTime($cachedData);
            $approximatedRemaining = self::getApproximatedRemainingTime($cachedData, $online, $lastActivity);

            $execution = array(
                'id' => $cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID],
                'delivery' => array(
                    'uri' => $cachedData[DeliveryMonitoringService::DELIVERY_ID],
                    'label' => _dh($cachedData[DeliveryMonitoringService::DELIVERY_NAME]),
                ),
                'start_time' => $cachedData[DeliveryMonitoringService::START_TIME],
                'allowExtraTime' => (isset($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME])) ? boolval($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME]) : null,
                'timer' => [
                    'lastActivity' => $lastActivity,
                    'countDown' => (DeliveryExecution::STATE_ACTIVE == $executionState && $online) ? true : false,
                    'approximatedRemaining' => $approximatedRemaining,
                    'remaining_time' => $remaining,
                    'extraTime' => $extraTime,
                    'extendedTime' => (isset($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) && $cachedData[DeliveryMonitoringService::EXTENDED_TIME] > 1) ? floatval($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) : '',
                    'consumedExtraTime' => (isset($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME]) : 0
                ],
                'testTaker' => $testTaker,
                'extraFields' => $extraFields,
                'state' => $state,
            );

            if ($online) {
                $execution['online'] = $online;
            }

            $executions[] = $execution;
        }

        return $executions;
    }
1099273
public static TestCaseStartedEvent withExecutorInfo(TestCaseStartedEvent event) {
        event.getLabels().add(createHostLabel(getHostname()));
        event.getLabels().add(createThreadLabel(format("%s.%s(%s)",
                        ManagementFactory.getRuntimeMXBean().getName(),
                        Thread.currentThread().getName(),
                        Thread.currentThread().getId())
        ));
        return event;
    }
336589
private function captureOutlineOnBeforeOutlineEvent(Event $event)
    {
        if (!$event instanceof BeforeOutlineTested) {
            return;
        }

        $this->outline = $event->getOutline();
        $this->headerPrinted = false;
    }