diff --git a/src/TaskManager/Plug-ins/TestPlugin/TestPlugin.cs b/src/TaskManager/Plug-ins/TestPlugin/TestPlugin.cs index 045f1f5d7..4e9f0c8ae 100644 --- a/src/TaskManager/Plug-ins/TestPlugin/TestPlugin.cs +++ b/src/TaskManager/Plug-ins/TestPlugin/TestPlugin.cs @@ -17,25 +17,21 @@ using Ardalis.GuardClauses; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Monai.Deploy.Messaging.API; using Monai.Deploy.Messaging.Events; using Monai.Deploy.WorkflowManager.TaskManager.API; namespace Monai.Deploy.WorkflowManager.TaskManager.TestPlugin { - public class TestPlugin : TaskPluginBase, IAsyncDisposable + public class TestPlugin : TaskPluginBase { - private const string TaskManagerApplicationId = "4c9072a1-35f5-4d85-847d-dafca22244a8"; private readonly IServiceScope _scope; private readonly ILogger _logger; - private readonly IMessageBrokerPublisherService? _messageBrokerPublisherService; private string _executeTaskStatus = String.Empty; private string _getStatusStatus = String.Empty; public TestPlugin( IServiceScopeFactory serviceScopeFactory, - IMessageBrokerPublisherService messageBrokerPublisherService, ILogger logger, TaskDispatchEvent taskDispatchEvent) : base(taskDispatchEvent) @@ -45,7 +41,6 @@ public TestPlugin( _scope = serviceScopeFactory.CreateScope(); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _messageBrokerPublisherService = messageBrokerPublisherService ?? throw new ArgumentNullException(nameof(messageBrokerPublisherService)); _executeTaskStatus = string.Empty; _getStatusStatus = string.Empty; ValidateEventAndInit(); @@ -128,11 +123,5 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - - public async ValueTask DisposeAsync() - { - Dispose(disposing: false); - GC.SuppressFinalize(this); - } } } diff --git a/src/WorkflowManager/Database/Interfaces/IPayloadRepsitory.cs b/src/WorkflowManager/Database/Interfaces/IPayloadRepsitory.cs index bb991874a..1ce1b59d3 100644 --- a/src/WorkflowManager/Database/Interfaces/IPayloadRepsitory.cs +++ b/src/WorkflowManager/Database/Interfaces/IPayloadRepsitory.cs @@ -31,7 +31,7 @@ public interface IPayloadRepsitory /// /// Retrieves a list of payloads in the database. /// - Task> GetAllAsync(int? skip = null, int? limit = null, string? patientId = "", string? patientName = ""); + Task> GetAllAsync(int? skip = null, int? limit = null, string patientId = "", string patientName = ""); /// /// Retrieves a payload by id in the database. diff --git a/src/WorkflowManager/WorkflowExecuter/Common/EventMapper.cs b/src/WorkflowManager/WorkflowExecuter/Common/EventMapper.cs index 89c8dfdab..18cd31ce3 100644 --- a/src/WorkflowManager/WorkflowExecuter/Common/EventMapper.cs +++ b/src/WorkflowManager/WorkflowExecuter/Common/EventMapper.cs @@ -83,7 +83,7 @@ public static TaskDispatchEvent ToTaskDispatchEvent(TaskExecution task, Workflow IntermediateStorage = new Messaging.Common.Storage { Bucket = workflowInstance.BucketId, - RelativeRootPath = $"{task.OutputDirectory}/tmp", + RelativeRootPath = task.OutputDirectory, Endpoint = configuration.Settings["endpoint"], Name = task.TaskId, SecuredConnection = bool.Parse(configuration.Settings["securedConnection"]) diff --git a/src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs b/src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs index 36106a146..3f6e816e7 100644 --- a/src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs +++ b/src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs @@ -319,8 +319,6 @@ private async Task UpdateWorkflowInstanceStatus(WorkflowInstance workflowI private async Task HandleDicomExportAsync(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string correlationId) { - var exportDestinations = workflow.Workflow?.Tasks?.FirstOrDefault(t => t.Id == task.TaskId)?.ExportDestinations; - var exportList = workflow.Workflow?.Tasks?.FirstOrDefault(t => t.Id == task.TaskId)?.ExportDestinations.Select(e => e.Name).ToArray(); var artifactValues = GetDicomExports(workflow, workflowInstance, task, exportList); @@ -335,15 +333,17 @@ private async Task HandleDicomExportAsync(WorkflowRevision workflow, WorkflowIns await DispatchDicomExport(workflowInstance, task, exportList, artifactValues, correlationId); } - private string[] GetDicomExports(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string[] exportDestinations) + private string[] GetDicomExports(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string[]? exportDestinations) { var validExportDestinations = workflow.Workflow?.InformaticsGateway?.ExportDestinations; +#pragma warning disable CS8604 // Possible null reference argument. if (exportDestinations.IsNullOrEmpty() || validExportDestinations.IsNullOrEmpty()) { return Array.Empty(); } +#pragma warning restore CS8604 // Possible null reference argument. foreach (var exportDestination in exportDestinations) { diff --git a/tests/IntegrationTests/TaskManager.IntegrationTests/Support/MinioClientUtil.cs b/tests/IntegrationTests/TaskManager.IntegrationTests/Support/MinioClientUtil.cs index 31ffb76d5..72ed7f5de 100644 --- a/tests/IntegrationTests/TaskManager.IntegrationTests/Support/MinioClientUtil.cs +++ b/tests/IntegrationTests/TaskManager.IntegrationTests/Support/MinioClientUtil.cs @@ -49,7 +49,6 @@ await RetryPolicy.ExecuteAsync(async () => try { var listOfKeys = new List(); - var count = 0; var listArgs = new ListObjectsArgs() .WithBucket(bucketName) .WithPrefix("") @@ -61,7 +60,7 @@ await RetryPolicy.ExecuteAsync(async () => await Client.RemoveObjectAsync(bucketName, obj.Key); } } - catch (Exception e) + catch (Exception) { } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs index c01791fc9..4c6df5b8b 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs @@ -67,7 +67,7 @@ public void ThenWorkflowInstanceStatusIs(string status) } else if (DataHelper.WorkflowRequestMessage.PayloadId != null) { - _outputHelper.WriteLine($"Retrieving workflow instance by PayloadId={DataHelper.WorkflowRequestMessage.PayloadId.ToString()}"); + _outputHelper.WriteLine($"Retrieving workflow instance by PayloadId={DataHelper.WorkflowRequestMessage.PayloadId}"); workflowInstance = MongoClient.GetWorkflowInstance(DataHelper.WorkflowRequestMessage.PayloadId.ToString()); } else diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs index 061afa657..1b367b2cd 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs @@ -84,7 +84,7 @@ public void ThenTheDeletedWorkflowIsNotReturned() var result = ApiHelper.Response.Content.ReadAsStringAsync().Result; var workflowRevisions = JsonConvert.DeserializeObject>>(result); - workflowRevisions.Data.Should().BeNullOrEmpty(); + workflowRevisions?.Data.Should().BeNullOrEmpty(); } } } diff --git a/tests/UnitTests/WorkflowExecuter.Tests/Common/EventMapperTests.cs b/tests/UnitTests/WorkflowExecuter.Tests/Common/EventMapperTests.cs index cba78a7be..aac91078c 100644 --- a/tests/UnitTests/WorkflowExecuter.Tests/Common/EventMapperTests.cs +++ b/tests/UnitTests/WorkflowExecuter.Tests/Common/EventMapperTests.cs @@ -112,7 +112,7 @@ public void ToTaskDispatchEvent_ValidAeTitleWorkflowRequest_ReturnsTaskDispatch( Bucket = workflowInstance.BucketId, Endpoint = configuration.Settings["endpoint"], Name = task.TaskId, - RelativeRootPath = "minio/workflowid/taskid/tmp", + RelativeRootPath = "minio/workflowid/taskid", SecuredConnection = bool.Parse(configuration.Settings["securedConnection"]) } }; diff --git a/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs b/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs index 55f348d73..a0c4d73cf 100644 --- a/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs +++ b/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs @@ -447,7 +447,7 @@ public async Task DeleteAsync_WorkflowsDoesntExist_SoftDeltesWorkflow() var result = await WorkflowsController.DeleteAsync(wrongGuid); var objectResult = Assert.IsType(result); - Assert.Equal(result.As().Value.As().Detail, "Failed to validate id, workflow not found"); + Assert.Equal("Failed to validate id, workflow not found", result.As().Value.As().Detail); Assert.Equal(404, objectResult.StatusCode); } @@ -463,7 +463,7 @@ public async Task DeleteAsync_WorkflowsServiceThrowsException_Should500Error() var result = await WorkflowsController.DeleteAsync(workflowRevisionId); var objectResult = Assert.IsType(result); - Assert.Equal(result.As().Value.As().Detail, "Unexpected error occured: Error in the application."); + Assert.Equal("Unexpected error occured: Error in the application.", result.As().Value.As().Detail); Assert.Equal(500, objectResult.StatusCode); } @@ -476,7 +476,7 @@ public async Task DeleteAsync_WorkflowsGivenInvalidId_ShouldBadRequest() var result = await WorkflowsController.DeleteAsync(invalidId); var objectResult = Assert.IsType(result); - Assert.Equal(result.As().Value.As().Detail, "Failed to validate id, not a valid guid"); + Assert.Equal("Failed to validate id, not a valid guid", result.As().Value.As().Detail); Assert.Equal(400, objectResult.StatusCode); }