< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.ResumeDispatchWorkflowActivity
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ResumeDispatchWorkflowActivity.cs
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
Total lines: 48
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.cctor()100%11100%
HandleAsync()100%66100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/ResumeDispatchWorkflowActivity.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Helpers;
 3using Elsa.Workflows.Notifications;
 4using Elsa.Workflows.Runtime.Activities;
 5using Elsa.Workflows.Runtime.Stimuli;
 6using JetBrains.Annotations;
 7
 8namespace Elsa.Workflows.Runtime.Handlers;
 9
 10/// <summary>
 11/// Resumes any blocking <see cref="DispatchWorkflow"/> activities when its child workflow completes.
 12/// </summary>
 13[PublicAPI]
 46714internal class ResumeDispatchWorkflowActivity(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulusHasher) : INotificat
 15{
 216    private static readonly string ActivityTypeName = ActivityTypeNameHelper.GenerateTypeName<DispatchWorkflow>();
 17
 18    public async Task HandleAsync(WorkflowExecuted notification, CancellationToken cancellationToken)
 19    {
 46520        var workflowState = notification.WorkflowState;
 21
 46522        if (workflowState.Status != WorkflowStatus.Finished)
 6423            return;
 24
 40125        var props = workflowState.Properties;
 40126        var waitForCompletion = props.TryGetValue("WaitForCompletion", out var waitForCompletionValue) && (bool)waitForC
 27
 40128        if (!waitForCompletion)
 38229            return;
 30
 1931        var parentInstanceId = (string)props["ParentInstanceId"];
 1932        var stimulus = new DispatchWorkflowStimulus(notification.WorkflowState.Id);
 1933        var input = workflowState.Output;
 34
 1935        var bookmarkQueueItem = new NewBookmarkQueueItem
 1936        {
 1937            WorkflowInstanceId = parentInstanceId,
 1938            ActivityTypeName = ActivityTypeName,
 1939            StimulusHash = stimulusHasher.Hash(ActivityTypeName, stimulus),
 1940            Options = new()
 1941            {
 1942                Input = input
 1943            }
 1944        };
 45
 1946        await bookmarkQueue.EnqueueAsync(bookmarkQueueItem, cancellationToken);
 46547    }
 48}