< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.DeleteTriggers
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/DeleteTriggers.cs
Line coverage
34%
Covered lines: 8
Uncovered lines: 15
Coverable lines: 23
Total lines: 58
Line coverage: 34.7%
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%
HandleAsync()100%11100%
HandleAsync()100%210%
HandleAsync()100%210%
HandleAsync()100%210%
DeleteTriggersAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/DeleteTriggers.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Management.Notifications;
 3using Elsa.Workflows.Runtime.Filters;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Workflows.Runtime.Handlers;
 7
 8/// <summary>
 9/// Deletes bookmarks for workflow definitions being deleted.
 10/// </summary>
 11[UsedImplicitly]
 46712public class DeleteTriggers(ITriggerIndexer triggerIndexer) :
 13    INotificationHandler<WorkflowDefinitionDeleting>,
 14    INotificationHandler<WorkflowDefinitionVersionDeleting>,
 15    INotificationHandler<WorkflowDefinitionsDeleting>,
 16    INotificationHandler<WorkflowDefinitionVersionsDeleting>
 17{
 18    /// <inheritdoc />
 19    public async Task HandleAsync(WorkflowDefinitionDeleting notification, CancellationToken cancellationToken)
 20    {
 421        await DeleteTriggersAsync(new TriggerFilter
 422        {
 423            WorkflowDefinitionId = notification.DefinitionId
 424        }, cancellationToken);
 425    }
 26
 27    /// <inheritdoc />
 28    public async Task HandleAsync(WorkflowDefinitionVersionDeleting notification, CancellationToken cancellationToken)
 29    {
 030        await DeleteTriggersAsync(new TriggerFilter
 031        {
 032            WorkflowDefinitionVersionId = notification.WorkflowDefinition.Id
 033        }, cancellationToken);
 034    }
 35
 36    /// <inheritdoc />
 37    public async Task HandleAsync(WorkflowDefinitionsDeleting notification, CancellationToken cancellationToken)
 38    {
 039        await DeleteTriggersAsync(new TriggerFilter
 040        {
 041            WorkflowDefinitionIds = notification.DefinitionIds
 042        }, cancellationToken);
 043    }
 44
 45    /// <inheritdoc />
 46    public async Task HandleAsync(WorkflowDefinitionVersionsDeleting notification, CancellationToken cancellationToken)
 47    {
 048        await DeleteTriggersAsync(new TriggerFilter
 049        {
 050            WorkflowDefinitionVersionIds = notification.Ids
 051        }, cancellationToken);
 052    }
 53
 54    private async Task DeleteTriggersAsync(TriggerFilter filter, CancellationToken cancellationToken)
 55    {
 456        await triggerIndexer.DeleteTriggersAsync(filter, cancellationToken);
 457    }
 58}