< 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: 44
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.Authorization;
 2using Elsa.Abstractions;
 3using Elsa.Alterations.Core.Contracts;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Alterations.Endpoints.Alterations.Run;
 7
 8/// <summary>
 9/// Executes an alteration plan by targeting workflow instances by ID.
 10/// </summary>
 11[PublicAPI]
 12public class Run : ElsaEndpoint<Request, Response>
 13{
 14    private readonly IAlterationRunner _alterationRunner;
 15    private readonly IAlteredWorkflowDispatcher _workflowDispatcher;
 16
 17    /// <inheritdoc />
 318    public Run(IAlterationRunner alterationRunner, IAlteredWorkflowDispatcher workflowDispatcher)
 19    {
 320        _alterationRunner = alterationRunner;
 321        _workflowDispatcher = workflowDispatcher;
 322    }
 23
 24    /// <inheritdoc />
 25    public override void Configure()
 26    {
 327        Post("/alterations/run");
 328        RequirePermission(Elsa.Alterations.Permissions.AlterationPermissions.Alterations, CoreVerbs.Execute);
 329    }
 30
 31    /// <inheritdoc />
 32    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 33    {
 34        // Run the alterations.
 035        var results = await _alterationRunner.RunAsync(request.WorkflowInstanceIds, request.Alterations, cancellationTok
 36
 37        // Schedule each successfully updated workflow containing scheduled work.
 038        await _workflowDispatcher.DispatchAsync(results, cancellationToken);
 39
 40        // Write response.
 041        var response = new Response(results);
 042        await Send.OkAsync(response, cancellationToken);
 043    }
 44}