< Summary

Information
Class: Elsa.Alterations.Endpoints.Alterations.Submit.Submit
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Endpoints/Alterations/Submit/Endpoint.cs
Line coverage
66%
Covered lines: 8
Uncovered lines: 4
Coverable lines: 12
Total lines: 45
Line coverage: 66.6%
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/Submit/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Alterations.Core.Contracts;
 3using Elsa.Alterations.Core.Models;
 4using Elsa.Common;
 5using Elsa.Workflows;
 6using JetBrains.Annotations;
 7
 8namespace Elsa.Alterations.Endpoints.Alterations.Submit;
 9
 10/// <summary>
 11/// Submits an alteration plan to be executed targeting workflow instances by a filter.
 12/// </summary>
 13[PublicAPI]
 14public class Submit : ElsaEndpoint<AlterationPlanParams, Response>
 15{
 16    private readonly IAlterationPlanScheduler _alterationPlanScheduler;
 17    private readonly IIdentityGenerator _identityGenerator;
 18    private readonly ISystemClock _systemClock;
 19
 20    /// <inheritdoc />
 121    public Submit(IAlterationPlanScheduler alterationPlanScheduler, IIdentityGenerator identityGenerator, ISystemClock s
 22    {
 123        _alterationPlanScheduler = alterationPlanScheduler;
 124        _identityGenerator = identityGenerator;
 125        _systemClock = systemClock;
 126    }
 27
 28    /// <inheritdoc />
 29    public override void Configure()
 30    {
 131        Post("/alterations/submit");
 132        ConfigurePermissions("run:alterations");
 133    }
 34
 35    /// <inheritdoc />
 36    public override async Task HandleAsync(AlterationPlanParams planParams, CancellationToken cancellationToken)
 37    {
 38        // Submit the plan.
 039        var planId = await _alterationPlanScheduler.SubmitAsync(planParams, cancellationToken);
 40
 41        // Write response.
 042        var response = new Response(planId);
 043        await Send.OkAsync(response, cancellationToken);
 044    }
 45}