< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Execute.GetRequest
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/Models.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 74
Line coverage: 100%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_DefinitionId()100%11100%
get_CorrelationId()100%11100%
get_Name()100%11100%
get_TriggerActivityId()100%11100%
get_ActivityHandle()100%11100%
get_VersionOptions()100%11100%
get_Input()100%11100%
get_Variables()100%11100%
GetInputAsDictionary()100%11100%
GetVariablesAsDictionary()100%11100%
ParseStringAsDictionary(...)50%66100%

File(s)

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

#LineLine coverage
 1using System.Dynamic;
 2using System.Text.Json.Serialization;
 3using Elsa.Common.Models;
 4using Elsa.Expressions.Helpers;
 5using Elsa.Workflows.Models;
 6using Elsa.Workflows.Serialization.Converters;
 7using Elsa.Workflows.State;
 8
 9namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Execute;
 10
 11public interface IExecutionRequest
 12{
 13    string DefinitionId { get; }
 14    string? CorrelationId { get; }
 15    string? Name { get; }
 16    string? TriggerActivityId { get; }
 17    ActivityHandle? ActivityHandle { get; }
 18    VersionOptions? VersionOptions { get; }
 19
 20    IDictionary<string, object>? GetInputAsDictionary();
 21    IDictionary<string, object>? GetVariablesAsDictionary();
 22}
 23
 24public class PostRequest : IExecutionRequest
 25{
 26    public string DefinitionId { get; set; } = null!;
 27    public string? CorrelationId { get; set; }
 28    public string? Name { get; set; }
 29    public string? TriggerActivityId { get; set; }
 30    public ActivityHandle? ActivityHandle { get; set; }
 31    public VersionOptions? VersionOptions { get; set; }
 32
 33    [JsonConverter(typeof(ExpandoObjectConverterFactory))]
 34    public object? Input { get; set; }
 35
 36    [JsonConverter(typeof(ExpandoObjectConverterFactory))]
 37    public object? Variables { get; set; }
 38
 39    public IDictionary<string, object>? GetInputAsDictionary() => (IDictionary<string, object>?)Input;
 40    public IDictionary<string, object>? GetVariablesAsDictionary() => (IDictionary<string, object>?)Variables;
 41}
 42
 43public class GetRequest : IExecutionRequest
 44{
 445    public string DefinitionId { get; set; } = null!;
 346    public string? CorrelationId { get; set; }
 247    public string? Name { get; set; }
 248    public string? TriggerActivityId { get; set; }
 249    public ActivityHandle? ActivityHandle { get; set; }
 250    public VersionOptions? VersionOptions { get; set; }
 251    public string? Input { get; set; }
 252    public string? Variables { get; set; }
 53
 254    public IDictionary<string, object>? GetInputAsDictionary() => ParseStringAsDictionary(Input);
 255    public IDictionary<string, object>? GetVariablesAsDictionary() => ParseStringAsDictionary(Variables);
 56
 57    private IDictionary<string, object>? ParseStringAsDictionary(string? value)
 58    {
 459        var result = value?.TryConvertTo<ExpandoObject>(new()
 460        {
 461            SerializerOptions = new()
 462            {
 463                Converters = { new ExpandoObjectConverter() }
 464            }
 465        });
 66
 467        return result?.Success == true ? (IDictionary<string, object>?)result.Value : null;
 68    }
 69}
 70
 71public class Response(WorkflowState workflowState)
 72{
 73    public WorkflowState WorkflowState { get; } = workflowState;
 74}