< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.ActivityDescriptorOptions.Get.Get
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/ActivityDescriptorOptions/Get/Endpoint.cs
Line coverage
44%
Covered lines: 8
Uncovered lines: 10
Coverable lines: 18
Total lines: 47
Line coverage: 44.4%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%4260%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using JetBrains.Annotations;
 3
 4namespace Elsa.Workflows.Api.Endpoints.ActivityDescriptorOptions.Get;
 5
 6[PublicAPI]
 7internal class Get : ElsaEndpoint<Request, Response>
 8{
 9    private readonly IServiceProvider _serviceProvider;
 10    private readonly IActivityRegistryLookupService _registryLookup;
 11    private readonly IPropertyUIHandlerResolver _optionsResolver;
 12
 13    /// <inheritdoc />
 114    public Get(IServiceProvider serviceProvider, IActivityRegistryLookupService registryLookup, IPropertyUIHandlerResolv
 15    {
 116        _serviceProvider = serviceProvider;
 117        _registryLookup = registryLookup;
 118        _optionsResolver = optionsResolver;
 119    }
 20
 21    /// <inheritdoc />
 22    public override void Configure()
 23    {
 124        Post("/descriptors/activities/{activityTypeName}/options/{propertyName}");
 125        ConfigurePermissions("read:*", "read:activity-descriptors-options");
 126    }
 27
 28    /// <inheritdoc />
 29    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 30    {
 031        var descriptor = request.Version == null ? await _registryLookup.FindAsync(request.ActivityTypeName) : await _re
 032        if (descriptor == null)
 033            await Send.NotFoundAsync(cancellationToken);
 34
 035        var propertyDescriptor =  descriptor!.Inputs.FirstOrDefault(x => x.Name == request.PropertyName);
 36
 037        if(propertyDescriptor == null)
 38        {
 039            await Send.NotFoundAsync(cancellationToken);
 040            return;
 41        }
 42
 043        var inputOptions = await _optionsResolver.GetUIPropertiesAsync(propertyDescriptor.PropertyInfo!, request.Context
 44
 045        await Send.OkAsync(new Response(inputOptions), cancellationToken);
 046    }
 47}