< 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: 53
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.Authorization;
 2using Elsa.Abstractions;
 3using Elsa.Alterations.Core.Contracts;
 4using Elsa.Alterations.Core.Filters;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Alterations.Endpoints.Alterations.Get;
 8
 9/// <summary>
 10/// Gets an alteration plan and its associated jobs.
 11/// </summary>
 12[PublicAPI]
 13public class Get : ElsaEndpointWithoutRequest<Response>
 14{
 15    private readonly IAlterationPlanStore _alterationPlanStore;
 16    private readonly IAlterationJobStore _alterationJobStore;
 17
 18    /// <inheritdoc />
 319    public Get(IAlterationPlanStore alterationPlanStore, IAlterationJobStore alterationJobStore)
 20    {
 321        _alterationPlanStore = alterationPlanStore;
 322        _alterationJobStore = alterationJobStore;
 323    }
 24
 25    /// <inheritdoc />
 26    public override void Configure()
 27    {
 328        Get("/alterations/{id}");
 329        RequirePermission(Elsa.Alterations.Permissions.AlterationPermissions.Alterations, CoreVerbs.View);
 330    }
 31
 32    /// <inheritdoc />
 33    public override async Task HandleAsync(CancellationToken cancellationToken)
 34    {
 035        var planId = Route<string>("id");
 36
 37        // Load the plan.
 038        var plan = await _alterationPlanStore.FindAsync(new AlterationPlanFilter { Id = planId }, cancellationToken);
 39
 040        if (plan == null)
 41        {
 042            await Send.NotFoundAsync(cancellationToken);
 043            return;
 44        }
 45
 46        // Load the jobs.
 047        var jobs = (await _alterationJobStore.FindManyAsync(new AlterationJobFilter { PlanId = planId }, cancellationTok
 48
 49        // Write response.
 050        var response = new Response(plan, jobs);
 051        await Send.OkAsync(response, cancellationToken);
 052    }
 53}