< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Graph.Graph
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Graph/Endpoint.cs
Line coverage
84%
Covered lines: 11
Uncovered lines: 2
Coverable lines: 13
Total lines: 35
Line coverage: 84.6%
Branch coverage
50%
Covered branches: 2
Total branches: 4
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%4477.77%

File(s)

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

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Extensions;
 3using Elsa.Workflows.Management;
 4using Elsa.Workflows.Serialization.Converters;
 5using Elsa.Workflows.Serialization.Helpers;
 6using JetBrains.Annotations;
 7using Microsoft.AspNetCore.Http;
 8
 9namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Graph;
 10
 11[PublicAPI]
 212internal class Graph(IWorkflowDefinitionService workflowDefinitionService, IApiSerializer apiSerializer, ActivityWriter 
 13{
 14    public override void Configure()
 15    {
 116        Get("/workflow-definitions/subgraph/{id}");
 117        ConfigurePermissions("read:workflow-definitions");
 118    }
 19
 20    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 21    {
 122        var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(request.Id, cancellationToken);
 23
 124        if (workflowGraph == null)
 25        {
 026            await Send.NotFoundAsync(cancellationToken);
 027            return;
 28        }
 29
 130        var parentNode = workflowGraph.NodeIdLookup.TryGetValue(request.ParentNodeId, out var node) ? node : workflowGra
 131        var serializerOptions = apiSerializer.GetOptions().Clone();
 132        serializerOptions.Converters.Add(new RootActivityNodeConverter(activityWriter));
 133        await HttpContext.Response.WriteAsJsonAsync(parentNode, serializerOptions, cancellationToken);
 134    }
 35}