< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Execute.PostRequest
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: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 74
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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%

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{
 2026    public string DefinitionId { get; set; } = null!;
 1227    public string? CorrelationId { get; set; }
 1128    public string? Name { get; set; }
 1129    public string? TriggerActivityId { get; set; }
 1130    public ActivityHandle? ActivityHandle { get; set; }
 1131    public VersionOptions? VersionOptions { get; set; }
 32
 33    [JsonConverter(typeof(ExpandoObjectConverterFactory))]
 1134    public object? Input { get; set; }
 35
 36    [JsonConverter(typeof(ExpandoObjectConverterFactory))]
 1137    public object? Variables { get; set; }
 38
 939    public IDictionary<string, object>? GetInputAsDictionary() => (IDictionary<string, object>?)Input;
 940    public IDictionary<string, object>? GetVariablesAsDictionary() => (IDictionary<string, object>?)Variables;
 41}
 42
 43public class GetRequest : IExecutionRequest
 44{
 45    public string DefinitionId { get; set; } = null!;
 46    public string? CorrelationId { get; set; }
 47    public string? Name { get; set; }
 48    public string? TriggerActivityId { get; set; }
 49    public ActivityHandle? ActivityHandle { get; set; }
 50    public VersionOptions? VersionOptions { get; set; }
 51    public string? Input { get; set; }
 52    public string? Variables { get; set; }
 53
 54    public IDictionary<string, object>? GetInputAsDictionary() => ParseStringAsDictionary(Input);
 55    public IDictionary<string, object>? GetVariablesAsDictionary() => ParseStringAsDictionary(Variables);
 56
 57    private IDictionary<string, object>? ParseStringAsDictionary(string? value)
 58    {
 59        var result = value?.TryConvertTo<ExpandoObject>(new()
 60        {
 61            SerializerOptions = new()
 62            {
 63                Converters = { new ExpandoObjectConverter() }
 64            }
 65        });
 66
 67        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}