< Summary

Information
Class: Elsa.Alterations.Endpoints.Alterations.Get.Get
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Endpoints/Alterations/Get/Endpoint.cs
Line coverage
43%
Covered lines: 7
Uncovered lines: 9
Coverable lines: 16
Total lines: 52
Line coverage: 43.7%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
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()0%620%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Alterations.Core.Contracts;
 3using Elsa.Alterations.Core.Filters;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Alterations.Endpoints.Alterations.Get;
 7
 8/// <summary>
 9/// Gets an alteration plan and its associated jobs.
 10/// </summary>
 11[PublicAPI]
 12public class Get : ElsaEndpointWithoutRequest<Response>
 13{
 14    private readonly IAlterationPlanStore _alterationPlanStore;
 15    private readonly IAlterationJobStore _alterationJobStore;
 16
 17    /// <inheritdoc />
 118    public Get(IAlterationPlanStore alterationPlanStore, IAlterationJobStore alterationJobStore)
 19    {
 120        _alterationPlanStore = alterationPlanStore;
 121        _alterationJobStore = alterationJobStore;
 122    }
 23
 24    /// <inheritdoc />
 25    public override void Configure()
 26    {
 127        Get("/alterations/{id}");
 128        ConfigurePermissions("read:alterations");
 129    }
 30
 31    /// <inheritdoc />
 32    public override async Task HandleAsync(CancellationToken cancellationToken)
 33    {
 034        var planId = Route<string>("id");
 35
 36        // Load the plan.
 037        var plan = await _alterationPlanStore.FindAsync(new AlterationPlanFilter { Id = planId }, cancellationToken);
 38
 039        if (plan == null)
 40        {
 041            await Send.NotFoundAsync(cancellationToken);
 042            return;
 43        }
 44
 45        // Load the jobs.
 046        var jobs = (await _alterationJobStore.FindManyAsync(new AlterationJobFilter { PlanId = planId }, cancellationTok
 47
 48        // Write response.
 049        var response = new Response(plan, jobs);
 050        await Send.OkAsync(response, cancellationToken);
 051    }
 52}