< Summary

Information
Class: Elsa.Alterations.Services.AlterationPlanManager
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Services/AlterationPlanManager.cs
Line coverage
6%
Covered lines: 1
Uncovered lines: 15
Coverable lines: 16
Total lines: 43
Line coverage: 6.2%
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
.ctor(...)100%11100%
GetPlanAsync()100%210%
GetIsAllJobsCompletedAsync()100%210%
CompletePlanAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Services/AlterationPlanManager.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Entities;
 3using Elsa.Alterations.Core.Enums;
 4using Elsa.Alterations.Core.Filters;
 5using Elsa.Alterations.Core.Notifications;
 6using Elsa.Common;
 7using Elsa.Mediator.Contracts;
 8
 9namespace Elsa.Alterations.Services;
 10
 11/// <inheritdoc />
 32012public class AlterationPlanManager(IAlterationPlanStore planStore, IAlterationJobStore jobStore, ISystemClock systemCloc
 13{
 14    /// <inheritdoc />
 15    public async Task<AlterationPlan?> GetPlanAsync(string planId, CancellationToken cancellationToken = default)
 16    {
 017        var planFilter = new AlterationPlanFilter { Id = planId };
 018        return await planStore.FindAsync(planFilter, cancellationToken);
 019    }
 20
 21    /// <inheritdoc />
 22    public async Task<bool> GetIsAllJobsCompletedAsync(string planId, CancellationToken cancellationToken = default)
 23    {
 24        // Check if all jobs are completed.
 025        var jobFilter = new AlterationJobFilter
 026        {
 027            PlanId = planId,
 028            Statuses = [AlterationJobStatus.Pending, AlterationJobStatus.Running]
 029        };
 30
 031        return await jobStore.CountAsync(jobFilter, cancellationToken) == 0;
 032    }
 33
 34    /// <inheritdoc />
 35    public async Task CompletePlanAsync(AlterationPlan plan, CancellationToken cancellationToken = default)
 36    {
 037        plan.Status = AlterationPlanStatus.Completed;
 038        plan.CompletedAt = systemClock.UtcNow;
 39
 040        await planStore.SaveAsync(plan, cancellationToken);
 041        await notificationSender.SendAsync(new AlterationPlanCompleted(plan), cancellationToken);
 042    }
 43}