< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Export.Export
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs
Line coverage
75%
Covered lines: 15
Uncovered lines: 5
Coverable lines: 20
Total lines: 55
Line coverage: 75%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
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()60%141066.66%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Common.Models;
 3using Elsa.Workflows.Management;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Export;
 7
 8/// <summary>
 9/// Exports the specified workflow definition as JSON download.
 10/// </summary>
 11[UsedImplicitly]
 712internal class Export(IWorkflowDefinitionExporter exporter) : ElsaEndpoint<Request>
 13{
 14    /// <inheritdoc />
 15    public override void Configure()
 16    {
 317        Routes("/bulk-actions/export/workflow-definitions", "/workflow-definitions/{definitionId}/export");
 318        Verbs(FastEndpoints.Http.GET, FastEndpoints.Http.POST);
 319        ConfigurePermissions("read:workflow-definitions");
 320    }
 21
 22    /// <inheritdoc />
 23    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 24    {
 425        if (request.DefinitionId != null)
 26        {
 227            var versionOptions = string.IsNullOrEmpty(request.VersionOptions) ? VersionOptions.Latest : VersionOptions.F
 228            var result = await exporter.ExportAsync(request.DefinitionId, versionOptions, request.IncludeConsumingWorkfl
 29
 230            if (result == null)
 31            {
 032                await Send.NotFoundAsync(cancellationToken);
 033                return;
 34            }
 35
 236            await Send.BytesAsync(result.Data, result.FileName, cancellation: cancellationToken);
 37        }
 238        else if (request.Ids != null)
 39        {
 240            var result = await exporter.ExportManyAsync(request.Ids, request.IncludeConsumingWorkflows, cancellationToke
 41
 242            if (result == null)
 43            {
 044                await Send.NoContentAsync(cancellationToken);
 045                return;
 46            }
 47
 248            await Send.BytesAsync(result.Data, result.FileName, cancellation: cancellationToken);
 49        }
 50        else
 51        {
 052            await Send.NoContentAsync(cancellationToken);
 53        }
 454    }
 55}