< Summary

Information
Class: Elsa.Alterations.AlterationHandlers.MigrateHandler
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/AlterationHandlers/MigrateHandler.cs
Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 37
Line coverage: 83.3%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HandleAsync()50%2283.33%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/AlterationHandlers/MigrateHandler.cs

#LineLine coverage
 1using Elsa.Alterations.AlterationTypes;
 2using Elsa.Alterations.Core.Abstractions;
 3using Elsa.Alterations.Core.Contexts;
 4using Elsa.Common.Models;
 5using Elsa.Workflows.Management;
 6using JetBrains.Annotations;
 7using Microsoft.Extensions.DependencyInjection;
 8
 9namespace Elsa.Alterations.AlterationHandlers;
 10
 11/// <summary>
 12/// Upgrades the version of the workflow instance.
 13/// </summary>
 14[UsedImplicitly]
 15public class MigrateHandler : AlterationHandlerBase<Migrate>
 16{
 17    /// <inheritdoc />
 18    protected override async ValueTask HandleAsync(AlterationContext context, Migrate alteration)
 19    {
 120        var workflowDefinitionService = context.ServiceProvider.GetRequiredService<IWorkflowDefinitionService>();
 121        var definitionId = context.Workflow.Identity.DefinitionId;
 122        var targetVersion = alteration.TargetVersion;
 123        var cancellationToken = context.CancellationToken;
 124        var targetWorkflowDefinition = await workflowDefinitionService.FindWorkflowDefinitionAsync(definitionId, Version
 25
 126        if (targetWorkflowDefinition == null)
 27        {
 028            context.Fail($"Workflow definition with ID {definitionId} and version {targetVersion} not found");
 029            return;
 30        }
 31
 132        var targetWorkflow = await workflowDefinitionService.MaterializeWorkflowAsync(targetWorkflowDefinition, cancella
 133        await context.WorkflowExecutionContext.SetWorkflowGraphAsync(targetWorkflow);
 34
 135        context.Succeed();
 136    }
 37}

Methods/Properties

HandleAsync()