< Summary

Information
Class: Elsa.Alterations.Endpoints.Alterations.Run.Run
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Endpoints/Alterations/Run/Endpoint.cs
Line coverage
58%
Covered lines: 7
Uncovered lines: 5
Coverable lines: 12
Total lines: 43
Line coverage: 58.3%
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%
Configure()100%11100%
HandleAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Endpoints/Alterations/Run/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Alterations.Core.Contracts;
 3using JetBrains.Annotations;
 4
 5namespace Elsa.Alterations.Endpoints.Alterations.Run;
 6
 7/// <summary>
 8/// Executes an alteration plan by targeting workflow instances by ID.
 9/// </summary>
 10[PublicAPI]
 11public class Run : ElsaEndpoint<Request, Response>
 12{
 13    private readonly IAlterationRunner _alterationRunner;
 14    private readonly IAlteredWorkflowDispatcher _workflowDispatcher;
 15
 16    /// <inheritdoc />
 117    public Run(IAlterationRunner alterationRunner, IAlteredWorkflowDispatcher workflowDispatcher)
 18    {
 119        _alterationRunner = alterationRunner;
 120        _workflowDispatcher = workflowDispatcher;
 121    }
 22
 23    /// <inheritdoc />
 24    public override void Configure()
 25    {
 126        Post("/alterations/run");
 127        ConfigurePermissions("run:alterations");
 128    }
 29
 30    /// <inheritdoc />
 31    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 32    {
 33        // Run the alterations.
 034        var results = await _alterationRunner.RunAsync(request.WorkflowInstanceIds, request.Alterations, cancellationTok
 35
 36        // Schedule each successfully updated workflow containing scheduled work.
 037        await _workflowDispatcher.DispatchAsync(results, cancellationToken);
 38
 39        // Write response.
 040        var response = new Response(results);
 041        await Send.OkAsync(response, cancellationToken);
 042    }
 43}