< Summary

Information
Class: Elsa.Alterations.Handlers.AlterationJobCompletedHandler
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Handlers/AlterationJobCompletedHandler.cs
Line coverage
11%
Covered lines: 1
Uncovered lines: 8
Coverable lines: 9
Total lines: 27
Line coverage: 11.1%
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
.ctor(...)100%11100%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Handlers/AlterationJobCompletedHandler.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Notifications;
 3using Elsa.Mediator.Contracts;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Alterations.Handlers;
 7
 8/// <summary>
 9/// Handles <see cref="AlterationJobCompleted"/> notifications and updates the plan status if all jobs are completed.
 10/// </summary>
 11[UsedImplicitly]
 32012public class AlterationJobCompletedHandler(IAlterationPlanManager manager) : INotificationHandler<AlterationJobCompleted
 13{
 14    /// <inheritdoc />
 15    public async Task HandleAsync(AlterationJobCompleted notification, CancellationToken cancellationToken)
 16    {
 017        var job = notification.Job;
 018        var planId = job.PlanId;
 019        var plan = (await manager.GetPlanAsync(planId, cancellationToken))!;
 020        var allJobsCompleted = await manager.GetIsAllJobsCompletedAsync(planId, cancellationToken);
 21
 022        if(!allJobsCompleted)
 023            return;
 24
 025        await manager.CompletePlanAsync(plan, cancellationToken);
 026    }
 27}