< Summary

Information
Class: Elsa.Http.Extensions.HttpEndpointActivityExecutionContextExtensions
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Extensions/HttpEndpointActivityExecutionContextExtensions.cs
Line coverage
51%
Covered lines: 25
Uncovered lines: 24
Coverable lines: 49
Total lines: 95
Line coverage: 51%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
WaitForHttpRequestAsync()100%210%
WaitForHttpRequestAsync()100%11100%
WaitForHttpRequestAsync()83.33%6690%
GetHttpEndpointStimuli(...)100%210%
GetHttpEndpointStimuli(...)100%210%
GetHttpEndpointStimuli(...)100%210%
GetHttpEndpointStimuli(...)100%11100%
CreateCrossBoundaryBookmark(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Extensions/HttpEndpointActivityExecutionContextExtensions.cs

#LineLine coverage
 1using Elsa.Expressions.Models;
 2using Elsa.Extensions;
 3using Elsa.Http.Bookmarks;
 4using Elsa.Workflows;
 5using Elsa.Workflows.Models;
 6using Microsoft.AspNetCore.Routing.Patterns;
 7
 8namespace Elsa.Http.Extensions;
 9
 10public static class HttpEndpointActivityExecutionContextExtensions
 11{
 12public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, string method,
 13{
 014    var options = new HttpEndpointOptions
 015    {
 016        Path = path,
 017        Methods = [method]
 018    };
 019    await WaitForHttpRequestAsync(context, options, callback);
 020}
 21
 22public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, string path, IEnumerable<st
 23{
 21824    var options = new HttpEndpointOptions
 21825    {
 21826        Path = path,
 21827        Methods = methods.ToList()
 21828    };
 21829    await WaitForHttpRequestAsync(context, options, callback);
 21830}
 31
 32    public static async ValueTask WaitForHttpRequestAsync(this ActivityExecutionContext context, HttpEndpointOptions opt
 33    {
 21834        var path = options.Path;
 21835        if (path.Contains("//"))
 036            throw new RoutePatternException(path, "Path cannot contain double slashes (//)");
 37
 21838        var expressionExecutionContext = context.ExpressionExecutionContext;
 21839        if (!context.IsTriggerOfWorkflow())
 40        {
 641            context.CreateBookmarks(expressionExecutionContext.GetHttpEndpointStimuli(options), includeActivityInstanceI
 642            return;
 43        }
 44
 21245        if (callback is not null)
 21246            await callback(context);
 21847    }
 48
 49    public static IEnumerable<object> GetHttpEndpointStimuli(this TriggerIndexingContext context, string path, string me
 50    {
 051        return context.GetHttpEndpointStimuli(path, [method]);
 52    }
 53
 54    public static IEnumerable<object> GetHttpEndpointStimuli(this TriggerIndexingContext context, string path, IEnumerab
 55    {
 056        var options = new HttpEndpointOptions
 057        {
 058            Path = path,
 059            Methods = methods.ToList()
 060        };
 61
 062        return context.GetHttpEndpointStimuli(options);
 63    }
 64
 65    public static IEnumerable<object> GetHttpEndpointStimuli(this TriggerIndexingContext context, HttpEndpointOptions op
 66    {
 067        return context.ExpressionExecutionContext.GetHttpEndpointStimuli(options);
 68    }
 69
 70    public static IEnumerable<object> GetHttpEndpointStimuli(this ExpressionExecutionContext context, HttpEndpointOption
 71    {
 72        // Generate bookmark data for path and selected methods.
 673        var normalizedRoute = options.Path.NormalizeRoute();
 674        var authorize = options.Authorize;
 675        var policy = options.Policy;
 676        var requestTimeout = options.RequestTimeout;
 677        var requestSizeLimit = options.RequestSizeLimit;
 78
 679        return options.Methods
 680            .Select(x => new HttpEndpointBookmarkPayload(normalizedRoute, x.ToLowerInvariant(), authorize, policy, reque
 681            .Cast<object>()
 682            .ToArray();
 83    }
 84
 85    internal static void CreateCrossBoundaryBookmark(this ActivityExecutionContext context, ExecuteActivityDelegate? cal
 86    {
 087        var bookmarkOptions = new CreateBookmarkArgs
 088        {
 089            BookmarkName = HttpStimulusNames.HttpEndpoint,
 090            Callback = callback,
 091            Metadata = BookmarkMetadata.HttpCrossBoundary,
 092        };
 093        context.CreateBookmark(bookmarkOptions);
 094    }
 95}