< Summary

Information
Class: Elsa.Labels.Endpoints.WorkflowDefinitionLabels.List.List
Assembly: Elsa.Labels
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Endpoints/WorkflowDefinitionLabels/List/Endpoint.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 49
Line coverage: 0%
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%210%
Configure()100%210%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Labels/Endpoints/WorkflowDefinitionLabels/List/Endpoint.cs

#LineLine coverage
 1using Elsa.Labels.Contracts;
 2using Elsa.Workflows.Management;
 3using Elsa.Workflows.Management.Filters;
 4using FastEndpoints;
 5using JetBrains.Annotations;
 6using Open.Linq.AsyncExtensions;
 7
 8namespace Elsa.Labels.Endpoints.WorkflowDefinitionLabels.List;
 9
 10[PublicAPI]
 11internal class List : Endpoint<Request, Response>
 12{
 13    private readonly IWorkflowDefinitionStore _workflowDefinitionStore;
 14    private readonly IWorkflowDefinitionLabelStore _workflowDefinitionLabelStore;
 15
 016    public List(
 017        IWorkflowDefinitionStore workflowDefinitionStore,
 018        IWorkflowDefinitionLabelStore workflowDefinitionLabelStore)
 19    {
 020        _workflowDefinitionStore = workflowDefinitionStore;
 021        _workflowDefinitionLabelStore = workflowDefinitionLabelStore;
 022    }
 23
 24    public override void Configure()
 25    {
 026        Get("/workflow-definitions/{id}/labels");
 027        Policies(Constants.PolicyName);
 028    }
 29
 30    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 31    {
 032        var workflowDefinition = await _workflowDefinitionStore.FindAsync(new WorkflowDefinitionFilter { Id = request.Id
 33
 034        if (workflowDefinition == null)
 35        {
 036            await Send.NotFoundAsync(cancellationToken);
 037            return;
 38        }
 39
 040        var currentLabels = await _workflowDefinitionLabelStore.FindByWorkflowDefinitionVersionIdAsync(request.Id, cance
 41
 042        var response = new Response
 043        {
 044            Items = currentLabels.ToList()
 045        };
 46
 047        await Send.OkAsync(response, cancellationToken);
 048    }
 49}