< Summary

Information
Class: Elsa.Alterations.Activities.SubmitAlterationPlan
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Activities/SubmitAlterationPlan.cs
Line coverage
5%
Covered lines: 1
Uncovered lines: 17
Coverable lines: 18
Total lines: 52
Line coverage: 5.5%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Params()100%11100%
ExecuteAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Activities/SubmitAlterationPlan.cs

#LineLine coverage
 1using System.ComponentModel;
 2using Elsa.Alterations.Core.Contracts;
 3using Elsa.Alterations.Core.Entities;
 4using Elsa.Alterations.Core.Enums;
 5using Elsa.Alterations.Core.Models;
 6using Elsa.Common;
 7using Elsa.Extensions;
 8using Elsa.Workflows;
 9using Elsa.Workflows.Attributes;
 10using Elsa.Workflows.Models;
 11
 12namespace Elsa.Alterations.Activities;
 13
 14/// <summary>
 15/// Submits an alteration plan for execution.
 16/// </summary>
 17[Browsable(false)]
 18[Output(
 19    DisplayName = "Plan ID",
 20    Description = "The ID of the submitted alteration plan."
 21)]
 22[Activity("Elsa", "Alterations", "Submits an Alteration Plan", Kind = ActivityKind.Task)]
 23public class SubmitAlterationPlan : CodeActivity<string>
 24{
 25    /// <summary>
 26    /// The parameters for the alteration plan to be submitted.
 27    /// </summary>
 6728    public Input<AlterationPlanParams> Params { get; set; } = null!;
 29
 30    /// <inheritdoc />
 31    protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
 32    {
 033        var systemClock = context.GetRequiredService<ISystemClock>();
 034        var identityGenerator = context.GetRequiredService<IIdentityGenerator>();
 035        var now = systemClock.UtcNow;
 036        var planParams = context.Get(Params)!;
 37
 038        var plan = new AlterationPlan
 039        {
 040            Id = string.IsNullOrWhiteSpace(planParams.Id) ? identityGenerator.GenerateId() : planParams.Id,
 041            Alterations = planParams.Alterations,
 042            WorkflowInstanceFilter = planParams.Filter,
 043            Status = AlterationPlanStatus.Pending,
 044            CreatedAt = now
 045        };
 46
 047        var alterationPlanStore = context.GetRequiredService<IAlterationPlanStore>();
 048        var cancellationToken = context.CancellationToken;
 049        await alterationPlanStore.SaveAsync(plan, cancellationToken);
 050        Result.Set(context, plan.Id);
 051    }
 52}

Methods/Properties

get_Params()
ExecuteAsync()