< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.Tasks.Complete.Complete
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Tasks/Complete/Endpoint.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 33
Line coverage: 66.6%
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%
Configure()100%11100%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Tasks/Complete/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Workflows.Runtime;
 3using Elsa.Workflows.Runtime.Activities;
 4
 5namespace Elsa.Workflows.Api.Endpoints.Tasks.Complete;
 6
 7/// <summary>
 8/// Resumes the <see cref="RunTask"/> activity matching the received Task ID.
 9/// </summary>
 10public class Complete : ElsaEndpoint<Request, Response>
 11{
 12    private readonly ITaskReporter _taskReporter;
 13
 14    /// <inheritdoc />
 115    public Complete(ITaskReporter taskReporter)
 16    {
 117        _taskReporter = taskReporter;
 118    }
 19
 20    /// <inheritdoc />
 21    public override void Configure()
 22    {
 123        Post("/tasks/{taskId}/complete");
 124        ConfigurePermissions("tasks:complete");
 125    }
 26
 27    /// <inheritdoc />
 28    public override async Task HandleAsync(Request request, CancellationToken cancellationToken)
 29    {
 030        await _taskReporter.ReportCompletionAsync(request.TaskId, request.Result, cancellationToken);
 031        if (!HttpContext.Response.HasStarted) await Send.OkAsync(cancellationToken);
 032    }
 33}