< Summary

Information
Class: Elsa.Http.Services.HttpWorkflowLookupService
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/HttpWorkflowLookupService.cs
Line coverage
92%
Covered lines: 23
Uncovered lines: 2
Coverable lines: 25
Total lines: 53
Line coverage: 92%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
FindWorkflowAsync()66.66%6681.81%
FindTriggersAsync()100%11100%
FindWorkflowGraphAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/HttpWorkflowLookupService.cs

#LineLine coverage
 1using Elsa.Workflows.Management;
 2using Elsa.Workflows.Management.Filters;
 3using Elsa.Workflows.Models;
 4using Elsa.Workflows.Runtime;
 5using Elsa.Workflows.Runtime.Entities;
 6using Elsa.Workflows.Runtime.Filters;
 7using Open.Linq.AsyncExtensions;
 8
 9namespace Elsa.Http.Services;
 10
 11/// <inheritdoc />
 21512public class HttpWorkflowLookupService(ITriggerStore triggerStore, IWorkflowDefinitionService workflowDefinitionService)
 13{
 14    /// <inheritdoc />
 15    public async Task<HttpWorkflowLookupResult?> FindWorkflowAsync(string bookmarkHash, CancellationToken cancellationTo
 16    {
 20917        var triggers = await FindTriggersAsync(bookmarkHash, cancellationToken).ToList();
 18
 20919        if (triggers.Count > 1)
 020            return new(null, triggers);
 21
 20922        var trigger = triggers.SingleOrDefault();
 23
 20924        if (trigger == null)
 225            return default;
 26
 20727        var workflowGraph = await FindWorkflowGraphAsync(trigger, cancellationToken);
 28
 20729        if (workflowGraph == null)
 030            return default;
 31
 20732        return new(workflowGraph, triggers);
 20933    }
 34
 35    private async Task<IEnumerable<StoredTrigger>> FindTriggersAsync(string bookmarkHash, CancellationToken cancellation
 36    {
 20937        var triggerFilter = new TriggerFilter
 20938        {
 20939            Hash = bookmarkHash
 20940        };
 20941        return await triggerStore.FindManyAsync(triggerFilter, cancellationToken);
 20942    }
 43
 44    private async Task<WorkflowGraph?> FindWorkflowGraphAsync(StoredTrigger trigger, CancellationToken cancellationToken
 45    {
 20746        var workflowDefinitionVersionId = trigger.WorkflowDefinitionVersionId;
 20747        var filter = new WorkflowDefinitionFilter
 20748        {
 20749            Id = workflowDefinitionVersionId
 20750        };
 20751        return await workflowDefinitionService.FindWorkflowGraphAsync(filter, cancellationToken);
 20752    }
 53}