Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for task update updating to same status #981

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/WorkflowManager/Logging/Log.200000.Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public static partial class Log
[LoggerMessage(EventId = 200020, Level = LogLevel.Warning, Message = "Use new ArtifactReceived Queue for continuation messages.")]
public static partial void DontUseWorkflowReceivedForPayload(this ILogger logger);

[LoggerMessage(EventId = 200021, Level = LogLevel.Trace, Message = "The task execution status for task {taskId} is already {status}. Payload: {payloadId}")]
public static partial void TaskStatusUpdateNotNeeded(this ILogger logger, string payloadId, string taskId, string status);

// Conditions Resolver
[LoggerMessage(EventId = 210000, Level = LogLevel.Warning, Message = "Failed to parse condition: {condition}. resolvedConditional: {resolvedConditional}")]
public static partial void FailedToParseCondition(this ILogger logger, string resolvedConditional, string condition, Exception ex);
Expand Down
7 changes: 5 additions & 2 deletions src/WorkflowManager/Logging/Log.700000.Artifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@
[LoggerMessage(EventId = 700012, Level = LogLevel.Error, Message = "Error finding Task :{taskId}")]
public static partial void ErrorFindingTask(this ILogger logger, string taskId);

[LoggerMessage(EventId = 700013, Level = LogLevel.Error, Message = "Error finding Task :{taskId} or previousTask {previousTask}")]
public static partial void ErrorFindingTaskOrPrevious(this ILogger logger, string taskId, string previousTask);
//[LoggerMessage(EventId = 700013, Level = LogLevel.Error, Message = "Error finding Task :{taskId} or previousTask {previousTask}")]
//public static partial void ErrorFindingTaskOrPrevious(this ILogger logger, string taskId, string previousTask);

Check warning on line 64 in src/WorkflowManager/Logging/Log.700000.Artifact.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)

[LoggerMessage(EventId = 700014, Level = LogLevel.Warning, Message = "Error Task :{taskId} cant be trigger as it has missing artifacts {missingtypesJson}")]
public static partial void ErrorTaskMissingArtifacts(this ILogger logger, string taskId, string missingtypesJson);

[LoggerMessage(EventId = 700015, Level = LogLevel.Warning, Message = "Error Task :{taskId} cant be trigger as it has missing artifacts {artifactName}")]
public static partial void ErrorFindingArtifactInPrevious(this ILogger logger, string taskId, string artifactName);


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@

public async Task<bool> ProcessPayload(WorkflowRequestEvent message, Payload payload)
{
ArgumentNullException.ThrowIfNull(message, nameof(message));

Check warning on line 115 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)

using var loggerScope = _logger.BeginScope($"correlationId={message.CorrelationId}, payloadId={payload.PayloadId}");

// for external App executions use the ArtifactReceived queue.
if (string.IsNullOrWhiteSpace(message.WorkflowInstanceId) is false && string.IsNullOrEmpty(message.TaskId) is false)

Check warning on line 120 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)

Check warning on line 120 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
_logger.DontUseWorkflowReceivedForPayload();
return false;
Expand All @@ -136,7 +136,7 @@
workflows = new List<WorkflowRevision>(result);
}

if (workflows is null || workflows.Any() is false)

Check warning on line 139 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
_logger.NoMatchingWorkflowFoundForPayload();
return false;
Expand All @@ -153,7 +153,7 @@
return false;
}

workflowInstances.AddRange(newInstances);

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / task-manager-integration-tests

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / task-manager-integration-tests

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / scan

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / scan

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / analyze

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / analyze

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

Check warning on line 156 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Argument of type 'WorkflowInstance?[]' cannot be used for parameter 'collection' of type 'IEnumerable<WorkflowInstance>' in 'void List<WorkflowInstance>.AddRange(IEnumerable<WorkflowInstance> collection)' due to differences in the nullability of reference types.

var existingInstances = await _workflowInstanceRepository.GetByWorkflowsIdsAsync(workflowInstances.Select(w => w.WorkflowId).ToList());

Expand Down Expand Up @@ -186,7 +186,7 @@

