< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetById.GetById
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetById/Endpoint.cs
Line coverage
87%
Covered lines: 14
Uncovered lines: 2
Coverable lines: 16
Total lines: 37
Line coverage: 87.5%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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()50%2281.81%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetById/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Workflows.Management;
 3using Elsa.Workflows.Management.Filters;
 4using JetBrains.Annotations;
 5using Microsoft.AspNetCore.Builder;
 6
 7namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetById;
 8
 9[PublicAPI]
 210internal class GetById(IWorkflowDefinitionStore store, IWorkflowDefinitionLinker linker) : ElsaEndpoint<Request>
 11{
 12    public override void Configure()
 13    {
 114        Get("/workflow-definitions/by-id/{id}");
 115        ConfigurePermissions("read:workflow-definitions");
 216        Options(x => x.WithName("GetWorkflowDefinitionById"));
 117    }
 18
 19    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 20    {
 121        var filter = new WorkflowDefinitionFilter
 122        {
 123            Id = request.Id
 124        };
 25
 126        var definition = await store.FindAsync(filter, cancellationToken);
 27
 128        if (definition == null)
 29        {
 030            await Send.NotFoundAsync(cancellationToken);
 031            return;
 32        }
 33
 134        var model = await linker.MapAsync(definition, cancellationToken);
 135        await Send.OkAsync(model, cancellationToken);
 136    }
 37}