< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.CommitStrategies.Workflows.List.List
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/CommitStrategies/Workflows/List/Endpoint.cs
Line coverage
50%
Covered lines: 4
Uncovered lines: 4
Coverable lines: 8
Total lines: 29
Line coverage: 50%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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%
ExecuteAsync(...)100%210%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Models;
 3using Elsa.Workflows.CommitStates;
 4
 5namespace Elsa.Workflows.Api.Endpoints.CommitStrategies.Workflows.List;
 6
 7/// <summary>
 8/// Represents an API endpoint that provides a list of registered workflow commit strategies.
 9/// </summary>
 10/// <remarks>
 11/// This class is an implementation of an endpoint that retrieves a collection of workflow commit strategy registrations
 12/// from a provided registry and returns them in a unified response.
 13/// </remarks>
 114internal class List(ICommitStrategyRegistry registry) : ElsaEndpointWithoutRequest<ListResponse<CommitStrategyDescriptor
 15{
 16    public override void Configure()
 17    {
 118        Get("/descriptors/commit-strategies/workflows");
 119        ConfigurePermissions("read:commit-strategies");
 120    }
 21
 22    public override Task<ListResponse<CommitStrategyDescriptor>> ExecuteAsync(CancellationToken cancellationToken)
 23    {
 024        var registrations = registry.ListWorkflowStrategyRegistrations().ToList();
 025        var descriptors = CommitStrategyDescriptor.FromStrategyMetadata(registrations.Select(x => x.Metadata)).ToList();
 026        var response =new ListResponse<CommitStrategyDescriptor>(descriptors);
 027        return Task.FromResult(response);
 28    }
 29}