public async Task<bool> ProcessArtifactReceivedAsync(ArtifactsReceivedEvent message)
{
ArgumentNullException.ThrowIfNull(message, nameof(message));

Check warning on line 189 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove this argument from the method call; it hides the caller information. (https://rules.sonarsource.com/csharp/RSPEC-3236)

var workflowInstanceId = message.WorkflowInstanceId;
var taskId = message.TaskId;
Expand Down Expand Up @@ -263,7 +263,7 @@
{
var artifactList = message.Artifacts.Select(a => a.Path).ToList();
var artifactsInStorage = (await _storageService.VerifyObjectsExistAsync(workflowInstance.BucketId, artifactList, default)) ?? new Dictionary<string, bool>();
if (artifactsInStorage.Any(a => a.Value) is false)

Check warning on line 266 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Remove the unnecessary Boolean literal(s). (https://rules.sonarsource.com/csharp/RSPEC-1125)
{
_logger.NoFilesExistInStorage(JsonSerializer.Serialize(artifactList));
return;
Expand Down Expand Up @@ -376,7 +376,7 @@
var matchType = previousTask.Artifacts.Output.FirstOrDefault(t => t.Name == artifact.Name);
if (matchType is null)
{
_logger.ErrorFindingTaskOrPrevious(taskId, previousTaskId);
_logger.ErrorFindingArtifactInPrevious(taskId, artifact.Name);
}
else
{
Expand Down Expand Up @@ -408,7 +408,7 @@
{
["workflowInstanceId"] = workflowInstance.Id,
["durationSoFar"] = (DateTime.UtcNow - workflowInstance.StartTime).TotalMilliseconds,
["executionId"] = task.ExecutionId

Check warning on line 411 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Define a constant instead of using this literal 'executionId' 5 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
});

await SwitchTasksAsync(task,
Expand Down Expand Up @@ -481,6 +481,12 @@
await ClinicalReviewTimeOutEvent(workflowInstance, currentTask, message.CorrelationId);
}

if (message.Status == currentTask.Status)
{
_logger.TaskStatusUpdateNotNeeded(workflowInstance.PayloadId, message.TaskId, message.Status.ToString());
return true;
}

if (!message.Status.IsTaskExecutionStatusUpdateValid(currentTask.Status))
{
_logger.TaskStatusUpdateNotValid(workflowInstance.PayloadId, message.TaskId, currentTask.Status.ToString(), message.Status.ToString());
Expand Down Expand Up @@ -1163,7 +1169,7 @@
{
Id = workflowInstanceId,
WorkflowId = workflow.WorkflowId,
WorkflowName = workflow.Workflow.Name,

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / task-manager-integration-tests

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / task-manager-integration-tests

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / scan

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / scan

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / analyze

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / analyze

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Dereference of a possibly null reference.

Check warning on line 1172 in src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

View workflow job for this annotation

GitHub Actions / docs

Dereference of a possibly null reference.
PayloadId = message.PayloadId.ToString(),
StartTime = DateTime.UtcNow,
Status = Status.Created,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3702,6 +3702,88 @@ public async Task ProcessTaskUpdate_ValidTaskUpdateEventWithExportHl7TaskDestina
response.Should().BeTrue();
}

[Fact]
public async Task ProcessTaskUpdate_ValidTaskUpdateEventWith_Same_Status_returns_true()
{
var workflowInstanceId = Guid.NewGuid().ToString();
var taskId = Guid.NewGuid().ToString();

var updateEvent = new TaskUpdateEvent
{
WorkflowInstanceId = workflowInstanceId,
TaskId = "pizza",
ExecutionId = Guid.NewGuid().ToString(),
Status = TaskExecutionStatus.Succeeded,
};

var workflowId = Guid.NewGuid().ToString();

var workflow = new WorkflowRevision
{
Id = Guid.NewGuid().ToString(),
WorkflowId = workflowId,
Revision = 1,
Workflow = new Workflow
{
Name = "Workflowname2",
Description = "Workflowdesc2",
Version = "1",
InformaticsGateway = new InformaticsGateway
{
AeTitle = "aetitle"
},
Tasks = new TaskObject[]
{
new TaskObject {
Id = "pizza",
Type = "type",
Description = "taskdesc",
TaskDestinations = new TaskDestination[]
{
new TaskDestination
{
Name = "exporttaskid"
},
}
}
}
}
};

var workflowInstance = new WorkflowInstance
{
Id = workflowInstanceId,
WorkflowId = workflowId,
WorkflowName = workflow.Workflow.Name,
PayloadId = Guid.NewGuid().ToString(),
Status = Status.Created,
BucketId = "bucket",
Tasks = new List<TaskExecution>
{
new TaskExecution
{
TaskId = "pizza",
Status = TaskExecutionStatus.Succeeded
}
}
};

_workflowInstanceRepository.Setup(w => w.UpdateTaskStatusAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<TaskExecutionStatus>())).ReturnsAsync(true);
_workflowInstanceRepository.Setup(w => w.GetByWorkflowInstanceIdAsync(workflowInstance.Id)).ReturnsAsync(workflowInstance);
_workflowInstanceRepository.Setup(w => w.UpdateTasksAsync(workflowInstance.Id, It.IsAny<List<TaskExecution>>())).ReturnsAsync(true);
_workflowRepository.Setup(w => w.GetByWorkflowIdAsync(workflowInstance.WorkflowId)).ReturnsAsync(workflow);
_payloadService.Setup(p => p.GetByIdAsync(It.IsAny<string>())).ReturnsAsync(new Payload { PatientDetails = new PatientDetails { } });
_artifactMapper.Setup(a => a.ConvertArtifactVariablesToPath(It.IsAny<Artifact[]>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>())).ReturnsAsync(new Dictionary<string, string> { { "dicomexport", "/dcm" } });

var response = await WorkflowExecuterService.ProcessTaskUpdate(updateEvent);

_messageBrokerPublisherService.Verify(w => w.Publish(_configuration.Value.Messaging.Topics.ExportHL7, It.IsAny<Message>()), Times.Exactly(0));

_logger.Verify(logger => logger.IsEnabled(LogLevel.Trace),Times.Once);

response.Should().BeTrue();
}

[Fact]
public async Task ProcessPayload_With_Multiple_Taskdestinations_One_Has_Inputs()
{
Expand Down Expand Up @@ -3977,6 +4059,62 @@ public async Task ProcessPayload_With_Passing_Workflow_Conditional_Should_Procce

Assert.True(result);
}

[Fact]
public async Task ProcessPayload_With_Empty_Workflow_Conditional_Should_Procced()
{
var workflowRequest = new WorkflowRequestEvent
{
Bucket = "testbucket",
DataTrigger = new DataOrigin { Source = "aetitle", Destination = "aetitle" },
CorrelationId = Guid.NewGuid().ToString(),
Timestamp = DateTime.UtcNow
};

var workflows = new List<WorkflowRevision>
{
new() {
Id = Guid.NewGuid().ToString(),
WorkflowId = Guid.NewGuid().ToString(),
Revision = 1,
Workflow = new Workflow
{
Name = "Workflowname",
Description = "Workflowdesc",
Version = "1",
InformaticsGateway = new InformaticsGateway
{
AeTitle = "aetitle"
},
Tasks =
[
new TaskObject {
Id = Guid.NewGuid().ToString(),
Type = "type",
Description = "taskdesc"
}
],
Predicate = []
}
}
};

_dicom.Setup(w => w.GetAnyValueAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync(() => "lordge");

_workflowRepository.Setup(w => w.GetWorkflowsByAeTitleAsync(It.IsAny<List<string>>())).ReturnsAsync(workflows);
_workflowRepository.Setup(w => w.GetWorkflowsForWorkflowRequestAsync(It.IsAny<string>(), It.IsAny<string>())).ReturnsAsync(workflows);
_workflowRepository.Setup(w => w.GetByWorkflowIdAsync(workflows[0].WorkflowId)).ReturnsAsync(workflows[0]);
_workflowInstanceRepository.Setup(w => w.CreateAsync(It.IsAny<List<WorkflowInstance>>())).ReturnsAsync(true);
_workflowInstanceRepository.Setup(w => w.GetByWorkflowsIdsAsync(It.IsAny<List<string>>())).ReturnsAsync(new List<WorkflowInstance>());
_workflowInstanceRepository.Setup(w => w.UpdateTaskStatusAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<TaskExecutionStatus>())).ReturnsAsync(true);

var result = await WorkflowExecuterService.ProcessPayload(workflowRequest, new Payload() { Id = Guid.NewGuid().ToString() });

_messageBrokerPublisherService.Verify(w => w.Publish(_configuration.Value.Messaging.Topics.TaskDispatchRequest, It.IsAny<Message>()), Times.Once());

Assert.True(result);
}
}
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}
Loading