< Summary

Information
Class: Elsa.Workflows.Runtime.DefaultCommitStateHandler
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/DefaultCommitStateHandler.cs
Line coverage
85%
Covered lines: 18
Uncovered lines: 3
Coverable lines: 21
Total lines: 38
Line coverage: 85.7%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CommitAsync()100%210%
CommitAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/DefaultCommitStateHandler.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.CommitStates;
 3using Elsa.Workflows.Management;
 4using Elsa.Workflows.Runtime.Entities;
 5using Elsa.Workflows.Runtime.Notifications;
 6using Elsa.Workflows.Runtime.Requests;
 7using Elsa.Workflows.State;
 8
 9namespace Elsa.Workflows.Runtime;
 10
 43711public class DefaultCommitStateHandler(
 43712    IWorkflowInstanceManager workflowInstanceManager,
 43713    IBookmarksPersister bookmarkPersister,
 43714    IVariablePersistenceManager variablePersistenceManager,
 43715    IMediator mediator,
 43716    ILogRecordSink<ActivityExecutionRecord> activityExecutionLogRecordSink,
 43717    ILogRecordSink<WorkflowExecutionLogRecord> workflowExecutionLogRecordSink) : ICommitStateHandler
 18{
 19    public async Task CommitAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken
 20    {
 021        var workflowState = workflowInstanceManager.ExtractWorkflowState(workflowExecutionContext);
 022        await CommitAsync(workflowExecutionContext, workflowState, cancellationToken);
 023    }
 24
 25    public async Task CommitAsync(WorkflowExecutionContext workflowExecutionContext, WorkflowState workflowState, Cancel
 26    {
 46627        var updateBookmarksRequest = new UpdateBookmarksRequest(workflowExecutionContext, workflowExecutionContext.Bookm
 46628        await bookmarkPersister.PersistBookmarksAsync(updateBookmarksRequest);
 46629        await activityExecutionLogRecordSink.PersistExecutionLogsAsync(workflowExecutionContext, cancellationToken);
 46630        await workflowExecutionLogRecordSink.PersistExecutionLogsAsync(workflowExecutionContext, cancellationToken);
 46631        await variablePersistenceManager.SaveVariablesAsync(workflowExecutionContext);
 46632        var workflowInstance = await workflowInstanceManager.SaveAsync(workflowState, cancellationToken);
 46633        workflowExecutionContext.ExecutionLog.Clear();
 46634        workflowExecutionContext.ClearCompletedActivityExecutionContexts();
 46635        await workflowExecutionContext.ExecuteDeferredTasksAsync();
 46636        await mediator.SendAsync(new WorkflowStateCommitted(workflowExecutionContext, workflowState, workflowInstance), 
 46637    }
 38}