< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetByDefinitionId.GetByDefinitionId
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/GetByDefinitionId/Endpoint.cs
Line coverage
30%
Covered lines: 4
Uncovered lines: 9
Coverable lines: 13
Total lines: 33
Line coverage: 30.7%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%2040%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Common.Models;
 3using Elsa.Workflows.Management;
 4using Elsa.Workflows.Models;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.GetByDefinitionId;
 8
 9[PublicAPI]
 110internal class GetByDefinitionId(IWorkflowDefinitionStore store, IWorkflowDefinitionLinker linker) : ElsaEndpoint<Reques
 11{
 12    public override void Configure()
 13    {
 114        Get("/workflow-definitions/by-definition-id/{definitionId}", "/workflow-definitions/{definitionId}");
 115        ConfigurePermissions("read:workflow-definitions");
 116    }
 17
 18    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 19    {
 020        var versionOptions = request.VersionOptions != null ? VersionOptions.FromString(request.VersionOptions) : Versio
 021        var filter = WorkflowDefinitionHandle.ByDefinitionId(request.DefinitionId, versionOptions).ToFilter();
 022        var definition = await store.FindAsync(filter, cancellationToken);
 23
 024        if (definition == null)
 25        {
 026            await Send.NotFoundAsync(cancellationToken);
 027            return;
 28        }
 29
 030        var model = await linker.MapAsync(definition, cancellationToken);
 031        await Send.OkAsync(model, cancellationToken);
 032    }
 33}