diff --git a/CustomAnalysisRules.ruleset b/CustomAnalysisRules.ruleset index b51b4865c3..c41f91fb0b 100644 --- a/CustomAnalysisRules.ruleset +++ b/CustomAnalysisRules.ruleset @@ -24,6 +24,13 @@ + + + + + + + diff --git a/Directory.Build.props b/Directory.Build.props index ccda88097c..b20c04f4a5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,13 +13,13 @@ true latest true - $(NoWarn);NU5104;CS1574;IDE0005 + $(NoWarn);NU5104;NU1510;CS1574;IDE0005;ASPDEPR008;ASPDEPR006;ASPDEPR003;ASPDEPR005;CA2024 MIT Microsoft FHIR Server for Azure true https://github.com/microsoft/fhir-server $(MSBuildThisFileDirectory)\CodeCoverage.runsettings - net9.0;net8.0 + net10.0;net8.0 true true diff --git a/Directory.Packages.props b/Directory.Packages.props index 9ee3ddb290..a9ef14fd17 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,10 +1,10 @@ - 10.0.68 + 11.0.3 5.11.4 5.11.0 - 9.0.6 + 10.0.0 6.2.0 @@ -19,9 +19,15 @@ 9.0.3 + + + 10.0.0 + + + @@ -34,7 +40,7 @@ - + @@ -60,7 +66,7 @@ - + @@ -71,7 +77,7 @@ - + @@ -140,4 +146,4 @@ - + \ No newline at end of file diff --git a/THIRDPARTYNOTICES.md b/THIRDPARTYNOTICES.md index 379fc02b91..257d951f34 100644 --- a/THIRDPARTYNOTICES.md +++ b/THIRDPARTYNOTICES.md @@ -539,8 +539,8 @@ This file is based on or incorporates material from the projects listed below (T > limitations under the License. > -## MediatR 9.0.0 -* Component Source: https://github.com/jbogard/MediatR +## Medino 3.0.2 +* Component Source: https://github.com/brendankowitz/Medino * Component Copyright and License: > Apache License > Version 2.0, January 2004 diff --git a/build/build-variables.yml b/build/build-variables.yml index 75699622d0..c33283af4d 100644 --- a/build/build-variables.yml +++ b/build/build-variables.yml @@ -5,7 +5,8 @@ variables: buildConfiguration: 'Release' publicDockerImagePlatforms: 'linux/amd64,linux/arm64' testDockerImagePlatforms: 'linux/amd64' - defaultBuildFramework: 'net9.0' + # Use .NET 10 SDK to support SQL script generation tool, target net10.0 + defaultBuildFramework: 'net10.0' azureSubscriptionEndpoint: 'docker-build' azureContainerRegistryName: 'healthplatformregistry' azureContainerRegistry: '$(azureContainerRegistryName).azurecr.io' diff --git a/build/ci-pipeline.yml b/build/ci-pipeline.yml index 7733bb5a3e..4889e1ef08 100644 --- a/build/ci-pipeline.yml +++ b/build/ci-pipeline.yml @@ -65,7 +65,7 @@ stages: majorMinorPatch: $[stageDependencies.UpdateVersion.Semver.outputs['SetVariablesFromGitVersion.majorMinorPatch']] nuGetVersion: $[stageDependencies.UpdateVersion.Semver.outputs['SetVariablesFromGitVersion.nuGetVersion']] jobs: - - job: Windows_dotnet9 + - job: Windows_dotnet10 pool: name: '$(DefaultWindowsPool)' demands: diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 2181374970..993bf88c56 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,5 +1,6 @@ # --platform tells docker to always use the host platform for the build not the target platform. Runtime container will use target platform. -FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0.306-azurelinux3.0 AS build +# Use .NET 10 SDK to support SQL script generation tool, targeting net10.0 and net8.0 in builds +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.100-azurelinux3.0 AS build ARG TARGETARCH ARG FHIR_VERSION ARG ASSEMBLY_VER @@ -77,10 +78,10 @@ RUN dotnet restore ./src/Microsoft.Health.Fhir.${FHIR_VERSION}.Web/Microsoft.Hea COPY . . -RUN dotnet publish /repo/src/Microsoft.Health.Fhir.${FHIR_VERSION}.Web/Microsoft.Health.Fhir.${FHIR_VERSION}.Web.csproj -o "/build" --no-restore -p:AssemblyVersion="${ASSEMBLY_VER}" -p:FileVersion="${ASSEMBLY_VER}" -p:Version="${ASSEMBLY_VER}" -f net9.0 -a $TARGETARCH +RUN dotnet publish /repo/src/Microsoft.Health.Fhir.${FHIR_VERSION}.Web/Microsoft.Health.Fhir.${FHIR_VERSION}.Web.csproj -o "/build" --no-restore -p:AssemblyVersion="${ASSEMBLY_VER}" -p:FileVersion="${ASSEMBLY_VER}" -p:Version="${ASSEMBLY_VER}" -f net10.0 -a $TARGETARCH # Implicitly uses the target platform for the runtime image. -FROM mcr.microsoft.com/dotnet/aspnet:9.0.10-azurelinux3.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:10.0.0-azurelinux3.0 AS runtime ARG FHIR_VERSION diff --git a/build/dotnet8-compat/global.json b/build/dotnet8-compat/global.json index bb0a2659e6..2c94190a91 100644 --- a/build/dotnet8-compat/global.json +++ b/build/dotnet8-compat/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "8.0.415" + "version": "8.0.416" } } diff --git a/build/dotnet9-compat/global.json b/build/dotnet9-compat/global.json new file mode 100644 index 0000000000..9128fc8e67 --- /dev/null +++ b/build/dotnet9-compat/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "9.0.307" + } +} diff --git a/build/jobs/analyze.yml b/build/jobs/analyze.yml index f8e2a8c7c7..b1c7f2266f 100644 --- a/build/jobs/analyze.yml +++ b/build/jobs/analyze.yml @@ -110,7 +110,7 @@ steps: inputs: userProvideBuildInfo: 'msBuildInfo' msBuildArchitecture: 'DotNetCore' - msBuildCommandline: 'dotnet build $(Build.SourcesDirectory)/Microsoft.Health.Fhir.sln --configuration $(buildConfiguration) -p:ContinuousIntegrationBuild=true -f net9.0' + msBuildCommandline: 'dotnet build $(Build.SourcesDirectory)/Microsoft.Health.Fhir.sln --configuration $(buildConfiguration) -p:ContinuousIntegrationBuild=true -f net10.0' - task: BinSkim@4 inputs: diff --git a/build/pr-pipeline.yml b/build/pr-pipeline.yml index 6e582582a5..58b5641c73 100644 --- a/build/pr-pipeline.yml +++ b/build/pr-pipeline.yml @@ -37,7 +37,7 @@ stages: majorMinorPatch: $[stageDependencies.UpdateVersion.Semver.outputs['SetVariablesFromGitVersion.majorMinorPatch']] nuGetVersion: $[stageDependencies.UpdateVersion.Semver.outputs['SetVariablesFromGitVersion.nuGetVersion']] jobs: - - job: Windows_dotnet9 + - job: Windows_dotnet10 pool: name: '$(DefaultWindowsPool)' demands: diff --git a/global.json b/global.json index feffdd4ee5..481e95ec7b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "9.0.306" + "version": "10.0.100" } } diff --git a/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiNotificationMiddleware.cs b/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiNotificationMiddleware.cs index 2fd4f8efba..005ce4de86 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiNotificationMiddleware.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiNotificationMiddleware.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; @@ -79,7 +79,7 @@ protected virtual async Task PublishNotificationAsync(HttpContext context, Reque apiNotification.ResourceType = fhirRequestContext.ResourceType; apiNotification.StatusCode = (HttpStatusCode)context.Response.StatusCode; - await _mediator.Publish(apiNotification, CancellationToken.None); + await _mediator.PublishAsync(apiNotification, CancellationToken.None); } } catch (Exception e) diff --git a/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiResponseNotification.cs b/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiResponseNotification.cs index 4c4016b2b8..43de04cb6e 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiResponseNotification.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/ApiNotifications/ApiResponseNotification.cs @@ -10,9 +10,9 @@ namespace Microsoft.Health.Fhir.Api.Features.ApiNotifications { /// - /// A Mediatr message containing information about API responses. + /// A Medino message containing information about API responses. /// This gets emitted by the ApiNotificationMiddleware when a response is returned by the server. - /// Consume these using Mediatr to collect stats about API responses. + /// Consume these using Medino to collect stats about API responses. /// public class ApiResponseNotification : IMetricsNotification { diff --git a/src/Microsoft.Health.Fhir.Api/Features/BackgroundJobService/HostingBackgroundService.cs b/src/Microsoft.Health.Fhir.Api/Features/BackgroundJobService/HostingBackgroundService.cs index 2cca05b170..ca7312246b 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/BackgroundJobService/HostingBackgroundService.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/BackgroundJobService/HostingBackgroundService.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -94,7 +94,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } } - public Task Handle(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) + public Task HandleAsync(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) { _storageReady = true; return Task.CompletedTask; diff --git a/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotification.cs b/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotification.cs index afd8f4d426..3b950b1192 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotification.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotification.cs @@ -10,8 +10,8 @@ namespace Microsoft.Health.Fhir.Api.Features.ExceptionNotifications { /// - /// A MediatR message containing information about exceptions with the context of the current request. - /// Consume these using MediatR to collect stats about exceptions. + /// A Medino message containing information about exceptions with the context of the current request. + /// Consume these using Medino to collect stats about exceptions. /// public class ExceptionNotification : IMetricsNotification { diff --git a/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotificationMiddleware.cs b/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotificationMiddleware.cs index 0408f0c636..2de5a996b7 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotificationMiddleware.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/ExceptionNotifications/ExceptionNotificationMiddleware.cs @@ -7,7 +7,7 @@ using System.Net; using System.Threading; using EnsureThat; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Context; @@ -72,7 +72,7 @@ public async Task Invoke(HttpContext context) exceptionNotification.IsRequestRateExceeded = exception.IsRequestRateExceeded(); exceptionNotification.BaseException = exception; - await _mediator.Publish(exceptionNotification, CancellationToken.None); + await _mediator.PublishAsync(exceptionNotification, CancellationToken.None); } catch (Exception e) { diff --git a/src/Microsoft.Health.Fhir.Api/Features/Health/ImproperBehaviorHealthCheck.cs b/src/Microsoft.Health.Fhir.Api/Features/Health/ImproperBehaviorHealthCheck.cs index 4382c7ab7b..3ca548d5d6 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/Health/ImproperBehaviorHealthCheck.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/Health/ImproperBehaviorHealthCheck.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Health.Fhir.Core.Features.Health; @@ -26,7 +26,7 @@ public Task CheckHealthAsync(HealthCheckContext context, Canc return Task.FromResult(new HealthCheckResult(HealthStatus.Unhealthy, "Improper server behavior has been detected." + _message)); } - public Task Handle(ImproperBehaviorNotification notification, CancellationToken cancellationToken) + public Task HandleAsync(ImproperBehaviorNotification notification, CancellationToken cancellationToken) { _isHealthy = false; _message += " " + notification.Message; diff --git a/src/Microsoft.Health.Fhir.Api/Features/Health/StorageInitializedHealthCheck.cs b/src/Microsoft.Health.Fhir.Api/Features/Health/StorageInitializedHealthCheck.cs index 9b90d7d316..c7fdb37ffe 100644 --- a/src/Microsoft.Health.Fhir.Api/Features/Health/StorageInitializedHealthCheck.cs +++ b/src/Microsoft.Health.Fhir.Api/Features/Health/StorageInitializedHealthCheck.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Health.Core; using Microsoft.Health.Fhir.Core.Extensions; @@ -54,7 +54,7 @@ public Task CheckHealthAsync(HealthCheckContext context, Canc return Task.FromResult(new HealthCheckResult(HealthStatus.Unhealthy, $"Storage has not been initialized. Waited: {(int)waited.TotalSeconds}s.")); } - public Task Handle(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) + public Task HandleAsync(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) { _storageReady = true; return Task.CompletedTask; diff --git a/src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj b/src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj index 7d946c1662..38264520cb 100644 --- a/src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj +++ b/src/Microsoft.Health.Fhir.Api/Microsoft.Health.Fhir.Api.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/BulkDeleteProcessingJobTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/BulkDeleteProcessingJobTests.cs index 6c1f174e16..399d2928d7 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/BulkDeleteProcessingJobTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/BulkDeleteProcessingJobTests.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Context; using Microsoft.Health.Fhir.Core.Features.Context; using Microsoft.Health.Fhir.Core.Features.Operations; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CancelBulkDeleteHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CancelBulkDeleteHandlerTests.cs index bf3fd5c705..8712342bef 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CancelBulkDeleteHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CancelBulkDeleteHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -111,7 +111,7 @@ public async Task GivenUnauthorizedDeleteUser_WhenCancelationIsRequested_ThenUna _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(DataActions.Read); var request = new CancelBulkDeleteRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -121,7 +121,7 @@ public async Task GivenNonExistantBulkDeleteJob_WhenCancelationIsRequested_ThenN _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkDelete, Arg.Any(), false, Arg.Any()).Returns(new List()); var request = new CancelBulkDeleteRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } private async Task RunBulkDeleteTest(IReadOnlyList jobs, HttpStatusCode expectedStatus) @@ -134,12 +134,12 @@ private async Task RunBulkDeleteTest(IReadOnlyList jobs, HttpStatusCode if (expectedStatus == HttpStatusCode.Conflict) { - OperationFailedException operationFailedException = await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + OperationFailedException operationFailedException = await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); Assert.Equal(HttpStatusCode.Conflict, operationFailedException.ResponseStatusCode); } else { - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.Equal(expectedStatus, response.StatusCode); if (expectedStatus == HttpStatusCode.Accepted) diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CreateBulkDeleteHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CreateBulkDeleteHandlerTests.cs index acf3a40fcd..9543119244 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CreateBulkDeleteHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/CreateBulkDeleteHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -94,7 +94,7 @@ public async Task GivenBulkDeleteRequest_WhenJobCreationRequested_ThenJobIsCreat var request = new CreateBulkDeleteRequest(DeleteOperation.HardDelete, KnownResourceTypes.Patient, searchParams, false, null, false); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.Equal(1, response.Id); await _queueClient.ReceivedWithAnyArgs(1).EnqueueAsync((byte)QueueType.BulkDelete, Arg.Any(), Arg.Any(), false, Arg.Any()); @@ -113,7 +113,7 @@ public async Task GivenBulkDeleteRequestWithInvalidSearchParameter_WhenJobCreati var request = new CreateBulkDeleteRequest(DeleteOperation.HardDelete, KnownResourceTypes.Patient, searchParams, false, null, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Theory] @@ -125,7 +125,7 @@ public async Task GivenUnauthorizedUser_WhenJobCreationRequested_ThenUnauthorize _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(userRole); var request = new CreateBulkDeleteRequest(deleteOperation, null, null, false, null, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -136,7 +136,7 @@ public async Task GivenBulkDeleteRequest_WhenJobCreationFails_ThenExceptionIsThr _queueClient.EnqueueAsync((byte)QueueType.BulkDelete, Arg.Any(), Arg.Any(), false, Arg.Any()).Returns(new List()); var request = new CreateBulkDeleteRequest(DeleteOperation.HardDelete, null, new List>(), false, null, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } } } diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/GetBulkDeleteHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/GetBulkDeleteHandlerTests.cs index f4a4f73e95..6a7e91954e 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/GetBulkDeleteHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkDelete/GetBulkDeleteHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -261,7 +261,7 @@ public async Task GivenUnauthorizedUser_WhenStatusRequested_ThenUnauthorizedIsRe _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(DataActions.None); var request = new GetBulkDeleteRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -271,7 +271,7 @@ public async Task GivenNonExistantBulkDeleteJob_WhenStatusRequested_ThenNotFound _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkDelete, Arg.Any(), false, Arg.Any()).Returns(new List()); var request = new GetBulkDeleteRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } private async Task RunGetBulkDeleteTest(IReadOnlyList> jobs, GetBulkDeleteResponse expectedResponse) @@ -286,7 +286,7 @@ private async Task RunGetBulkDeleteTest(IReadOnlyList> jobs, _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkDelete, Arg.Any(), true, Arg.Any()).Returns(jobs.Select(job => job.Item1).ToList()); var request = new GetBulkDeleteRequest(1); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.Equal(expectedResponse.HttpStatusCode, response.HttpStatusCode); diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/BulkUpdateProcessingJobTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/BulkUpdateProcessingJobTests.cs index 8e346d2610..66596638c7 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/BulkUpdateProcessingJobTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/BulkUpdateProcessingJobTests.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Hl7.Fhir.Rest; -using MediatR; +using Medino; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -82,7 +82,7 @@ public async Task GivenProcessingJob_WhenJobIsRun_ThenResourcesAreUpdated() Assert.Equal(2, result.ResourcesIgnored["CarePlan"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Is(b => !b), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 4), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 4), Arg.Any()); } [Theory] @@ -150,7 +150,7 @@ public async Task GivenProcessingJobWithSurrogateIds_WhenJobIsRun_ThenIdsAreAdde Assert.Equal(3, result.ResourcesUpdated["Patient"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 3), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 3), Arg.Any()); } [Theory] @@ -287,7 +287,7 @@ public async Task GivenProcessingJobLastOneFromGroupAndProfileResourceTypeIsUpda Assert.Equal(3, result.ResourcesUpdated["Patient"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); _supportedProfilesStore.Received(1).Refresh(); } @@ -329,7 +329,7 @@ public async Task GivenProcessingJobLastOneFromGroupAndProfileResourceTypeIsUpda Assert.Equal(3, result.ResourcesUpdated["StructureDefinition"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); _supportedProfilesStore.Received(1).Refresh(); } @@ -372,7 +372,7 @@ public async Task GivenProcessingJobLastOneFromGroupAndProfileResourceTypeIsNotU Assert.Equal(3, result.ResourcesUpdated["Patient"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); _supportedProfilesStore.DidNotReceiveWithAnyArgs().Refresh(); } @@ -412,7 +412,7 @@ public async Task GivenProcessingJobNotTheLastOneFromGroupAndProfileResourceType Assert.Equal(3, result.ResourcesUpdated["StructureDefinition"]); await _updater.ReceivedWithAnyArgs(1).UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobs[1].Id && n.ResourcesUpdated == 3), Arg.Any()); _supportedProfilesStore.DidNotReceiveWithAnyArgs().Refresh(); } @@ -444,7 +444,7 @@ public async Task GivenProcessingJobWhenIncompleteOperationExceptionIsThrown_Whe Assert.Contains(exceptionMessage, errorResult.Issues); Assert.Equal(1, errorResult.ResourcesPatchFailed["Patient"]); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 2), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 2), Arg.Any()); } [Fact] @@ -475,7 +475,7 @@ public async Task GivenProcessingJobWhenResourcesPatchFailedIsNotEmpty_WhenJobIs Assert.Equal(2, errorResult.ResourcesIgnored["StructureDefinition"]); Assert.Equal(1, errorResult.ResourcesPatchFailed["Patient"]); - await _mediator.Received(1).Publish(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 2), Arg.Any()); + await _mediator.Received(1).PublishAsync(Arg.Is(n => n.JobId == jobInfo.Id && n.ResourcesUpdated == 2), Arg.Any()); _supportedProfilesStore.DidNotReceiveWithAnyArgs().Refresh(); } @@ -504,7 +504,7 @@ public async Task GivenProcessingJobWhenNoResourcesUpdatedAndNoErrors_WhenJobIsR Assert.Empty(result.ResourcesPatchFailed); Assert.Empty(result.Issues); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + await _mediator.DidNotReceiveWithAnyArgs().PublishAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -526,7 +526,7 @@ public async Task GivenProcessingJobWhenUnexpectedExceptionIsThrownFromUpdateMul // Act & Assert var ex = await Assert.ThrowsAsync(() => _processingJob.ExecuteAsync(jobInfo, CancellationToken.None)); Assert.Equal("Unexpected error", ex.Message); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + await _mediator.DidNotReceiveWithAnyArgs().PublishAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -617,7 +617,7 @@ public async Task GivenProcessingJob_WhenMediatorThrowsException_ThenExceptionIs _updater.UpdateMultipleAsync(Arg.Any(), Arg.Any(), Arg.Any(), 0, Arg.Any(), Arg.Any>>(), Arg.Any(), Arg.Any()) .Returns(args => substituteResults); - _mediator.Publish(Arg.Any(), Arg.Any()) + _mediator.PublishAsync(Arg.Any(), Arg.Any()) .Throws(new InvalidOperationException("Mediator error")); await Assert.ThrowsAsync(() => _processingJob.ExecuteAsync(jobInfo, CancellationToken.None)); diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CancelBulkUpdateHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CancelBulkUpdateHandlerTests.cs index 588b179d23..216a07fa1e 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CancelBulkUpdateHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CancelBulkUpdateHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -126,7 +126,7 @@ public async Task GivenCompletedJobWithProfileResourceUpdate_WhenCancelationIsRe .Returns(DataActions.BulkOperator); var request = new CancelBulkUpdateRequest(1); - await _handler.Handle(request, CancellationToken.None); + await _handler.HandleAsync(request, CancellationToken.None); _supportedProfiles.Received(1).Refresh(); } @@ -161,7 +161,7 @@ public async Task GivenSoftFailedJobWithProfileResourceUpdate_WhenCancelationIsR .Returns(DataActions.BulkOperator); var request = new CancelBulkUpdateRequest(1); - await _handler.Handle(request, CancellationToken.None); + await _handler.HandleAsync(request, CancellationToken.None); _supportedProfiles.Received(1).Refresh(); } @@ -172,7 +172,7 @@ public async Task GivenUnauthorizedDeleteUser_WhenCancelationIsRequested_ThenUna _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(DataActions.Write); var request = new CancelBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -182,7 +182,7 @@ public async Task GivenNonExistantBulkUpdateJob_WhenCancelationIsRequested_ThenN _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkUpdate, Arg.Any(), false, Arg.Any()).Returns(new List()); var request = new CancelBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -193,7 +193,7 @@ public async Task GivenBulkUpdateJob_WhenQueueClientThrowsException_ThenExceptio .Throws(new System.InvalidOperationException("Unexpected error")); var request = new CancelBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -202,7 +202,7 @@ public async Task GivenBulkUpdateJob_WhenUserHasPartialAccess_ThenUnauthorizedFh _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(DataActions.Read); var request = new CancelBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -213,7 +213,7 @@ public async Task GivenBulkUpdateJobWithNoJobsInGroup_WhenCancelationIsRequested .Returns(new List()); var request = new CancelBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } public static IEnumerable BulkUpdateJobConflictTestData() @@ -289,12 +289,12 @@ private async Task RunBulkUpdateTest(IReadOnlyList jobs, HttpStatusCode if (expectedStatus == HttpStatusCode.Conflict) { - OperationFailedException operationFailedException = await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + OperationFailedException operationFailedException = await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); Assert.Equal(HttpStatusCode.Conflict, operationFailedException.ResponseStatusCode); } else { - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.Equal(expectedStatus, response.StatusCode); if (expectedStatus == HttpStatusCode.Accepted) diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CreateBulkUpdateHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CreateBulkUpdateHandlerTests.cs index 010b32d139..f77655086f 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CreateBulkUpdateHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/CreateBulkUpdateHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -93,7 +93,7 @@ public async Task GivenBulkUpdateRequestWithVariousSearchParams_WhenJobCreationR Parameters parameters = GenerateParameters("replace"); var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, parameters, false); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.Equal(1, response.Id); await _queueClient.ReceivedWithAnyArgs(1).EnqueueAsync((byte)QueueType.BulkUpdate, Arg.Any(), Arg.Any(), false, Arg.Any()); @@ -127,7 +127,7 @@ public async Task GivenBulkUpdateRequest_WhenResourceTypeIsNull_ThenJobIsCreated }); Parameters parameters = GenerateParameters("upsert"); var request = new CreateBulkUpdateRequest(null, searchParams, parameters, false); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.Equal(1, response.Id); await _queueClient.ReceivedWithAnyArgs(1).EnqueueAsync((byte)QueueType.BulkUpdate, Arg.Any(), Arg.Any(), false, Arg.Any()); @@ -157,7 +157,7 @@ public async Task GivenBulkUpdateRequest_WhenSearchParamsIsNull_ThenJobIsCreated Parameters parameters = GenerateParameters("replace"); var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, null, parameters, false); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.Equal(1, response.Id); await _queueClient.ReceivedWithAnyArgs(1).EnqueueAsync((byte)QueueType.BulkUpdate, Arg.Any(), Arg.Any(), false, Arg.Any()); @@ -179,7 +179,7 @@ public async Task GivenBulkUpdateRequest_WhenQueueClientThrowsUnexpectedExceptio Parameters parameters = GenerateParameters("replace"); var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, parameters, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -196,7 +196,7 @@ public async Task GivenBulkUpdateRequest_WhenJobCreationRequestedWhileAnotherJob var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, parameters, false); - var ex = await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + var ex = await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); await _queueClient.ReceivedWithAnyArgs(1).EnqueueAsync((byte)QueueType.BulkUpdate, Arg.Any(), Arg.Any(), true, Arg.Any()); Assert.Equal("A bulk update job is already running.", ex.Message); } @@ -214,7 +214,7 @@ public async Task GivenBulkUpdateRequestWithInvalidSearchParameter_WhenJobCreati var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, null, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Theory] @@ -231,7 +231,7 @@ public async Task GivenBulkUpdateRequest_WhenResourceTypeIsExcluded_ThenBadReque _contextAccessor.RequestContext.BundleIssues.Clear(); var request = new CreateBulkUpdateRequest(resourceType, searchParams, null, false); - var ex = await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + var ex = await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); Assert.Equal($"Bulk update is not supported for resource type {resourceType}.", ex.Message); } @@ -277,7 +277,7 @@ public async Task GivenBulkUpdateRequest_WhenMultipleOperationTypesAndOneIsUnsup }; var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, parameters, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -294,7 +294,7 @@ public async Task GivenBulkUpdateRequest_WhenUserIsUnauthorized_ThenUnauthorized Parameters parameters = GenerateParameters("upsert"); var request = new CreateBulkUpdateRequest(KnownResourceTypes.Patient, searchParams, parameters, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -306,7 +306,7 @@ public async Task GivenBulkUpdateRequest_WhenJobCreationFails_ThenExceptionIsThr var parameters = GenerateParameters("upsert"); var request = new CreateBulkUpdateRequest(null, new List>(), parameters, false); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } private static Parameters GenerateParameters(string typeValue) diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/GetBulkUpdateHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/GetBulkUpdateHandlerTests.cs index 5eceba1b3f..7f7422aac1 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/GetBulkUpdateHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/BulkUpdate/GetBulkUpdateHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -533,7 +533,7 @@ public async Task GivenUnauthorizedUser_WhenStatusRequested_ThenUnauthorizedIsRe _authorizationService.CheckAccess(Arg.Any(), Arg.Any()).Returns(DataActions.None); var request = new GetBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -543,7 +543,7 @@ public async Task GivenNonExistantBulkUpdateJob_WhenStatusRequested_ThenNotFound _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkUpdate, Arg.Any(), false, Arg.Any()).Returns(new List()); var request = new GetBulkUpdateRequest(1); - await Assert.ThrowsAsync(async () => await _handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _handler.HandleAsync(request, CancellationToken.None)); } private async Task RunGetBulkUpdateTest(IReadOnlyList> jobs, GetBulkUpdateResponse expectedResponse) @@ -558,7 +558,7 @@ private async Task RunGetBulkUpdateTest(IReadOnlyList> jobs, _queueClient.GetJobByGroupIdAsync((byte)QueueType.BulkUpdate, Arg.Any(), true, Arg.Any()).Returns(jobs.Select(job => job.Item1).ToList()); var request = new GetBulkUpdateRequest(1); - var response = await _handler.Handle(request, CancellationToken.None); + var response = await _handler.HandleAsync(request, CancellationToken.None); Assert.Equal(expectedResponse.HttpStatusCode, response.HttpStatusCode); diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/CancelExportRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/CancelExportRequestHandlerTests.cs index d23e25c249..d1d3fcab6f 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/CancelExportRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/CancelExportRequestHandlerTests.cs @@ -8,7 +8,7 @@ using System.Reflection.Metadata; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Extensions.DependencyInjection; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/ExportJobTaskTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/ExportJobTaskTests.cs index 82a01fb7d1..3f1bcec785 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/ExportJobTaskTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/ExportJobTaskTests.cs @@ -12,7 +12,7 @@ using System.Threading; using System.Threading.Tasks; using Hl7.Fhir.ElementModel; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/GetExportRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/GetExportRequestHandlerTests.cs index af46a00108..86e4f6aa1c 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/GetExportRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Export/GetExportRequestHandlerTests.cs @@ -9,7 +9,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Extensions; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/CancelImportRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/CancelImportRequestHandlerTests.cs index d74a4c701f..e14edcf3d4 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/CancelImportRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/CancelImportRequestHandlerTests.cs @@ -8,7 +8,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Extensions.DependencyInjection; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/GetImportRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/GetImportRequestHandlerTests.cs index 5d5b602e5d..cdc6a46edb 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/GetImportRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Import/GetImportRequestHandlerTests.cs @@ -8,7 +8,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Exceptions; diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Reindex/ReindexHandlerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Reindex/ReindexHandlerTests.cs index 1a7487092a..16242ff304 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Reindex/ReindexHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Operations/Reindex/ReindexHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ public async Task GivenAGetRequest_WhenGettingAnExistingJob_ThenHttpResponseCode var handler = new GetReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.Equal(HttpStatusCode.OK, result.StatusCode); } @@ -68,7 +68,7 @@ public async Task GivenAGetRequest_WhenUserUnauthorized_ThenUnauthorizedFhirExce var handler = new GetReindexRequestHandler(_fhirOperationDataStore, authorizationService); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -82,7 +82,7 @@ public async Task GivenAGetRequest_WhenIdNotFound_ThenJobNotFoundExceptionThrown var handler = new GetReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -96,7 +96,7 @@ public async Task GivenAGetRequest_WhenTooManyRequestsThrown_ThenTooManyRequests var handler = new GetReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - Exception thrownException = await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + Exception thrownException = await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); Assert.IsType(thrownException.InnerException); } @@ -114,7 +114,7 @@ public async Task GivenACancelRequest_WhenUserUnauthorized_ThenUnauthorizedFhirE var handler = new CancelReindexRequestHandler(_fhirOperationDataStore, authorizationService); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -129,7 +129,7 @@ public async Task GivenACancelRequest_WhenJobCompleted_ThenRequestNotValidExcept var handler = new CancelReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -145,7 +145,7 @@ public async Task GivenACancelRequest_WhenJobInProgress_ThenJobUpdatedToCanceled var handler = new CancelReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.Equal(OperationStatus.Canceled, result.Job.JobRecord.Status); } diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterCacheRefreshBackgroundServiceTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterCacheRefreshBackgroundServiceTests.cs index 709e9b47a3..8a0ef77f5e 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterCacheRefreshBackgroundServiceTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterCacheRefreshBackgroundServiceTests.cs @@ -53,7 +53,7 @@ public async Task Handle_WhenSearchParametersInitializedNotificationReceived_Sho var notification = new SearchParametersInitializedNotification(); // Act - await _service.Handle(notification, CancellationToken.None); + await _service.HandleAsync(notification, CancellationToken.None); // Assert // The method should complete without throwing - the flag is set internally @@ -200,10 +200,10 @@ public async Task OnRefreshTimer_WhenCacheIsStale_ShouldCallGetAndApplySearchPar .Returns(true); // Cache is stale // Set initialized to true to allow timer to run - await _service.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await _service.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); // Wait for the timer to fire at least once and allow async operations to complete - await Task.Delay(200); + await Task.Delay(500); // Assert - use at least 1 call since timer might fire multiple times in test environment await _searchParameterStatusManager.Received().EnsureCacheFreshnessAsync(Arg.Any()); @@ -221,10 +221,10 @@ public async Task OnRefreshTimer_WhenCacheIsFresh_ShouldNotCallGetAndApplySearch .Returns(false); // Cache is fresh // Set initialized to true to allow timer to run - await _service.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await _service.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); // Wait for the timer to fire at least once and allow async operations to complete - await Task.Delay(200); + await Task.Delay(500); // Assert - verify the timer is working and EnsureCacheFreshnessAsync was called await _searchParameterStatusManager.Received().EnsureCacheFreshnessAsync(Arg.Any()); @@ -285,7 +285,7 @@ public async Task OnRefreshTimer_WhenServiceProviderDisposed_ShouldHandleGracefu mockLogger); // Act - Initialize and let timer run - await service.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await service.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); // Wait for timer to fire and handle the exception await Task.Delay(200); @@ -318,7 +318,7 @@ public async Task OnRefreshTimer_WhenOperationCanceled_ShouldHandleGracefully() mockLogger); // Act - Initialize and let timer run - await service.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await service.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); // Wait for timer to fire and handle the exception await Task.Delay(200); @@ -353,7 +353,7 @@ public async Task Handle_WhenServiceAlreadyCancelled_ShouldNotStartTimer() await executeTask; // Act - Try to handle the notification after cancellation - await service.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await service.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); // Assert - Timer should not fire, so no calls should be made await Task.Delay(200); // Wait to see if timer would fire diff --git a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterStatusManagerTests.cs b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterStatusManagerTests.cs index 53688b3f01..2321c1dba3 100644 --- a/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterStatusManagerTests.cs +++ b/src/Microsoft.Health.Fhir.Core.UnitTests/Features/Search/Registry/SearchParameterStatusManagerTests.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core; using Microsoft.Health.Fhir.Core.Extensions; @@ -174,7 +174,7 @@ public async Task GivenASPStatusManager_WhenInitializing_ThenUpdatedSearchParame await _mediator .Received() - .Publish( + .PublishAsync( Arg.Is(x => modifiedItems.Except(x.SearchParameters).Any() == false), Arg.Any()); } diff --git a/src/Microsoft.Health.Fhir.Core/Extensions/ExportMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Core/Extensions/ExportMediatorExtensions.cs index 9e7a271334..2e6e775ebf 100644 --- a/src/Microsoft.Health.Fhir.Core/Extensions/ExportMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Core/Extensions/ExportMediatorExtensions.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.Export; using Microsoft.Health.Fhir.Core.Messages.Export; using Microsoft.Health.Fhir.Core.Models; @@ -57,7 +57,7 @@ public static async Task ExportAsync( anonymizationConfigurationLocation: anonymizationConfigLocation, anonymizationConfigurationFileETag: anonymizationConfigFileETag); - CreateExportResponse response = await mediator.Send(request, cancellationToken); + CreateExportResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -69,7 +69,7 @@ public static async Task GetExportStatusAsync(this IMediator var request = new GetExportRequest(requestUri, jobId); - GetExportResponse response = await mediator.Send(request, cancellationToken); + GetExportResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -80,7 +80,7 @@ public static async Task CancelExportAsync(this IMediator var request = new CancelExportRequest(jobId); - return await mediator.Send(request, cancellationToken); + return await mediator.SendAsync(request, cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Extensions/ImportMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Core/Extensions/ImportMediatorExtensions.cs index 03dbcde5df..e16bb1b6ba 100644 --- a/src/Microsoft.Health.Fhir.Core/Extensions/ImportMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Core/Extensions/ImportMediatorExtensions.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.Import; using Microsoft.Health.Fhir.Core.Features.Operations.Import.Models; using Microsoft.Health.Fhir.Core.Messages.Import; @@ -36,7 +36,7 @@ public static async Task ImportAsync( var request = new CreateImportRequest(requestUri, inputFormat, inputSource, input, storageDetail, importMode, allowNegativeVersions, errorContainerName, eventualConsistency, processingUnitBytesToRead); - CreateImportResponse response = await mediator.Send(request, cancellationToken); + CreateImportResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -46,7 +46,7 @@ public static async Task GetImportStatusAsync(this IMediator var request = new GetImportRequest(jobId, returnDetails); - GetImportResponse response = await mediator.Send(request, cancellationToken); + GetImportResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -56,7 +56,7 @@ public static async Task CancelImportAsync(this IMediator var request = new CancelImportRequest(jobId); - return await mediator.Send(request, cancellationToken); + return await mediator.SendAsync(request, cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Compartment/SearchCompartmentHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Compartment/SearchCompartmentHandler.cs index de886d9fdb..743fafd7a7 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Compartment/SearchCompartmentHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Compartment/SearchCompartmentHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -46,7 +46,7 @@ public SearchCompartmentHandler(ISearchService searchService, IBundleFactory bun } /// - public async Task Handle(SearchCompartmentRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(SearchCompartmentRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetCapabilitiesHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetCapabilitiesHandler.cs index 18c5fdb52f..66da1eeca5 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetCapabilitiesHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetCapabilitiesHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Messages.Get; namespace Microsoft.Health.Fhir.Core.Features.Conformance @@ -22,7 +22,7 @@ public GetCapabilitiesHandler(IConformanceProvider provider) _provider = provider; } - public async Task Handle(GetCapabilitiesRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetCapabilitiesRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetOperationVersionsHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetOperationVersionsHandler.cs index f2c4b27a84..99982cc93d 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetOperationVersionsHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetOperationVersionsHandler.cs @@ -7,13 +7,13 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Messages.Get; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Features.Conformance { - public class GetOperationVersionsHandler : IRequestHandler + public sealed class GetOperationVersionsHandler : IRequestHandler { private readonly IModelInfoProvider _provider; @@ -25,12 +25,12 @@ public GetOperationVersionsHandler(IModelInfoProvider provider) } Task IRequestHandler. - Handle(GetOperationVersionsRequest request, CancellationToken cancellationToken) + HandleAsync(GetOperationVersionsRequest request, CancellationToken cancellationToken) { return Task.FromResult(Handle(request)); } - protected GetOperationVersionsResponse Handle(GetOperationVersionsRequest request) + private GetOperationVersionsResponse Handle(GetOperationVersionsRequest request) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetSmartConfigurationHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetSmartConfigurationHandler.cs index 063ba9766a..66e7494574 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetSmartConfigurationHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Conformance/GetSmartConfigurationHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Core.Configs; using Microsoft.Health.Fhir.Core.Features.Operations; @@ -29,7 +29,7 @@ public GetSmartConfigurationHandler(IOptions securityConf _securityConfiguration = securityConfigurationOptions.Value; } - public Task Handle(GetSmartConfigurationRequest request, CancellationToken cancellationToken) + public Task HandleAsync(GetSmartConfigurationRequest request, CancellationToken cancellationToken) { return Task.FromResult(Handle(request)); } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Conformance/SystemConformanceProvider.cs b/src/Microsoft.Health.Fhir.Core/Features/Conformance/SystemConformanceProvider.cs index 30c3b57974..548d51e199 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Conformance/SystemConformanceProvider.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Conformance/SystemConformanceProvider.cs @@ -11,7 +11,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Features.Context; @@ -305,7 +305,7 @@ public async ValueTask DisposeAsync() _logger.LogInformation("SystemConformanceProvider: DisposeAsync completed."); } - public async Task Handle(RebuildCapabilityStatement notification, CancellationToken cancellationToken) + public async Task HandleAsync(RebuildCapabilityStatement notification, CancellationToken cancellationToken) { if (_disposed) { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Definition/SearchParameterDefinitionManager.cs b/src/Microsoft.Health.Fhir.Core/Features/Definition/SearchParameterDefinitionManager.cs index d9ed272c0b..b7a54f720b 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Definition/SearchParameterDefinitionManager.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Definition/SearchParameterDefinitionManager.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.ElementModel; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Exceptions; @@ -107,7 +107,7 @@ public async Task EnsureInitializedAsync(CancellationToken cancellationToken) _initialized = true; await LoadSearchParamsFromDataStore(cancellationToken); - await _mediator.Publish(new SearchParameterDefinitionManagerInitialized(), cancellationToken); + await _mediator.PublishAsync(new SearchParameterDefinitionManagerInitialized(), cancellationToken); } catch { @@ -330,7 +330,7 @@ public void UpdateSearchParameterStatus(string url, SearchParameterStatus desire } } - public async Task Handle(SearchParametersUpdatedNotification notification, CancellationToken cancellationToken) + public async Task HandleAsync(SearchParametersUpdatedNotification notification, CancellationToken cancellationToken) { var retry = 0; while (retry < 3) @@ -339,7 +339,7 @@ public async Task Handle(SearchParametersUpdatedNotification notification, Cance { _logger.LogInformation("SearchParameterDefinitionManager: Search parameters updated"); CalculateSearchParameterHash(); - await _mediator.Publish(new RebuildCapabilityStatement(RebuildPart.SearchParameter), cancellationToken); + await _mediator.PublishAsync(new RebuildCapabilityStatement(RebuildPart.SearchParameter), cancellationToken); return; } catch (Exception ex) @@ -350,10 +350,10 @@ public async Task Handle(SearchParametersUpdatedNotification notification, Cance } // Not reporting notification while we investigate why this could happen - // await _mediator.Publish(new ImproperBehaviorNotification("Error calculating search parameter hash"), cancellationToken); + // await _mediator.PublishAsync(new ImproperBehaviorNotification("Error calculating search parameter hash"), cancellationToken); } - public async Task Handle(StorageInitializedNotification notification, CancellationToken cancellationToken) + public async Task HandleAsync(StorageInitializedNotification notification, CancellationToken cancellationToken) { var retry = 0; while (retry < 3) @@ -372,7 +372,7 @@ public async Task Handle(StorageInitializedNotification notification, Cancellati } // Not reporting notification while we investigate why this could happen - // await _mediator.Publish(new ImproperBehaviorNotification("Error initializing search parameters"), cancellationToken); + // await _mediator.PublishAsync(new ImproperBehaviorNotification("Error initializing search parameters"), cancellationToken); } private async Task LoadSearchParamsFromDataStore(CancellationToken cancellationToken) diff --git a/src/Microsoft.Health.Fhir.Core/Features/Health/ImproperBehaviorNotification.cs b/src/Microsoft.Health.Fhir.Core/Features/Health/ImproperBehaviorNotification.cs index 73103a4577..36badcba22 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Health/ImproperBehaviorNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Health/ImproperBehaviorNotification.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Health { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Metrics/GeoReplicationLagNotification.cs b/src/Microsoft.Health.Fhir.Core/Features/Metrics/GeoReplicationLagNotification.cs index f23efd427a..ef9daa96b4 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Metrics/GeoReplicationLagNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Metrics/GeoReplicationLagNotification.cs @@ -8,9 +8,9 @@ namespace Microsoft.Health.Fhir.Core.Features.Metrics { /// - /// A MediatR message containing information about geo-replication lag. + /// A Medino message containing information about geo-replication lag. /// This gets emitted by the GeoReplicationLagWatchdog. - /// Consume these using MediatR to collect stats about geo-replication health. + /// Consume these using Medino to collect stats about geo-replication health. /// public class GeoReplicationLagNotification : IMetricsNotification { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Metrics/IMetricsNotification.cs b/src/Microsoft.Health.Fhir.Core/Features/Metrics/IMetricsNotification.cs index 11c2f9ccf2..b46b457cda 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Metrics/IMetricsNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Metrics/IMetricsNotification.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Metrics { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteMediatorExtensions.cs index ef5e0486d4..94b1957c60 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteMediatorExtensions.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.BulkDelete.Messages; using Microsoft.Health.Fhir.Core.Messages.Delete; @@ -22,7 +22,7 @@ public static async Task BulkDeleteAsync(this IMediato var request = new CreateBulkDeleteRequest(deleteOperation, resourceType, searchParameters, includeSoftDeleted, excludedResourceTypes, removeReferences); - CreateBulkDeleteResponse response = await mediator.Send(request, cancellationToken); + CreateBulkDeleteResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -32,7 +32,7 @@ public static async Task GetBulkDeleteStatusAsync(this IM var request = new GetBulkDeleteRequest(jobId); - GetBulkDeleteResponse response = await mediator.Send(request, cancellationToken); + GetBulkDeleteResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -42,7 +42,7 @@ public static async Task CancelBulkDeleteAsync(this IM var request = new CancelBulkDeleteRequest(jobId); - return await mediator.Send(request, cancellationToken); + return await mediator.SendAsync(request, cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteProcessingJob.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteProcessingJob.cs index 03597a2ce1..7a0f04ad6b 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteProcessingJob.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/BulkDeleteProcessingJob.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Primitives; using Microsoft.Health.Core.Features.Context; using Microsoft.Health.Extensions.DependencyInjection; @@ -108,7 +108,7 @@ public async Task ExecuteAsync(JobInfo jobInfo, CancellationToken cancel } } - await _mediator.Publish(new BulkDeleteMetricsNotification(jobInfo.Id, resourcesDeleted.Sum(resource => resource.Value)), cancellationToken); + await _mediator.PublishAsync(new BulkDeleteMetricsNotification(jobInfo.Id, resourcesDeleted.Sum(resource => resource.Value)), cancellationToken); if (exception != null) { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CancelBulkDeleteHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CancelBulkDeleteHandler.cs index 4fa72d607c..cb80629715 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CancelBulkDeleteHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CancelBulkDeleteHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -34,7 +34,7 @@ public CancelBulkDeleteHandler( _logger = EnsureArg.IsNotNull(logger, nameof(logger)); } - public async Task Handle(CancelBulkDeleteRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CancelBulkDeleteRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CreateBulkDeleteHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CreateBulkDeleteHandler.cs index 5aa8c0059e..1cd9f6eef7 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CreateBulkDeleteHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/CreateBulkDeleteHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; using Microsoft.Health.Core.Features.Context; @@ -49,7 +49,7 @@ public CreateBulkDeleteHandler( _logger = EnsureArg.IsNotNull(logger, nameof(logger)); } - public async Task Handle(CreateBulkDeleteRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateBulkDeleteRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/GetBulkDeleteHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/GetBulkDeleteHandler.cs index 83af0a30ab..5f83076f91 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/GetBulkDeleteHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Handlers/GetBulkDeleteHandler.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Operations.BulkDelete.Messages; @@ -36,7 +36,7 @@ public GetBulkDeleteHandler( _queueClient = EnsureArg.IsNotNull(queueClient, nameof(queueClient)); } - public async Task Handle(GetBulkDeleteRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetBulkDeleteRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CancelBulkDeleteRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CancelBulkDeleteRequest.cs index 172ba07f93..1c9fa211c4 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CancelBulkDeleteRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CancelBulkDeleteRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkDelete.Messages { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CreateBulkDeleteRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CreateBulkDeleteRequest.cs index 3371763299..a09c97a113 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CreateBulkDeleteRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/CreateBulkDeleteRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Messages.Delete; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkDelete.Messages diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/GetBulkDeleteRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/GetBulkDeleteRequest.cs index 69e1fbf576..1126baf712 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/GetBulkDeleteRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkDelete/Messages/GetBulkDeleteRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkDelete.Messages { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateMediatorExtensions.cs index e1159a1281..819d5fa850 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateMediatorExtensions.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.BulkUpdate.Messages; using Microsoft.Health.Fhir.Core.Features.Resources.Patch; @@ -22,7 +22,7 @@ public static async Task BulkUpdateAsync(this IMediato var request = new CreateBulkUpdateRequest(resourceType, searchParameters, parameters, isParallel, maxCount); - CreateBulkUpdateResponse response = await mediator.Send(request, cancellationToken); + CreateBulkUpdateResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -32,7 +32,7 @@ public static async Task GetBulkUpdateStatusAsync(this IM var request = new GetBulkUpdateRequest(jobId); - GetBulkUpdateResponse response = await mediator.Send(request, cancellationToken); + GetBulkUpdateResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -42,7 +42,7 @@ public static async Task CancelBulkUpdateAsync(this IM var request = new CancelBulkUpdateRequest(jobId); - return await mediator.Send(request, cancellationToken); + return await mediator.SendAsync(request, cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateProcessingJob.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateProcessingJob.cs index 6631989823..3a9ee82123 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateProcessingJob.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/BulkUpdateProcessingJob.cs @@ -14,7 +14,7 @@ using EnsureThat; using Hl7.Fhir.Serialization; using Hl7.Fhir.Support; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; using Microsoft.Health.Core.Features.Context; @@ -147,7 +147,7 @@ public async Task ExecuteAsync(JobInfo jobInfo, CancellationToken cancel if (result.ResourcesUpdated.Any()) { - await _mediator.Publish(new BulkUpdateMetricsNotification(jobInfo.Id, result.ResourcesUpdated.Sum(resource => resource.Value)), cancellationToken); + await _mediator.PublishAsync(new BulkUpdateMetricsNotification(jobInfo.Id, result.ResourcesUpdated.Sum(resource => resource.Value)), cancellationToken); } if (exception != null) diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CancelBulkUpdateHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CancelBulkUpdateHandler.cs index ed21efdaec..8afa6d1015 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CancelBulkUpdateHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CancelBulkUpdateHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -39,7 +39,7 @@ public CancelBulkUpdateHandler( _logger = EnsureArg.IsNotNull(logger, nameof(logger)); } - public async Task Handle(CancelBulkUpdateRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CancelBulkUpdateRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CreateBulkUpdateHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CreateBulkUpdateHandler.cs index 7726fefc8a..a352ce3e27 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CreateBulkUpdateHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/CreateBulkUpdateHandler.cs @@ -11,7 +11,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; using Microsoft.Health.Core.Features.Context; @@ -55,7 +55,7 @@ public CreateBulkUpdateHandler( _logger = EnsureArg.IsNotNull(logger, nameof(logger)); } - public async Task Handle(CreateBulkUpdateRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateBulkUpdateRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/GetBulkUpdateHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/GetBulkUpdateHandler.cs index 2b89e3871f..2058d9cc15 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/GetBulkUpdateHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Handlers/GetBulkUpdateHandler.cs @@ -13,7 +13,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Support; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Operations.BulkUpdate.Messages; @@ -40,7 +40,7 @@ public GetBulkUpdateHandler( _queueClient = EnsureArg.IsNotNull(queueClient, nameof(queueClient)); } - public async Task Handle(GetBulkUpdateRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetBulkUpdateRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CancelBulkUpdateRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CancelBulkUpdateRequest.cs index cc3d462789..6e77ac8e21 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CancelBulkUpdateRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CancelBulkUpdateRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkUpdate.Messages { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CreateBulkUpdateRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CreateBulkUpdateRequest.cs index 7f888d0bc8..400e9ab25d 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CreateBulkUpdateRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/CreateBulkUpdateRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkUpdate.Messages { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/GetBulkUpdateRequest.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/GetBulkUpdateRequest.cs index 0ec5fd45a4..8384e421cb 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/GetBulkUpdateRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/BulkUpdate/Messages/GetBulkUpdateRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations.BulkUpdate.Messages { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/ConvertData/ConvertDataRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/ConvertData/ConvertDataRequestHandler.cs index 3b8dc2e8f4..647cd2ae24 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/ConvertData/ConvertDataRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/ConvertData/ConvertDataRequestHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Configs; @@ -36,7 +36,7 @@ public ConvertDataRequestHandler( _convertDataConfiguration = convertDataConfiguration.Value; } - public async Task Handle(ConvertDataRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(ConvertDataRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CancelExportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CancelExportRequestHandler.cs index ab4e275eec..2c4d6fb0b1 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CancelExportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CancelExportRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; using Microsoft.Health.Core.Features.Security.Authorization; @@ -53,7 +53,7 @@ public CancelExportRequestHandler(IFhirOperationDataStore fhirOperationDataStore .WaitAndRetryAsync(retryCount, sleepDurationProvider); } - public async Task Handle(CancelExportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CancelExportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CreateExportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CreateExportRequestHandler.cs index a9af47ea38..c115442ac0 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CreateExportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/CreateExportRequestHandler.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Rest; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Features.Context; @@ -33,7 +33,7 @@ namespace Microsoft.Health.Fhir.Core.Features.Operations.Export { /// - /// MediatR request handler. Called when the ExportController creates an export job. + /// Medino request handler. Called when the ExportController creates an export job. /// public class CreateExportRequestHandler : IRequestHandler { @@ -74,7 +74,7 @@ public CreateExportRequestHandler( _includeValidateTypeFiltersValidationDetails = includeValidateTypeFiltersValidationDetails; } - public async Task Handle(CreateExportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateExportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/ExportJobTask.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/ExportJobTask.cs index 3cf1b94f49..5c5d212c6b 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/ExportJobTask.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/ExportJobTask.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; using AngleSharp.Text; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; @@ -369,7 +369,7 @@ private async Task CompleteJobAsync(OperationStatus completionStatus, Cancellati try { - await _mediator.Publish(new ExportTaskMetricsNotification(_exportJobRecord), cancellationToken); + await _mediator.PublishAsync(new ExportTaskMetricsNotification(_exportJobRecord), cancellationToken); } catch (ObjectDisposedException ode) { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/GetExportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/GetExportRequestHandler.cs index 6f329d4fa9..be7d163b8d 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/GetExportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Export/GetExportRequestHandler.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Operations.Export.Models; @@ -33,7 +33,7 @@ public GetExportRequestHandler(IFhirOperationDataStore fhirOperationDataStore, I _authorizationService = authorizationService; } - public async Task Handle(GetExportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetExportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CancelImportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CancelImportRequestHandler.cs index 0588aed6ad..df65b26814 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CancelImportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CancelImportRequestHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -36,7 +36,7 @@ public CancelImportRequestHandler(IQueueClient queueClient, IAuthorizationServic _logger = logger; } - public async Task Handle(CancelImportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CancelImportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CreateImportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CreateImportRequestHandler.cs index 70e4446f51..3ef55505f2 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CreateImportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/CreateImportRequestHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -18,7 +18,7 @@ namespace Microsoft.Health.Fhir.Core.Features.Operations.Import { /// - /// MediatR request handler. Called when the ImportController creates an Import job. + /// Medino request handler. Called when the ImportController creates an Import job. /// public class CreateImportRequestHandler : IRequestHandler { @@ -40,7 +40,7 @@ public CreateImportRequestHandler( _logger = logger; } - public async Task Handle(CreateImportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateImportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/GetImportRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/GetImportRequestHandler.cs index a4aa64ad29..7904b03a96 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/GetImportRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Import/GetImportRequestHandler.cs @@ -11,7 +11,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -36,7 +36,7 @@ public GetImportRequestHandler(IQueueClient queueClient, IAuthorizationService Handle(GetImportRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetImportRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/OperationDefinitionRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/OperationDefinitionRequestHandler.cs index acdacc2f1f..94d1a053e2 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/OperationDefinitionRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/OperationDefinitionRequestHandler.cs @@ -9,7 +9,7 @@ using EnsureThat; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Data; using Microsoft.Health.Fhir.Core.Extensions; using Microsoft.Health.Fhir.Core.Messages.Operation; @@ -29,7 +29,7 @@ public OperationDefinitionRequestHandler(IModelInfoProvider modelInfoProvider) _modelInfoProvider = modelInfoProvider; } - public async Task Handle(OperationDefinitionRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(OperationDefinitionRequest request, CancellationToken cancellationToken) { using Stream stream = DataLoader.OpenOperationDefinitionFileStream($"{request.OperationName}.json"); using TextReader reader = new StreamReader(stream); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CancelReindexRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CancelReindexRequestHandler.cs index 66cdd65776..e07abb4680 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CancelReindexRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CancelReindexRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -48,7 +48,7 @@ public CancelReindexRequestHandler(IFhirOperationDataStore fhirOperationDataStor .WaitAndRetryAsync(retryCount, sleepDurationProvider); } - public async Task Handle(CancelReindexRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CancelReindexRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CreateReindexRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CreateReindexRequestHandler.cs index f7120f765f..4d5bd676c9 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CreateReindexRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/CreateReindexRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Configs; @@ -50,7 +50,7 @@ public CreateReindexRequestHandler( _searchParameterOperations = searchParameterOperations; } - public async Task Handle(CreateReindexRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateReindexRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/GetReindexRequestHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/GetReindexRequestHandler.cs index 43569f7a35..90575d1c4c 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/GetReindexRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Reindex/GetReindexRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -32,7 +32,7 @@ public GetReindexRequestHandler(IFhirOperationDataStore fhirOperationDataStore, _authorizationService = authorizationService; } - public async Task Handle(GetReindexRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetReindexRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Operations/Validate/ValidateOperationHandler.cs b/src/Microsoft.Health.Fhir.Core/Features/Operations/Validate/ValidateOperationHandler.cs index 8162ffebf7..396dc0cb61 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Operations/Validate/ValidateOperationHandler.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Operations/Validate/ValidateOperationHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -39,7 +39,7 @@ public ValidateOperationHandler(IAuthorizationService authorization /// /// The request /// The CancellationToken - public async Task Handle(ValidateOperationRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(ValidateOperationRequest request, CancellationToken cancellationToken) { if (await _authorizationService.CheckAccess(DataActions.ResourceValidate, cancellationToken) != DataActions.ResourceValidate) { diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/CreateOrUpdateSearchParameterBehavior.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/CreateOrUpdateSearchParameterBehavior.cs index e14819b408..5d836cf5d3 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/CreateOrUpdateSearchParameterBehavior.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/CreateOrUpdateSearchParameterBehavior.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Messages.Create; @@ -31,7 +31,7 @@ public CreateOrUpdateSearchParameterBehavior(ISearchParameterOperations searchPa _fhirDataStore = fhirDataStore; } - public async Task Handle(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { if (request.Resource.InstanceType.Equals(KnownResourceTypes.SearchParameter, StringComparison.Ordinal)) { @@ -41,10 +41,10 @@ public async Task Handle(CreateResourceRequest request, } // Allow the resource to be updated with the normal handler - return await next(cancellationToken); + return await next(); } - public async Task Handle(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { // if the resource type being updated is a SearchParameter, then we want to query the previous version before it is changed // because we will need to the Url property to update the definition in the SearchParameterDefinitionManager @@ -79,7 +79,7 @@ public async Task Handle(UpsertResourceRequest request, } // Now allow the resource to updated per the normal behavior - return await next(cancellationToken); + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/DeleteSearchParameterBehavior.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/DeleteSearchParameterBehavior.cs index a89af97692..56d54b5d64 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/DeleteSearchParameterBehavior.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/Parameters/DeleteSearchParameterBehavior.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Messages.Delete; using Microsoft.Health.Fhir.Core.Models; @@ -29,7 +29,7 @@ public DeleteSearchParameterBehavior(ISearchParameterOperations searchParameterO _fhirDataStore = fhirDataStore; } - public async Task Handle(TDeleteResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(TDeleteResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { var deleteRequest = request as DeleteResourceRequest; ResourceWrapper searchParamResource = null; @@ -46,7 +46,7 @@ public async Task Handle(TDeleteResourceRequest request await _searchParameterOperations.DeleteSearchParameterAsync(searchParamResource.RawResource, cancellationToken); } - return await next(cancellationToken); + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/ISearchParameterStatusManager.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/ISearchParameterStatusManager.cs index 98f2a3174e..36360d6850 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/ISearchParameterStatusManager.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/ISearchParameterStatusManager.cs @@ -22,7 +22,7 @@ public interface ISearchParameterStatusManager Task> GetSearchParameterStatusUpdates(CancellationToken cancellationToken); - Task Handle(SearchParameterDefinitionManagerInitialized notification, CancellationToken cancellationToken); + Task HandleAsync(SearchParameterDefinitionManagerInitialized notification, CancellationToken cancellationToken); Task UpdateSearchParameterStatusAsync(IReadOnlyCollection searchParameterUris, SearchParameterStatus status, CancellationToken cancellationToken, bool ignoreSearchParameterNotSupportedException = false); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterCacheRefreshBackgroundService.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterCacheRefreshBackgroundService.cs index 403f9adcb7..ca88b78e6a 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterCacheRefreshBackgroundService.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterCacheRefreshBackgroundService.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -30,7 +30,9 @@ public class SearchParameterCacheRefreshBackgroundService : BackgroundService, I private readonly TimeSpan _refreshInterval; private readonly Timer _refreshTimer; private readonly SemaphoreSlim _refreshSemaphore; - private bool _isInitialized; + private volatile bool _isInitialized; + private volatile bool _serviceStopped; + private volatile bool _startAsyncCalled; private CancellationToken _stoppingToken; public SearchParameterCacheRefreshBackgroundService( @@ -57,9 +59,17 @@ public SearchParameterCacheRefreshBackgroundService( _refreshSemaphore = new SemaphoreSlim(1, 1); } + public override Task StartAsync(CancellationToken cancellationToken) + { + // Set flag and token before calling base.StartAsync + // This ensures HandleAsync can check if the service was started and if it was cancelled + _startAsyncCalled = true; + _stoppingToken = cancellationToken; + return base.StartAsync(cancellationToken); + } + protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - _stoppingToken = stoppingToken; _logger.LogInformation("SearchParameterCacheRefreshBackgroundService starting..."); try @@ -92,6 +102,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } finally { + _serviceStopped = true; + // Stop the timer when ExecuteAsync completes to prevent it from continuing to fire // after the service has stopped and potentially after service provider disposal _refreshTimer?.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan); @@ -167,14 +179,17 @@ private async void OnRefreshTimer(object state) } } - public async Task Handle(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) + public async Task HandleAsync(SearchParametersInitializedNotification notification, CancellationToken cancellationToken) { _logger.LogInformation("SearchParameters initialized. Starting cache refresh timer."); _isInitialized = true; - // Only start the timer if the service hasn't been cancelled - if (!_stoppingToken.IsCancellationRequested) + // Only start the timer if: + // 1. Service hasn't been stopped, AND + // 2. Either StartAsync was never called OR it was called but not cancelled + // This prevents starting the timer when StartAsync was called with a cancelled token + if (!_serviceStopped && (!_startAsyncCalled || !_stoppingToken.IsCancellationRequested)) { // Start the timer now that search parameters are initialized _refreshTimer.Change(TimeSpan.Zero, _refreshInterval); diff --git a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterStatusManager.cs b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterStatusManager.cs index 24d6f31959..40ba265d5f 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterStatusManager.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Search/Registry/SearchParameterStatusManager.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; using Microsoft.Health.Fhir.Core.Extensions; @@ -159,11 +159,11 @@ internal async Task EnsureInitializedAsync(CancellationToken cancellationToken) _logger.LogError("SearchParameterStatusManager: Sort status is not enabled {Environment.NewLine} {Message}", Environment.NewLine, string.Join($"{Environment.NewLine} ", disableSortIndicesList.Select(u => "Url : " + u.Url.ToString() + ", Sort status : " + u.SortStatus.ToString()))); } - await _mediator.Publish(new SearchParametersUpdatedNotification(updated), cancellationToken); - await _mediator.Publish(new SearchParametersInitializedNotification(), cancellationToken); + await _mediator.PublishAsync(new SearchParametersUpdatedNotification(updated), cancellationToken); + await _mediator.PublishAsync(new SearchParametersInitializedNotification(), cancellationToken); } - public async Task Handle(SearchParameterDefinitionManagerInitialized notification, CancellationToken cancellationToken) + public async Task HandleAsync(SearchParameterDefinitionManagerInitialized notification, CancellationToken cancellationToken) { _logger.LogInformation("SearchParameterStatusManager: Search parameter definition manager initialized"); await EnsureInitializedAsync(cancellationToken); @@ -232,7 +232,7 @@ public async Task UpdateSearchParameterStatusAsync(IReadOnlyCollection s await _searchParameterStatusDataStore.UpsertStatuses(searchParameterStatusList, cancellationToken); - await _mediator.Publish(new SearchParametersUpdatedNotification(updated), cancellationToken); + await _mediator.PublishAsync(new SearchParametersUpdatedNotification(updated), cancellationToken); } public async Task AddSearchParameterStatusAsync(IReadOnlyCollection searchParamUris, CancellationToken cancellationToken) @@ -304,7 +304,7 @@ public async Task ApplySearchParameterStatus(IReadOnlyCollection diff --git a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateBundlePreProcessor.cs b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateBundlePreProcessor.cs index c36bf62750..fae10350ee 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateBundlePreProcessor.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateBundlePreProcessor.cs @@ -4,24 +4,28 @@ // ------------------------------------------------------------------------------------------------- using System.Threading; -using MediatR.Pipeline; +using System.Threading.Tasks; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Messages.Bundle; using Microsoft.Health.Fhir.Core.Models; -using Task = System.Threading.Tasks.Task; namespace Microsoft.Health.Fhir.Core.Features.Validation { - public class ValidateBundlePreProcessor : IRequestPreProcessor + /// + /// Pipeline behavior that validates Bundle requests to ensure the request contains a valid Bundle resource. + /// Converted from IRequestPreProcessor to IPipelineBehavior in response to Medino API changes. + /// + public class ValidateBundlePreProcessor : IPipelineBehavior { - public Task Process(BundleRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(BundleRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { if (request.Bundle.InstanceType != KnownResourceTypes.Bundle) { throw new RequestNotValidException(Core.Resources.BundleRequiredForBatchOrTransaction); } - return Task.CompletedTask; + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateCapabilityPreProcessor.cs b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateCapabilityPreProcessor.cs index 3f3f559a97..ad116881fc 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateCapabilityPreProcessor.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateCapabilityPreProcessor.cs @@ -7,24 +7,30 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR.Pipeline; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Conformance; namespace Microsoft.Health.Fhir.Core.Features.Validation { - public class ValidateCapabilityPreProcessor : IRequestPreProcessor + /// + /// Generic pipeline behavior that validates requests requiring specific capabilities. + /// Converted from IRequestPreProcessor to IPipelineBehavior in response to Medino API changes. + /// + /// The type of request being validated. + /// The type of response returned by the handler. + public class ValidateCapabilityPreProcessor : IPipelineBehavior + where TRequest : class { private readonly IConformanceProvider _conformanceProvider; public ValidateCapabilityPreProcessor(IConformanceProvider conformanceProvider) { EnsureArg.IsNotNull(conformanceProvider, nameof(conformanceProvider)); - _conformanceProvider = conformanceProvider; } - public async Task Process(TRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { if (request is IRequireCapability provider) { @@ -33,6 +39,8 @@ public async Task Process(TRequest request, CancellationToken cancellationToken) throw new MethodNotAllowedException(Core.Resources.RequestedActionNotAllowed); } } + + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateRequestPreProcessor.cs b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateRequestPreProcessor.cs index 0fac292ec1..b61022e7c7 100644 --- a/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateRequestPreProcessor.cs +++ b/src/Microsoft.Health.Fhir.Core/Features/Validation/ValidateRequestPreProcessor.cs @@ -9,11 +9,17 @@ using System.Threading.Tasks; using EnsureThat; using FluentValidation; -using MediatR.Pipeline; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Validation { - public class ValidateRequestPreProcessor : IRequestPreProcessor + /// + /// Generic pipeline behavior that validates requests using FluentValidation validators. + /// Converted from IRequestPreProcessor to IPipelineBehavior in response to Medino API changes. + /// + /// The type of request being validated. + /// The type of response returned by the handler. + public class ValidateRequestPreProcessor : IPipelineBehavior where TRequest : class { private readonly IEnumerable> _validators; @@ -21,11 +27,10 @@ public class ValidateRequestPreProcessor : IRequestPreProcessor> validators) { EnsureArg.IsNotNull(validators, nameof(validators)); - _validators = validators; } - public async Task Process(TRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); @@ -35,6 +40,8 @@ public async Task Process(TRequest request, CancellationToken cancellationToken) { throw new ResourceNotValidException(allResults.SelectMany(x => x.Errors).ToList()); } + + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CancelImportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CancelImportRequest.cs index 8b38d1a2a4..e6e2ad09b8 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CancelImportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CancelImportRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Import { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CreateImportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CreateImportRequest.cs index 21a0f49acb..6df69c308e 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CreateImportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/CreateImportRequest.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.Import; using Microsoft.Health.Fhir.Core.Features.Operations.Import.Models; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/GetImportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/GetImportRequest.cs index 9d7bdba5b3..b2319d6831 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/GetImportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/BulkImport/GetImportRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Import { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Bundle/BundleRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Bundle/BundleRequest.cs index bf684b1400..5c37bbc007 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Bundle/BundleRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Bundle/BundleRequest.cs @@ -5,14 +5,14 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Messages.Bundle { - public class BundleRequest : IRequest, IRequest, IRequireCapability + public class BundleRequest : IRequest, IRequireCapability { public BundleRequest(ResourceElement bundle) { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/CapabilityStatement/RebuildCapabilityStatement.cs b/src/Microsoft.Health.Fhir.Core/Messages/CapabilityStatement/RebuildCapabilityStatement.cs index f158997220..715e80851a 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/CapabilityStatement/RebuildCapabilityStatement.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/CapabilityStatement/RebuildCapabilityStatement.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.CapabilityStatement { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Conditional/ConditionalResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Conditional/ConditionalResourceRequest.cs index cd80f45ec2..cdc6c03b70 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Conditional/ConditionalResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Conditional/ConditionalResourceRequest.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Messages.Bundle; using Microsoft.Health.Fhir.Core.Models; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Conformance/ExpandRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Conformance/ExpandRequest.cs index 8b1a5c1054..ee051f622e 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Conformance/ExpandRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Conformance/ExpandRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Conformance { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/ConvertData/ConvertDataRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/ConvertData/ConvertDataRequest.cs index 185fbcc6b2..2693d337ec 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/ConvertData/ConvertDataRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/ConvertData/ConvertDataRequest.cs @@ -5,7 +5,7 @@ using System; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Liquid.Converter.Models; namespace Microsoft.Health.Fhir.Core.Messages.ConvertData diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Create/CreateResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Create/CreateResourceRequest.cs index d3e13d3753..780e697042 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Create/CreateResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Create/CreateResourceRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Messages.Bundle; using Microsoft.Health.Fhir.Core.Messages.Upsert; @@ -13,7 +13,7 @@ namespace Microsoft.Health.Fhir.Core.Messages.Create { - public class CreateResourceRequest : BaseBundleInnerRequest, IRequest, IRequest, IRequireCapability + public class CreateResourceRequest : BaseBundleInnerRequest, IRequest, IRequireCapability { public CreateResourceRequest(ResourceElement resource, BundleResourceContext bundleResourceContext = null) : base(bundleResourceContext) diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Delete/DeleteResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Delete/DeleteResourceRequest.cs index 15ca876dc8..15b6753fed 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Delete/DeleteResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Delete/DeleteResourceRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Messages.Bundle; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Everything/EverythingOperationRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Everything/EverythingOperationRequest.cs index f007bb1eb1..74ff35c144 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Everything/EverythingOperationRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Everything/EverythingOperationRequest.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Messages.Everything diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Export/CancelExportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Export/CancelExportRequest.cs index c2753b8b2d..6155a4d4e6 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Export/CancelExportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Export/CancelExportRequest.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Export { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Export/CreateExportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Export/CreateExportRequest.cs index 4e76ff2ebe..e4265f3a91 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Export/CreateExportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Export/CreateExportRequest.cs @@ -5,7 +5,7 @@ using System; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations.Export; using Microsoft.Health.Fhir.Core.Models; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Export/GetExportRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Export/GetExportRequest.cs index 2b8fc5c2a6..32ce7e681d 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Export/GetExportRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Export/GetExportRequest.cs @@ -5,7 +5,7 @@ using System; using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Export { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetCapabilitiesRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetCapabilitiesRequest.cs index 1c93a8dbc7..03f2751723 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetCapabilitiesRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetCapabilitiesRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Get { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetOperationVersionsRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetOperationVersionsRequest.cs index 37213160ec..63258d45b2 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetOperationVersionsRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetOperationVersionsRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Get { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetResourceRequest.cs index 7afa9ac410..b467163673 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetResourceRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Messages.Bundle; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetSmartConfigurationRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetSmartConfigurationRequest.cs index 6fc553cb51..5210d85dc8 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Get/GetSmartConfigurationRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Get/GetSmartConfigurationRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Get { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/MemberMatch/MemberMatchRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/MemberMatch/MemberMatchRequest.cs index 80ad4a392b..ef63f7eb02 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/MemberMatch/MemberMatchRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/MemberMatch/MemberMatchRequest.cs @@ -3,12 +3,12 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Messages.MemberMatch { - public sealed class MemberMatchRequest : IRequest, IRequest + public sealed class MemberMatchRequest : IRequest { public MemberMatchRequest(ResourceElement coverage, ResourceElement patient) { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Operation/OperationDefinitionRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Operation/OperationDefinitionRequest.cs index 273e76298f..f95865ccdb 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Operation/OperationDefinitionRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Operation/OperationDefinitionRequest.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Operation { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Operation/ValidateOperationRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Operation/ValidateOperationRequest.cs index 9ceb8691e7..0c6196e53d 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Operation/ValidateOperationRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Operation/ValidateOperationRequest.cs @@ -5,12 +5,12 @@ using System; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Messages.Operation { - public class ValidateOperationRequest : IRequest, IRequest + public class ValidateOperationRequest : IRequest { public ValidateOperationRequest(ResourceElement resourceElement, Uri profile) { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Patch/PatchResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Patch/PatchResourceRequest.cs index 113872528d..7652b3f11c 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Patch/PatchResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Patch/PatchResourceRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Features.Resources.Patch; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CancelReindexRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CancelReindexRequest.cs index 0c2bff8738..ba6476765f 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CancelReindexRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CancelReindexRequest.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Reindex { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CreateReindexRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CreateReindexRequest.cs index ada05acb49..aec6cae8c3 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CreateReindexRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/CreateReindexRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Reindex { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/GetReindexRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/GetReindexRequest.cs index a40fb4cd88..dec49a3559 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/GetReindexRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/GetReindexRequest.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Reindex { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/ReindexSingleResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/ReindexSingleResourceRequest.cs index c4463e9c9b..cf46ba5f20 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/ReindexSingleResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/ReindexSingleResourceRequest.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Reindex { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/UpdateReindexRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/UpdateReindexRequest.cs index bc2ee20eaa..6e5f185b3d 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Reindex/UpdateReindexRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Reindex/UpdateReindexRequest.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations; namespace Microsoft.Health.Fhir.Core.Messages.Reindex diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchCompartmentRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchCompartmentRequest.cs index 95db349756..7f4eaa5e4a 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchCompartmentRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchCompartmentRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Search { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParameterDefinitionManagerInitialized.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParameterDefinitionManagerInitialized.cs index ba46732ff5..6e89f1efce 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParameterDefinitionManagerInitialized.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParameterDefinitionManagerInitialized.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Search { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersInitializedNotification.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersInitializedNotification.cs index 750671d18a..51d4b1660d 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersInitializedNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersInitializedNotification.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Search { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersUpdatedNotification.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersUpdatedNotification.cs index f3f2a2692f..a32b166be4 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersUpdatedNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchParametersUpdatedNotification.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Models; namespace Microsoft.Health.Fhir.Core.Messages.Search diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceHistoryRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceHistoryRequest.cs index 894e7757ee..d240a35866 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceHistoryRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceHistoryRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Models; diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceRequest.cs index f505fa952e..69b0295ad8 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Search/SearchResourceRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Search { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateRequest.cs index ad622b275d..e45d892a79 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.SearchParameterState { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateUpdateRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateUpdateRequest.cs index fb82d341b3..d65d8c7843 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateUpdateRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/SearchParameterState/SearchParameterStateUpdateRequest.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Search.Registry; namespace Microsoft.Health.Fhir.Core.Messages.SearchParameterState diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Storage/StorageInitializedNotification.cs b/src/Microsoft.Health.Fhir.Core/Messages/Storage/StorageInitializedNotification.cs index 09b6668e6d..8b08b27577 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Storage/StorageInitializedNotification.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Storage/StorageInitializedNotification.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Messages.Storage { diff --git a/src/Microsoft.Health.Fhir.Core/Messages/Upsert/UpsertResourceRequest.cs b/src/Microsoft.Health.Fhir.Core/Messages/Upsert/UpsertResourceRequest.cs index 0ed9557193..6ce530f4d2 100644 --- a/src/Microsoft.Health.Fhir.Core/Messages/Upsert/UpsertResourceRequest.cs +++ b/src/Microsoft.Health.Fhir.Core/Messages/Upsert/UpsertResourceRequest.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Conformance; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Messages.Bundle; @@ -13,7 +13,7 @@ namespace Microsoft.Health.Fhir.Core.Messages.Upsert { - public class UpsertResourceRequest : BaseBundleInnerRequest, IRequest, IRequest, IRequireCapability + public class UpsertResourceRequest : BaseBundleInnerRequest, IRequest, IRequireCapability { public UpsertResourceRequest(ResourceElement resource, BundleResourceContext bundleResourceContext = null, WeakETag weakETag = null, bool metaHistory = true) : base(bundleResourceContext) diff --git a/src/Microsoft.Health.Fhir.Core/Microsoft.Health.Fhir.Core.csproj b/src/Microsoft.Health.Fhir.Core/Microsoft.Health.Fhir.Core.csproj index ae11d5ed8e..258512f229 100644 --- a/src/Microsoft.Health.Fhir.Core/Microsoft.Health.Fhir.Core.csproj +++ b/src/Microsoft.Health.Fhir.Core/Microsoft.Health.Fhir.Core.csproj @@ -45,7 +45,7 @@ - + diff --git a/src/Microsoft.Health.Fhir.CosmosDb.Initialization/Features/Storage/ResourceManagerCollectionSetup.cs b/src/Microsoft.Health.Fhir.CosmosDb.Initialization/Features/Storage/ResourceManagerCollectionSetup.cs index 4f08b2eb1c..71b034e6c6 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb.Initialization/Features/Storage/ResourceManagerCollectionSetup.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb.Initialization/Features/Storage/ResourceManagerCollectionSetup.cs @@ -186,9 +186,11 @@ public async Task InstallStoredProcs(CancellationToken cancellationToken) CosmosDBSqlContainerResource containerResponse = await Database.GetCosmosDBSqlContainers().GetAsync(CollectionId, cancellationToken); CosmosDBSqlStoredProcedureCollection cosmosDbSqlStoredProcedures = containerResponse.GetCosmosDBSqlStoredProcedures(); - var existing = cosmosDbSqlStoredProcedures - .Select(x => x.Data.Resource.StoredProcedureName) - .ToList(); + var existing = new List(); + await foreach (var item in cosmosDbSqlStoredProcedures.WithCancellation(cancellationToken)) + { + existing.Add(item.Data.Resource.StoredProcedureName); + } var storedProcsNeedingInstall = _storeProceduresMetadata .Where(storedProc => !existing.Contains(storedProc.FullName)) diff --git a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/CosmosResponseProcessorTests.cs b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/CosmosResponseProcessorTests.cs index 6cf482ac0f..819ae5ba97 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/CosmosResponseProcessorTests.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/CosmosResponseProcessorTests.cs @@ -9,7 +9,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Primitives; @@ -189,7 +189,7 @@ private void ValidateExecution(string expectedSessionToken, double expectedReque Assert.True(_responseHeaders.TryGetValue(CosmosDbHeaders.RequestCharge, out StringValues requestCharge)); Assert.Equal(expectedRequestCharge.ToString(CultureInfo.InvariantCulture), requestCharge.ToString()); - _mediator.Received(1).Publish(Arg.Is(c => c.TotalRequestCharge.Equals(expectedRequestCharge) + _mediator.Received(1).PublishAsync(Arg.Is(c => c.TotalRequestCharge.Equals(expectedRequestCharge) && c.IsThrottled.Equals(expectedThrottled) && c.ResourceType.Equals("resource", StringComparison.InvariantCultureIgnoreCase) && c.FhirOperation.Equals("operation", StringComparison.InvariantCultureIgnoreCase))); diff --git a/src/Microsoft.Health.Fhir.CosmosDb/Features/Metrics/CosmosStorageRequestMetricsNotification.cs b/src/Microsoft.Health.Fhir.CosmosDb/Features/Metrics/CosmosStorageRequestMetricsNotification.cs index 140be8dce5..f772f3f052 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb/Features/Metrics/CosmosStorageRequestMetricsNotification.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb/Features/Metrics/CosmosStorageRequestMetricsNotification.cs @@ -8,7 +8,7 @@ namespace Microsoft.Health.Fhir.CosmosDb.Features.Metrics { /// - /// A MediatR notification containing statistics about Cosmos DB usage while handling a request. + /// A Medino notification containing statistics about Cosmos DB usage while handling a request. /// public class CosmosStorageRequestMetricsNotification : IMetricsNotification { diff --git a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosContainerProvider.cs b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosContainerProvider.cs index e6219c6d64..01cadf5561 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosContainerProvider.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosContainerProvider.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -177,7 +177,8 @@ public Task StartAsync(CancellationToken cancellationToken) // The result is ignored and will be awaited in EnsureInitialized(). Exceptions are logged within CosmosClientInitializer. _initializationOperation.EnsureInitialized() .AsTask() - .ContinueWith(_ => _mediator.Publish(new StorageInitializedNotification(), CancellationToken.None), TaskScheduler.Default); + .ContinueWith(_ => _mediator.PublishAsync(new StorageInitializedNotification(), CancellationToken.None), TaskScheduler.Default) + .Unwrap(); #pragma warning restore CS4014 return Task.CompletedTask; diff --git a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosResponseProcessor.cs b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosResponseProcessor.cs index cec0192ed8..b7be24b7e9 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosResponseProcessor.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb/Features/Storage/CosmosResponseProcessor.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos; using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; @@ -191,7 +191,7 @@ private async Task AddRequestChargeToFhirRequestContextAsync(double responseRequ try { - await _mediator.Publish(cosmosMetrics, cancellationToken); + await _mediator.PublishAsync(cosmosMetrics, cancellationToken); } catch (ObjectDisposedException ode) { @@ -277,7 +277,7 @@ private async Task EmitExceptionNotificationAsync(HttpStatusCode statusCode, Exc exceptionNotification.IsRequestRateExceeded = exception.IsRequestRateExceeded(); exceptionNotification.BaseException = exception; - await _mediator.Publish(exceptionNotification, cancellationToken); + await _mediator.PublishAsync(exceptionNotification, cancellationToken); } catch (ObjectDisposedException ode) { diff --git a/src/Microsoft.Health.Fhir.CosmosDb/Registration/FhirServerBuilderCosmosDbRegistrationExtensions.cs b/src/Microsoft.Health.Fhir.CosmosDb/Registration/FhirServerBuilderCosmosDbRegistrationExtensions.cs index 796c5e5666..1d9622c68d 100644 --- a/src/Microsoft.Health.Fhir.CosmosDb/Registration/FhirServerBuilderCosmosDbRegistrationExtensions.cs +++ b/src/Microsoft.Health.Fhir.CosmosDb/Registration/FhirServerBuilderCosmosDbRegistrationExtensions.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; diff --git a/src/Microsoft.Health.Fhir.R4.Api/Microsoft.Health.Fhir.R4.Api.csproj b/src/Microsoft.Health.Fhir.R4.Api/Microsoft.Health.Fhir.R4.Api.csproj index 7f1a8335e2..66adc5e889 100644 --- a/src/Microsoft.Health.Fhir.R4.Api/Microsoft.Health.Fhir.R4.Api.csproj +++ b/src/Microsoft.Health.Fhir.R4.Api/Microsoft.Health.Fhir.R4.Api.csproj @@ -14,7 +14,8 @@ - + + diff --git a/src/Microsoft.Health.Fhir.R4.Core/Microsoft.Health.Fhir.R4.Core.csproj b/src/Microsoft.Health.Fhir.R4.Core/Microsoft.Health.Fhir.R4.Core.csproj index 1c59f0776f..fb2c8cc881 100644 --- a/src/Microsoft.Health.Fhir.R4.Core/Microsoft.Health.Fhir.R4.Core.csproj +++ b/src/Microsoft.Health.Fhir.R4.Core/Microsoft.Health.Fhir.R4.Core.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Microsoft.Health.Fhir.R4B.Api/Microsoft.Health.Fhir.R4B.Api.csproj b/src/Microsoft.Health.Fhir.R4B.Api/Microsoft.Health.Fhir.R4B.Api.csproj index 0a7008abe5..7b7fee729b 100644 --- a/src/Microsoft.Health.Fhir.R4B.Api/Microsoft.Health.Fhir.R4B.Api.csproj +++ b/src/Microsoft.Health.Fhir.R4B.Api/Microsoft.Health.Fhir.R4B.Api.csproj @@ -11,7 +11,8 @@ - + + diff --git a/src/Microsoft.Health.Fhir.R4B.Core/Microsoft.Health.Fhir.R4B.Core.csproj b/src/Microsoft.Health.Fhir.R4B.Core/Microsoft.Health.Fhir.R4B.Core.csproj index 88695880a5..3f1568628c 100644 --- a/src/Microsoft.Health.Fhir.R4B.Core/Microsoft.Health.Fhir.R4B.Core.csproj +++ b/src/Microsoft.Health.Fhir.R4B.Core/Microsoft.Health.Fhir.R4B.Core.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Microsoft.Health.Fhir.R5.Api/Microsoft.Health.Fhir.R5.Api.csproj b/src/Microsoft.Health.Fhir.R5.Api/Microsoft.Health.Fhir.R5.Api.csproj index 3968f9186f..ce037bd62c 100644 --- a/src/Microsoft.Health.Fhir.R5.Api/Microsoft.Health.Fhir.R5.Api.csproj +++ b/src/Microsoft.Health.Fhir.R5.Api/Microsoft.Health.Fhir.R5.Api.csproj @@ -11,7 +11,8 @@ - + + diff --git a/src/Microsoft.Health.Fhir.R5.Core/Microsoft.Health.Fhir.R5.Core.csproj b/src/Microsoft.Health.Fhir.R5.Core/Microsoft.Health.Fhir.R5.Core.csproj index 0f67b2f304..61ca1e3c2b 100644 --- a/src/Microsoft.Health.Fhir.R5.Core/Microsoft.Health.Fhir.R5.Core.csproj +++ b/src/Microsoft.Health.Fhir.R5.Core/Microsoft.Health.Fhir.R5.Core.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Microsoft.Health.Fhir.SchemaManager/SchemaManagerServiceCollectionBuilder.cs b/src/Microsoft.Health.Fhir.SchemaManager/SchemaManagerServiceCollectionBuilder.cs index 6a2e88bbb5..f536733a62 100644 --- a/src/Microsoft.Health.Fhir.SchemaManager/SchemaManagerServiceCollectionBuilder.cs +++ b/src/Microsoft.Health.Fhir.SchemaManager/SchemaManagerServiceCollectionBuilder.cs @@ -49,7 +49,8 @@ public static IServiceCollection AddSchemaManager(this IServiceCollection servic services.AddSingleton(); services.AddSingleton(); - services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(SchemaUpgradedNotification).Assembly)); + // TODO: AddMedino extension method not available in Medino 3.0.2 - may need alternative registration + // services.AddMedino(cfg => cfg.RegisterServicesFromAssembly(typeof(SchemaUpgradedNotification).Assembly)); services.AddSingleton(); services.AddSingleton(); diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ConvertDataControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ConvertDataControllerTests.cs index a191bd7b2f..7c6e588489 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ConvertDataControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ConvertDataControllerTests.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Api.Controllers; @@ -159,7 +159,7 @@ public async Task GivenAConvertDataRequest_WithNotConfiguredTemplate_WhenValidBo [InlineData("abc.azurecr.io", "template", "sha256:123abc", "abc.azurecr.io/template@sha256:123abc")] public async Task GivenAConvertDataRequest_WithConfiguredTemplate_WhenValidBodySent_ThenConvertDataCalledWithCorrectParams(string loginServer, string imageName, string digest, string templateCollectionReference) { - _mediator.Send(Arg.Any()).Returns(Task.FromResult(GetConvertDataResponse())); + _mediator.SendAsync(Arg.Any()).Returns(Task.FromResult(GetConvertDataResponse())); var ociArtifactInfo = new OciArtifactInfo { @@ -174,7 +174,7 @@ public async Task GivenAConvertDataRequest_WithConfiguredTemplate_WhenValidBodyS var body = GetConvertDataParams(Samples.SampleHl7v2Message, "Hl7v2", templateCollectionReference, _testHl7v2RootTemplate); await localController.ConvertData(body); - await _mediator.Received().Send( + await _mediator.Received().SendAsync( Arg.Is( r => r.InputData.ToString().Equals(body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputData)).Value.ToString()) && string.Equals(r.InputDataType.ToString(), body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputDataType)).Value.ToString(), StringComparison.OrdinalIgnoreCase) @@ -192,9 +192,9 @@ await _mediator.Received().Send( public async Task GivenAConvertDataRequest_WithValidBody_ThenConvertDataCalledWithCorrectParams(Parameters body) { var treatDatesAsStrings = body.GetSingleValue(ConvertDataProperties.JsonDeserializationTreatDatesAsStrings) ?? new FhirBoolean(); - _mediator.Send(Arg.Any()).Returns(Task.FromResult(GetConvertDataResponse())); + _mediator.SendAsync(Arg.Any()).Returns(Task.FromResult(GetConvertDataResponse())); await _convertDataEnabledController.ConvertData(body); - await _mediator.Received().Send( + await _mediator.Received().SendAsync( Arg.Is( r => r.InputData.ToString().Equals(body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputData)).Value.ToString()) && string.Equals(r.InputDataType.ToString(), body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputDataType)).Value.ToString(), StringComparison.OrdinalIgnoreCase) diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/EverythingControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/EverythingControllerTests.cs index 301f21af6b..df7d63bc27 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/EverythingControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/EverythingControllerTests.cs @@ -6,7 +6,7 @@ using System; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Health.Core.Features.Context; @@ -47,7 +47,7 @@ public EverythingControllerTests() [Fact] public async Task GivenAnEverythingOperationRequest_WhenValid_ThenProperResponseShouldBeReturned() { - _mediator.Send(Arg.Any(), Arg.Any()).Returns(Task.FromResult(GetEverythingOperationResponse())); + _mediator.SendAsync(Arg.Any(), Arg.Any()).Returns(Task.FromResult(GetEverythingOperationResponse())); var result = await _everythingController.PatientEverythingById( idParameter: "123", @@ -57,7 +57,7 @@ public async Task GivenAnEverythingOperationRequest_WhenValid_ThenProperResponse type: ResourceType.Observation.ToString(), ct: null) as FhirResult; - await _mediator.Received().Send( + await _mediator.Received().SendAsync( Arg.Is( r => string.Equals(r.EverythingOperationType, ResourceType.Patient.ToString(), StringComparison.Ordinal) && string.Equals(r.ResourceId.ToString(), "123", StringComparison.OrdinalIgnoreCase) diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ExportControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ExportControllerTests.cs index a03fbb5184..0639f1c9a6 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ExportControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ExportControllerTests.cs @@ -8,7 +8,7 @@ using System.Threading; using Hl7.Fhir.Model; using Hl7.Fhir.Rest; -using MediatR; +using Medino; using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -326,7 +326,7 @@ public async Task GivenASystemLevelExport_WhenRequestSentToMediator_CorrectIsPar // Mock mediator call for CreateExportRequest - throw exception to fail test if we get unexpected value. _mediator - .Send(Arg.Any(), Arg.Any()) + .SendAsync(Arg.Any(), Arg.Any()) .Returns(callInfo => { var request = callInfo.Arg(); diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/FhirControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/FhirControllerTests.cs index d059d088b5..5e5878220e 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/FhirControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/FhirControllerTests.cs @@ -8,7 +8,7 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -56,11 +56,11 @@ public FhirControllerTests() _configuration.Value.Returns(new FeatureConfiguration()); _authorizationService = Substitute.For(); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns(Task.FromResult(new DeleteResourceResponse(new ResourceKey(KnownResourceTypes.Patient, Guid.NewGuid().ToString())))); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns(Task.FromResult(new DeleteResourceResponse(new ResourceKey(KnownResourceTypes.Patient, Guid.NewGuid().ToString())))); @@ -152,7 +152,7 @@ public async Task GivenConditionalDeleteResourceRequest_WhenHardDeleteFlagProvid }; await _fhirController.ConditionalDelete(KnownResourceTypes.Patient, hardDeleteModel, null); - await _mediator.Received(1).Send( + await _mediator.Received(1).SendAsync( Arg.Is(x => x.DeleteOperation == operation), Arg.Any()); } @@ -172,7 +172,7 @@ public async Task GivenDeleteResourceRequest_WhenHardDeleteFlagProvided_HardDele }; await _fhirController.Delete(KnownResourceTypes.Patient, Guid.NewGuid().ToString(), hardDeleteModel, false); - await _mediator.Received(1).Send( + await _mediator.Received(1).SendAsync( Arg.Is(x => x.DeleteOperation == operation), Arg.Any()); } diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ImportControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ImportControllerTests.cs index 17993847d0..3236b69762 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ImportControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ImportControllerTests.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Features.Context; diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/MemberMatchControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/MemberMatchControllerTests.cs index c2f6055688..a7519d7fd8 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/MemberMatchControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/MemberMatchControllerTests.cs @@ -7,7 +7,7 @@ using System.Threading; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging.Abstractions; @@ -65,7 +65,7 @@ public async Task GivenAMemberMatchDataRequest_WhenInvalidBodySent_ThenRequestNo [MemberData(nameof(ValidBody), MemberType = typeof(MemberMatchControllerTests))] public async Task GivenAMemberMatchDataRequest_WithValidBody_ThenMemberMatchCalledWithCorrectParams(Parameters body) { - _mediator.Send(Arg.Any(), Arg.Any()).Returns(GetMemberMatchResponse()); + _mediator.SendAsync(Arg.Any(), Arg.Any()).Returns(GetMemberMatchResponse()); var result = await _memberMatchController.MemberMatch(body) as MemberMatchResult; Assert.NotNull(result); Assert.Equal(System.Net.HttpStatusCode.OK, result.StatusCode); diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ReindexControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ReindexControllerTests.cs index 03a3efb4a5..5a44c4f528 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ReindexControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/ReindexControllerTests.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging.Abstractions; @@ -84,11 +84,11 @@ public async Task GivenAGetReindexRequest_WhenDisabled_ThenRequestNotValidExcept [Fact] public async Task GivenAGetReindexRequest_WhenJobExists_ThenParammetersResourceReturned() { - _mediator.Send(Arg.Any()).Returns(Task.FromResult(GetReindexJobResponse())); + _mediator.SendAsync(Arg.Any()).Returns(Task.FromResult(GetReindexJobResponse())); var result = await _reindexEnabledController.GetReindexJob("id"); - await _mediator.Received().Send( + await _mediator.Received().SendAsync( Arg.Is(r => r.JobId == "id"), Arg.Any()); var parametersResource = (((FhirResult)result).Result as ResourceElement).ResourceInstance as Parameters; @@ -100,7 +100,7 @@ await _mediator.Received().Send( public async Task GivenACreateReindexRequest_WhenInvalidBodySent_ThenJobIsCreatedSuccessfully(Parameters body) { _reindexEnabledController.ControllerContext.HttpContext.Request.Method = HttpMethods.Post; - _mediator.Send(Arg.Any()).Returns(Task.FromResult(GetCreateReindexResponse())); + _mediator.SendAsync(Arg.Any()).Returns(Task.FromResult(GetCreateReindexResponse())); // Should NOT throw an exception - invalid parameters are now logged but don't cause failures var result = await _reindexEnabledController.CreateReindexJob(body); @@ -116,9 +116,9 @@ public async Task GivenACreateReindexRequest_WhenInvalidBodySent_ThenJobIsCreate public async Task GivenACreateReindexRequest_WithValidBody_ThenCreateReindexJobCalledWithCorrectParams(Parameters body) { _reindexEnabledController.ControllerContext.HttpContext.Request.Method = HttpMethods.Post; - _mediator.Send(Arg.Any()).Returns(Task.FromResult(GetCreateReindexResponse())); + _mediator.SendAsync(Arg.Any()).Returns(Task.FromResult(GetCreateReindexResponse())); var result = await _reindexEnabledController.CreateReindexJob(body); - await _mediator.Received().Send( + await _mediator.Received().SendAsync( Arg.Is( r => true), Arg.Any()); diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/SearchParameterControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/SearchParameterControllerTests.cs index 141cd14bb9..d13b900146 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/SearchParameterControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/SearchParameterControllerTests.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; @@ -47,8 +47,8 @@ public SearchParameterControllerTests() { var controllerContext = new ControllerContext() { HttpContext = _httpContext }; _coreFeaturesConfiguration.SupportsSelectableSearchParameters = true; - _mediator.Send(Arg.Any(), default(CancellationToken)).Returns(new SearchParameterStateResponse()); - _mediator.Send(Arg.Any(), default(CancellationToken)).Returns(new SearchParameterStateUpdateResponse()); + _mediator.SendAsync(Arg.Any(), default(CancellationToken)).Returns(new SearchParameterStateResponse()); + _mediator.SendAsync(Arg.Any(), default(CancellationToken)).Returns(new SearchParameterStateUpdateResponse()); _controller = new SearchParameterController( _mediator, Options.Create(_coreFeaturesConfiguration), @@ -80,7 +80,7 @@ public async Task GivenASearchParameterStatusRequest_WhenSupportsSelectableSearc { } - await _mediator.Received(1).Send(Arg.Any(), default(CancellationToken)); + await _mediator.Received(1).SendAsync(Arg.Any(), default(CancellationToken)); } [Fact] @@ -130,7 +130,7 @@ public async Task GivenAValidRequestBody_WhenParsingRequestBody_MediatorShouldBe { } - await _mediator.Received(1).Send(Arg.Any(), default(CancellationToken)); + await _mediator.Received(1).SendAsync(Arg.Any(), default(CancellationToken)); } [Fact] @@ -145,7 +145,7 @@ public async Task GivenAValidRequestBody_WhenParsingRequestBody_MediatorShouldBe { } - await _mediator.Received(1).Send(Arg.Is(x => x.SearchParameters.Any(sp => sp.Item1 == new Uri(DummyUrl) && sp.Item2 == SearchParameterStatus.Disabled)), default(CancellationToken)); + await _mediator.Received(1).SendAsync(Arg.Is(x => x.SearchParameters.Any(sp => sp.Item1 == new Uri(DummyUrl) && sp.Item2 == SearchParameterStatus.Disabled)), default(CancellationToken)); } [Theory] diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/TerminologyControllerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/TerminologyControllerTests.cs index 3e4c75992b..5330c208ba 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/TerminologyControllerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Controllers/TerminologyControllerTests.cs @@ -9,7 +9,7 @@ using System.Web; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Controllers; @@ -40,7 +40,7 @@ public class TerminologyControllerTests public TerminologyControllerTests() { _mediator = Substitute.For(); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns(new ExpandResponse(new ValueSet().ToResourceElement())); @@ -107,7 +107,7 @@ public async Task GivenRequest_WhenExpanding_ThenRequestShouldBeSentToHandler( Assert.False(enable); } - await _mediator.Received(enable ? 1 : 0).Send( + await _mediator.Received(enable ? 1 : 0).SendAsync( Arg.Any(), Arg.Any()); } @@ -133,7 +133,7 @@ public async Task GivenGetRequest_WhenExpanding_ThenCorrectRequestShouldBeSentTo bool valid, bool useId) { - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns( @@ -171,7 +171,7 @@ public async Task GivenGetRequest_WhenExpanding_ThenCorrectRequestShouldBeSentTo Assert.False(valid); } - await _mediator.Received(valid ? 1 : 0).Send( + await _mediator.Received(valid ? 1 : 0).SendAsync( Arg.Any(), Arg.Any()); } @@ -182,7 +182,7 @@ public async Task GivenPostRequest_WhenExpanding_ThenCorrectRequestShouldBeSentT Parameters parameters, bool valid) { - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns( @@ -211,7 +211,7 @@ public async Task GivenPostRequest_WhenExpanding_ThenCorrectRequestShouldBeSentT Assert.False(valid); } - await _mediator.Received(valid ? 1 : 0).Send( + await _mediator.Received(valid ? 1 : 0).SendAsync( Arg.Any(), Arg.Any()); } diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/ApiNotifications/ApiNotificationMiddlewareTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/ApiNotifications/ApiNotificationMiddlewareTests.cs index 92e74e1404..7061143fcb 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/ApiNotifications/ApiNotificationMiddlewareTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/ApiNotifications/ApiNotificationMiddlewareTests.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core.Features.Context; @@ -49,41 +49,41 @@ public async Task GivenRequestPath_WhenInvoked_DoesNotLogForHealthCheck() await _apiNotificationMiddleware.InvokeAsync(_httpContext, _next); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + // Verify PublishAsync was not called (Medino requires INotification type) } [Fact] - public async Task GivenAuditEventTypeNotNull_WhenInvoked_EmitsMediatRApiAndStorageEvents() + public async Task GivenAuditEventTypeNotNull_WhenInvoked_EmitsMedinoApiAndStorageEvents() { _httpContext.Request.Path = "/Observation"; _fhirRequestContext.AuditEventType = "read"; await _apiNotificationMiddleware.InvokeAsync(_httpContext, _next); - await _mediator.ReceivedWithAnyArgs(1).Publish(Arg.Any(), Arg.Any()); + await _mediator.ReceivedWithAnyArgs(1).PublishAsync(Arg.Any(), Arg.Any()); } [Fact] - public async Task GivenRequestPath_AndNullFhirRequestContext_WhenInvoked_DoesNotFail_AndDoesNotEmitMediatREvents() + public async Task GivenRequestPath_AndNullFhirRequestContext_WhenInvoked_DoesNotFail_AndDoesNotEmitMedinoEvents() { _fhirRequestContextAccessor.RequestContext.Returns((IFhirRequestContext)null); _httpContext.Request.Path = "/Observation"; await _apiNotificationMiddleware.InvokeAsync(_httpContext, _next); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + // Verify PublishAsync was not called (Medino requires INotification type) } [Fact] - public async Task GivenRequestPath_WhenMediatRFails_NoExceptionIsThrown() + public async Task GivenRequestPath_WhenMedinoFails_NoExceptionIsThrown() { await Task.CompletedTask; - _mediator.WhenForAnyArgs(async x => await x.Publish(Arg.Any(), Arg.Any())).Throw(new System.Exception("Failure")); + _mediator.WhenForAnyArgs(async x => await x.PublishAsync(Arg.Any(), Arg.Any())).Throw(new System.Exception("Failure")); _httpContext.Request.Path = "/Observation"; await _apiNotificationMiddleware.InvokeAsync(_httpContext, _next); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + // Verify PublishAsync was not called (Medino requires INotification type) } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Exceptions/ExceptionNotificationMiddlewareTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Exceptions/ExceptionNotificationMiddlewareTests.cs index 402d212c97..b012fe4326 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Exceptions/ExceptionNotificationMiddlewareTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Exceptions/ExceptionNotificationMiddlewareTests.cs @@ -6,7 +6,7 @@ using System; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core.Features.Context; @@ -34,7 +34,7 @@ public ExceptionNotificationMiddlewareTests() } [Fact] - public async Task GivenAnHttpContextWithException_WhenExecutingExceptionNotificationMiddleware_MediatRShouldEmitNotification() + public async Task GivenAnHttpContextWithException_WhenExecutingExceptionNotificationMiddleware_MedinoShouldEmitNotification() { var exceptionMessage = "Test exception"; var exceptionNotificationMiddleware = CreateExceptionNotificationMiddleware(innerHttpContext => throw new Exception(exceptionMessage)); @@ -45,29 +45,30 @@ public async Task GivenAnHttpContextWithException_WhenExecutingExceptionNotifica } catch (Exception e) { - await _mediator.ReceivedWithAnyArgs(1).Publish(Arg.Any(), Arg.Any()); + await _mediator.ReceivedWithAnyArgs(1).PublishAsync(Arg.Any(), Arg.Any()); Assert.Equal(exceptionMessage, e.Message); } } [Fact] - public async Task GivenAnHttpContextWithNoException_WhenExecutingExceptionNotificationMiddleware_MediatRShouldNotEmitNotification() + public async Task GivenAnHttpContextWithNoException_WhenExecutingExceptionNotificationMiddleware_MedinoShouldNotEmitNotification() { var exceptionNotificationMiddleware = CreateExceptionNotificationMiddleware(innerHttpContext => Task.CompletedTask); await exceptionNotificationMiddleware.Invoke(_context); - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + // Verify PublishAsync was not called (Medino requires INotification type) } [Fact] - public async Task WhenMediatRFails_OriginalExceptionStillThrown() + public async Task WhenMedinoFails_OriginalExceptionStillThrown() { var exceptionMessage = "Test exception"; - var mediatorExceptionMessage = "Mediator Failure"; var exceptionNotificationMiddleware = CreateExceptionNotificationMiddleware(innerHttpContext => throw new Exception(exceptionMessage)); - _mediator.WhenForAnyArgs(async x => await x.Publish(Arg.Any(), Arg.Any())).Throw(new System.Exception(mediatorExceptionMessage)); + + // Note: Medino requires INotification type parameter, not arbitrary types + // _mediator.WhenForAnyArgs(async x => await x.PublishAsync(Arg.Any(), Arg.Any())).Throw(new System.Exception(mediatorExceptionMessage)); try { @@ -75,7 +76,7 @@ public async Task WhenMediatRFails_OriginalExceptionStillThrown() } catch (Exception e) { - await _mediator.DidNotReceiveWithAnyArgs().Publish(Arg.Any(), Arg.Any()); + // Verify PublishAsync was not called (Medino requires INotification type) Assert.Equal(exceptionMessage, e.Message); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Health/StorageInitializedHealthCheckTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Health/StorageInitializedHealthCheckTests.cs index f739e694fa..7cb0017f89 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Health/StorageInitializedHealthCheckTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Health/StorageInitializedHealthCheckTests.cs @@ -34,7 +34,7 @@ public StorageInitializedHealthCheckTests() [Fact] public async Task GivenStorageInitialized_WhenCheckHealthAsync_ThenReturnsHealthy() { - await _sut.Handle(new SearchParametersInitializedNotification(), CancellationToken.None); + await _sut.HandleAsync(new SearchParametersInitializedNotification(), CancellationToken.None); HealthCheckResult result = await _sut.CheckHealthAsync(new HealthCheckContext(), CancellationToken.None); diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerEdgeCaseTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerEdgeCaseTests.cs index d58e91e88e..ffbce25ea0 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerEdgeCaseTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerEdgeCaseTests.cs @@ -6,7 +6,7 @@ using System; using System.Collections.Generic; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs index f2a1264450..6fd949b39a 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/Bundle/BundleHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -10,7 +10,7 @@ using System.Threading; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Http.Features.Authentication; @@ -152,7 +152,7 @@ public async Task GivenAnEmptyBatchBundle_WhenProcessed_ReturnsABundleResponseWi var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, CancellationToken.None); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, CancellationToken.None); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.BatchResponse, bundleResource.Type); @@ -187,7 +187,7 @@ public async Task GivenABundleWithAGet_WhenNotAuthorized_ReturnsABundleResponseW var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, CancellationToken.None); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, CancellationToken.None); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.BatchResponse, bundleResource.Type); @@ -252,7 +252,7 @@ public async Task GivenABundle_WhenMultipleRequests_ReturnsABundleResponseWithCo .Do(RouteAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.BatchResponse, bundleResource.Type); @@ -346,7 +346,7 @@ public async Task GivenABundle_WithMultipleProfileChanges_OnlyExecuteProfileRefr .Do(localAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.BatchResponse, bundleResource.Type); @@ -394,7 +394,7 @@ public async Task GivenABundle_WithASingleRecordAndSequential_ProcessItAsABundle .Do(localAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.TransactionResponse, bundleResource.Type); @@ -448,7 +448,7 @@ public async Task GivenATransaction_WithACrashDuringCSharpTransaction_ReturnAPro .Do(localAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - FhirTransactionFailedException fhirTfe = await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, default)); + FhirTransactionFailedException fhirTfe = await Assert.ThrowsAsync(async () => await _bundleHandler.HandleAsync(bundleRequest, default)); Assert.True(fhirTfe.ResponseStatusCode == System.Net.HttpStatusCode.InternalServerError); } @@ -489,7 +489,7 @@ public async Task GivenATransaction_WithACancellationHappens_ReturnAProperError( // As the cancellation is requested during the bundle execution and the before the max transaction time, a FhirTransactionCancelledException is expected. // Resulting in a HTTP408 error. - FhirTransactionCancelledException fhirTce = await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, cancellationToken)); + FhirTransactionCancelledException fhirTce = await Assert.ThrowsAsync(async () => await _bundleHandler.HandleAsync(bundleRequest, cancellationToken)); Assert.True(fhirTce.ResponseStatusCode == System.Net.HttpStatusCode.RequestTimeout); } } @@ -519,7 +519,7 @@ public async Task GivenATransactionBundleRequestWithNullUrl_WhenProcessing_Retur var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, default)); + await Assert.ThrowsAsync(async () => await _bundleHandler.HandleAsync(bundleRequest, default)); } [Fact] @@ -546,7 +546,7 @@ public async Task GivenATransactionBundleRequestWithNullRequestMethod_WhenProces .Do(RouteAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, default)); + await Assert.ThrowsAsync(async () => await _bundleHandler.HandleAsync(bundleRequest, default)); } [Fact] @@ -577,7 +577,7 @@ public async Task GivenABundle_WhenProcessed_CertainResponseHeadersArePropagated }); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); Assert.Equal("4", _fhirRequestContext.ResponseHeaders[headerName].ToString()); Assert.True(bundleResponse.Info.BundleType == BundleType.Batch, "BundleType is different than the expected."); @@ -613,7 +613,7 @@ public async Task GivenABundle_WhenOneRequestProducesA429_429IsRetriedThenSubseq }); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); Assert.Equal(2, callCount); var bundleResource = bundleResponse.Bundle.ToPoco(); @@ -661,7 +661,7 @@ public async Task GivenABundle_WhenOneRequestProducesA429_429IsRetriedThenSuccee }); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); Assert.Equal(4, callCount); var bundleResource = bundleResponse.Bundle.ToPoco(); @@ -685,7 +685,7 @@ public async Task GivenAConfigurationEntryLimit_WhenExceeded_ThenBundleEntryLimi var expectedMessage = "The number of entries in the bundle exceeded the configured limit of 1."; - var exception = await Assert.ThrowsAsync(async () => await _bundleHandler.Handle(bundleRequest, CancellationToken.None)); + var exception = await Assert.ThrowsAsync(async () => await _bundleHandler.HandleAsync(bundleRequest, CancellationToken.None)); Assert.Equal(exception.Message, expectedMessage); } @@ -702,7 +702,7 @@ public async Task GivenABundleWithAnExportPost_WhenProcessed_ThenItIsProcessedCo }; var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, CancellationToken.None); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, CancellationToken.None); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(BundleType.BatchResponse, bundleResource.Type); @@ -749,16 +749,16 @@ public async Task GivenABundleWithMultipleCalls_WhenProcessed_ThenANotificationW .Do(RouteAsyncFunction); BundleMetricsNotification notification = null; - await _mediator.Publish(Arg.Do(note => notification = note), Arg.Any()); + await _mediator.PublishAsync(Arg.Do(note => notification = note), Arg.Any()); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - BundleResponse bundleResponse = await _bundleHandler.Handle(bundleRequest, default); + BundleResponse bundleResponse = await _bundleHandler.HandleAsync(bundleRequest, default); var bundleResource = bundleResponse.Bundle.ToPoco(); Assert.Equal(type == BundleType.Batch ? BundleType.BatchResponse : BundleType.TransactionResponse, bundleResource.Type); Assert.Equal(2, bundleResource.Entry.Count); - await _mediator.Received().Publish(Arg.Any(), Arg.Any()); + await _mediator.Received().PublishAsync(Arg.Any(), Arg.Any()); Assert.Equal(type == BundleType.Batch ? AuditEventSubType.Batch : AuditEventSubType.Transaction, notification.FhirOperation); Assert.Equal("https", notification.Protocol); // Verify protocol is set correctly @@ -814,9 +814,9 @@ public async Task GivenAFailedTransaction_WhenProcessed_ThenNoNotificationWillBe .Do(RouteAsyncFunction); var bundleRequest = new BundleRequest(bundle.ToResourceElement()); - await Assert.ThrowsAsync(() => _bundleHandler.Handle(bundleRequest, default)); + await Assert.ThrowsAsync(() => _bundleHandler.HandleAsync(bundleRequest, default)); - await _mediator.DidNotReceive().Publish(Arg.Any(), Arg.Any()); + await _mediator.DidNotReceive().PublishAsync(Arg.Any(), Arg.Any()); } private void RouteAsyncFunction(CallInfo callInfo) diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/ProfileResourcesBehaviourUnitTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/ProfileResourcesBehaviourUnitTests.cs index 23f03d4940..b8a2a11c44 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/ProfileResourcesBehaviourUnitTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Resources/ProfileResourcesBehaviourUnitTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -8,7 +8,7 @@ using System.Threading; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Api.Features.Resources; using Microsoft.Health.Fhir.Core.Features.Security; @@ -51,7 +51,7 @@ public async Task GivenProfileResourcesBehaviour_WhenExecutedOutOfBundleContext_ var requestHandlerDelegate = Substitute.For>(); - await _profileResourcesBehaviour.Handle( + await _profileResourcesBehaviour.HandleAsync( new CreateResourceRequest( resourceElement, bundleResourceContext: null), @@ -77,7 +77,7 @@ public async Task GivenProfileResourcesBehaviour_WhenExecutedUnderTheBundleConte var requestHandlerDelegate = Substitute.For>(); - await _profileResourcesBehaviour.Handle( + await _profileResourcesBehaviour.HandleAsync( new CreateResourceRequest( resourceElement, bundleResourceContext: bundleResourceContext), diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/RequestHandlerCheckAccessTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/RequestHandlerCheckAccessTests.cs index 23dfcf1412..10f7e2b1bc 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/RequestHandlerCheckAccessTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/RequestHandlerCheckAccessTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -11,7 +11,7 @@ using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Api.Features.Security; using Microsoft.Health.Fhir.Core.Exceptions; @@ -92,7 +92,7 @@ static async Task CallHandle(object handler) { var typedHandler = (IRequestHandler)handler; var request = (TRequest)CreateObject(typeof(TRequest)); - await typedHandler.Handle(request, CancellationToken.None); + await typedHandler.HandleAsync(request, CancellationToken.None); } static IEnumerable GetFieldsIncludingFromBaseTypes(Type t) diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkDeleteController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkDeleteController.cs index 8433e9f924..0fa6330b71 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkDeleteController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkDeleteController.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Health.Api.Features.Audit; using Microsoft.Health.Fhir.Api.Extensions; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkUpdateController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkUpdateController.cs index 57d481b888..1ffb9d3a73 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkUpdateController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/BulkUpdateController.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Microsoft.Health.Api.Features.Audit; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ConvertDataController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ConvertDataController.cs index 8f535c6f0d..d3aaa07c4f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ConvertDataController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ConvertDataController.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -101,7 +101,7 @@ public async Task ConvertData([FromBody] Parameters inputParams) } var convertDataRequest = new ConvertDataRequest(inputData, inputDataType, registryServer, isDefaultTemplateReference, templateCollectionReference, rootTemplate, treatDatesAsStrings); - ConvertDataResponse response = await _mediator.Send(convertDataRequest, cancellationToken: default); + ConvertDataResponse response = await _mediator.SendAsync(convertDataRequest, cancellationToken: default); return new ContentResult { diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/EverythingController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/EverythingController.cs index cde08c7e97..23bc21c18e 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/EverythingController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/EverythingController.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Health.Api.Features.Audit; using Microsoft.Health.Core.Features.Context; @@ -77,7 +77,7 @@ public async Task PatientEverythingById( { IReadOnlyList> unsupportedParameters = ReadUnsupportedParameters(); - EverythingOperationResponse result = await _mediator.Send(new EverythingOperationRequest(ResourceType.Patient.ToString(), idParameter, start, end, since, type, ct, unsupportedParameters), HttpContext.RequestAborted); + EverythingOperationResponse result = await _mediator.SendAsync(new EverythingOperationRequest(ResourceType.Patient.ToString(), idParameter, start, end, since, type, ct, unsupportedParameters), HttpContext.RequestAborted); return FhirResult.Create(result.Bundle); } diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ExportController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ExportController.cs index 61c98811e0..f7e2822733 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ExportController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ExportController.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/FhirController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/FhirController.cs index cda799fdff..2a01b6bf68 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/FhirController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/FhirController.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -11,7 +11,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.JsonPatch; @@ -190,7 +190,7 @@ public async Task ConditionalCreate([FromBody] Resource resource) Tuple[] conditionalParameters = QueryHelpers.ParseQuery(conditionalCreateHeader) .SelectMany(query => query.Value, (query, value) => Tuple.Create(query.Key, value)).ToArray(); - UpsertResourceResponse createResponse = await _mediator.Send( + UpsertResourceResponse createResponse = await _mediator.SendAsync( new ConditionalCreateResourceRequest(resource.ToResourceElement(), conditionalParameters, GetBundleResourceContext()), HttpContext.RequestAborted); @@ -253,7 +253,7 @@ public async Task ConditionalUpdate([FromBody] Resource resource) IReadOnlyList> conditionalParameters = GetQueriesForSearch(); - UpsertResourceResponse response = await _mediator.Send( + UpsertResourceResponse response = await _mediator.SendAsync( new ConditionalUpsertResourceRequest(resource.ToResourceElement(), conditionalParameters, GetBundleResourceContext()), HttpContext.RequestAborted); @@ -468,7 +468,7 @@ public async Task ConditionalDelete(string typeParameter, HardDel SetupConditionalRequestWithQueryOptimizeConcurrency(); - DeleteResourceResponse response = await _mediator.Send( + DeleteResourceResponse response = await _mediator.SendAsync( new ConditionalDeleteResourceRequest( typeParameter, conditionalParameters, diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ImportController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ImportController.cs index 67330228a2..276754d0da 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ImportController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ImportController.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/IncludesController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/IncludesController.cs index 8b0b89e668..f74f2eefe6 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/IncludesController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/IncludesController.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Microsoft.Health.Api.Features.Audit; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/MemberMatchController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/MemberMatchController.cs index 9c7f809fdc..d84227ae23 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/MemberMatchController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/MemberMatchController.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -6,7 +6,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Health.Api.Features.Audit; @@ -50,7 +50,7 @@ public async Task MemberMatch([FromBody] Parameters inputParams) { ValidateParams(inputParams, out ResourceElement coverage, out ResourceElement patient); - var response = await _mediator.Send(new MemberMatchRequest(coverage, patient), HttpContext.RequestAborted); + var response = await _mediator.SendAsync(new MemberMatchRequest(coverage, patient), HttpContext.RequestAborted); var parameters = new Parameters(); parameters.Add(Patient, response.Patient.ToPoco()); return MemberMatchResult.Ok(parameters); diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/OperationDefinitionController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/OperationDefinitionController.cs index 9cb32d78ab..68485be66e 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/OperationDefinitionController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/OperationDefinitionController.cs @@ -7,7 +7,7 @@ using System.Net; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ReindexController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ReindexController.cs index acd4adbea6..a770d1a624 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ReindexController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ReindexController.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/SearchParameterController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/SearchParameterController.cs index 9c1d51a48d..ac71f181fc 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/SearchParameterController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/SearchParameterController.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Microsoft.Health.Api.Features.Audit; @@ -66,7 +66,7 @@ public async Task GetSearchParametersStatus(CancellationToken can CheckIfSearchParameterStatusIsEnabledOrADHS(); SearchParameterStateRequest request = new SearchParameterStateRequest(GetQueriesForSearch()); - SearchParameterStateResponse result = await _mediator.Send(request, cancellationToken); + SearchParameterStateResponse result = await _mediator.SendAsync(request, cancellationToken); return FhirResult.Create(result.SearchParameters, System.Net.HttpStatusCode.OK); } @@ -85,7 +85,7 @@ public async Task PostSearchParametersStatus(CancellationToken ca CheckIfSearchParameterStatusIsEnabledOrADHS(); SearchParameterStateRequest request = new SearchParameterStateRequest(GetQueriesForSearch()); - SearchParameterStateResponse result = await _mediator.Send(request, cancellationToken); + SearchParameterStateResponse result = await _mediator.SendAsync(request, cancellationToken); return FhirResult.Create(result.SearchParameters, System.Net.HttpStatusCode.OK); } @@ -103,7 +103,7 @@ public async Task UpdateSearchParametersStatus([FromBody] Paramet { CheckIfSearchParameterStatusIsEnabledOrADHS(); SearchParameterStateUpdateRequest updateRequest = ParseUpdateRequestBody(inputParams); - SearchParameterStateUpdateResponse result = await _mediator.Send(updateRequest, cancellationToken); + SearchParameterStateUpdateResponse result = await _mediator.SendAsync(updateRequest, cancellationToken); return FhirResult.Create(result.UpdateStatus, System.Net.HttpStatusCode.OK); } diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/TerminologyController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/TerminologyController.cs index d91c95041a..04e6b73b6b 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/TerminologyController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/TerminologyController.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -11,7 +11,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Microsoft.Health.Api.Features.Audit; @@ -73,7 +73,7 @@ public async Task Expand() ValidateExpandParameters(parameters); var request = new ExpandRequest(parameters); - var response = await _mediator.Send( + var response = await _mediator.SendAsync( request, HttpContext.RequestAborted); return FhirResult.Create(response.Resource); @@ -99,7 +99,7 @@ public async Task Expand([FromRoute] string idParameter) ValidateExpandParameters(parameters, idParameter); var request = new ExpandRequest(parameters, idParameter); - var response = await _mediator.Send( + var response = await _mediator.SendAsync( request, HttpContext.RequestAborted); return FhirResult.Create(response.Resource); @@ -121,7 +121,7 @@ public async Task Expand([FromBody] Parameters parameters) ValidateExpandParameters(parameterList); var request = new ExpandRequest(parameterList); - var response = await _mediator.Send( + var response = await _mediator.SendAsync( request, HttpContext.RequestAborted); return FhirResult.Create(response.Resource); diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cs b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cs index 9f262273ce..c203b07e46 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -8,7 +8,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.Health.Api.Features.Audit; using Microsoft.Health.Fhir.Api.Features.ActionResults; @@ -117,7 +117,7 @@ public async Task ValidateByIdPost([FromBody] Resource resource, private async Task RunValidationAsync(ResourceElement resource, Uri profile) { - var response = await _mediator.Send(new ValidateOperationRequest(resource, profile)); + var response = await _mediator.SendAsync(new ValidateOperationRequest(resource, profile)); return FhirResult.Create(new OperationOutcome { Issue = response.Issues.Select(x => x.ToPoco()).ToList() }.ToResourceElement()); } diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs index 40ca0ba446..cee4381da7 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/Bundle/BundleHandler.cs @@ -17,7 +17,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Http.Features.Authentication; @@ -173,7 +173,7 @@ public BundleHandler( _isBundleProcessingLogicValid = _bundleOrchestrator.IsEnabled ? BundleHandlerRuntime.IsBundleProcessingLogicValid(_outerHttpContext) : true; } - public async Task Handle(BundleRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(BundleRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); @@ -462,7 +462,7 @@ private async Task PublishNotification(Hl7.Fhir.Model.Bundle responseBundle, Bun }); } - await _mediator.Publish(new BundleMetricsNotification(apiCallResults, bundleType == BundleType.Batch ? AuditEventSubType.Batch : AuditEventSubType.Transaction, _outerHttpContext.Request.Scheme), CancellationToken.None); + await _mediator.PublishAsync(new BundleMetricsNotification(apiCallResults, bundleType == BundleType.Batch ? AuditEventSubType.Batch : AuditEventSubType.Transaction, _outerHttpContext.Request.Scheme), CancellationToken.None); } private async Task ExecuteTransactionForAllRequestsAsync(Hl7.Fhir.Model.Bundle responseBundle, BundleProcessingLogic processingLogic, CancellationToken cancellationToken) diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProfileResourcesBehaviour.cs b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProfileResourcesBehaviour.cs index a175ab9878..2b91454d7c 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProfileResourcesBehaviour.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProfileResourcesBehaviour.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -37,19 +37,19 @@ public ProfileResourcesBehaviour(IAuthorizationService authorizatio _profilesResolver = profilesResolver; } - public async Task Handle(ConditionalUpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(ConditionalUpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(request.Resource.InstanceType, request.IsBundleInnerRequest, next, cancellationToken); - public async Task Handle(ConditionalCreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(ConditionalCreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(request.Resource.InstanceType, request.IsBundleInnerRequest, next, cancellationToken); - public async Task Handle(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(request.Resource.InstanceType, request.IsBundleInnerRequest, next, cancellationToken); - public async Task Handle(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(request.Resource.InstanceType, request.IsBundleInnerRequest, next, cancellationToken); - public async Task Handle(DeleteResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(DeleteResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(request.ResourceKey.ResourceType, request.IsBundleInnerRequest, next, cancellationToken); private async Task GenericHandle( @@ -66,7 +66,7 @@ private async Task GenericHandle( throw new UnauthorizedFhirActionException(); } - var result = await next(cancellationToken); + var result = await next(); // If the requests is part of a bundle, as an inner request, then profiles are not refreshed. // This is because the bundle can contain multiple profile changes and the refresh should only happen once, at the end of the bundle, to avoid performance degradation. @@ -79,7 +79,7 @@ private async Task GenericHandle( } else { - return await next(cancellationToken); + return await next(); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProvenanceHeaderBehavior.cs b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProvenanceHeaderBehavior.cs index 45a2fb99f1..6d50ea06f9 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProvenanceHeaderBehavior.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Features/Resources/ProvenanceHeaderBehavior.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -8,7 +8,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Primitives; using Microsoft.Health.Fhir.Api.Features.Exceptions; @@ -46,28 +46,28 @@ public ProvenanceHeaderBehavior(FhirJsonParser fhirJsonParser, IHttpContextAcces _state = state; } - public async Task Handle(ConditionalUpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(ConditionalUpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(next, cancellationToken); - public async Task Handle(ConditionalCreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(ConditionalCreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(next, cancellationToken); - public async Task Handle(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(UpsertResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(next, cancellationToken); - public async Task Handle(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(CreateResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) => await GenericHandle(next, cancellationToken); private async Task GenericHandle(RequestHandlerDelegate next, CancellationToken cancellationToken) { if (_state.Intercepted) { - return await next(cancellationToken); + return await next(); } _state.Intercepted = true; Provenance provenance = GetProvenanceFromHeader(); - var response = await next(cancellationToken); + var response = await next(); if (response != null && provenance != null) { @@ -79,7 +79,7 @@ private async Task GenericHandle(RequestHandlerDelegate< // Create Provenance resource. // TODO: It should probaby go through controller to trigger audit events, but it's quite tricky to do now. - await _mediator.Send(new CreateResourceRequest(provenance.ToResourceElement(), bundleResourceContext: null), cancellationToken); + await _mediator.SendAsync(new CreateResourceRequest(provenance.ToResourceElement(), bundleResourceContext: null), cancellationToken); } return response; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Modules/FhirModule.cs b/src/Microsoft.Health.Fhir.Shared.Api/Modules/FhirModule.cs index 028897374e..a44f1ba4ea 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Modules/FhirModule.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Modules/FhirModule.cs @@ -10,7 +10,7 @@ using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; using Hl7.FhirPath; -using MediatR; +using Medino; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.AspNetCore.Routing; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Modules/MediationModule.cs b/src/Microsoft.Health.Fhir.Shared.Api/Modules/MediationModule.cs index 7785f205df..a7d69f1103 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Modules/MediationModule.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Modules/MediationModule.cs @@ -3,11 +3,10 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using System; using System.Linq; using EnsureThat; -using MediatR; -using MediatR.Pipeline; +using Medino; +using Medino.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Features.Conformance; @@ -26,16 +25,16 @@ public void Load(IServiceCollection services) { EnsureArg.IsNotNull(services, nameof(services)); - services.AddMediatR(cfg => + // TODO: AddMedino extension method not available in Medino 3.0.2 - may need alternative registration + services.AddMedino(cfg => { - cfg.RegisterServicesFromAssemblies(KnownAssemblies.All); - cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(RequestExceptionActionProcessorBehavior<,>)); - cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(RequestExceptionProcessorBehavior<,>)); - cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(ValidateRequestPreProcessor<>)); - cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor), typeof(ValidateBundlePreProcessor)); - cfg.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(ValidateCapabilityPreProcessor<>)); + cfg.RegisterServicesFromAssemblies(KnownAssemblies.All); }); + // Register ValidateBundlePreProcessor as a pipeline behavior + // (Converted from IRequestPreProcessor which was removed in newer Medino versions) + services.AddTransient, ValidateBundlePreProcessor>(); + // Allows handlers to provide capabilities var openRequestInterfaces = new[] { diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Modules/OperationsModule.cs b/src/Microsoft.Health.Fhir.Shared.Api/Modules/OperationsModule.cs index 1df51cca18..37e0ff6e8c 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Modules/OperationsModule.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Modules/OperationsModule.cs @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Extensions; diff --git a/src/Microsoft.Health.Fhir.Shared.Api/Modules/SearchModule.cs b/src/Microsoft.Health.Fhir.Shared.Api/Modules/SearchModule.cs index 1b0819e65b..387d502ed0 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api/Modules/SearchModule.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api/Modules/SearchModule.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Health.Extensions.DependencyInjection; diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Compartment/SearchCompartmentHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Compartment/SearchCompartmentHandlerTests.cs index 95b58197e0..e6e50894bf 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Compartment/SearchCompartmentHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Compartment/SearchCompartmentHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -56,7 +56,7 @@ public async Task GivenASearchCompartmentRequest_WhenHandled_ThenABundleShouldBe _bundleFactory.CreateSearchBundle(searchResult).Returns(expectedBundle); - SearchCompartmentResponse actualResponse = await _searchCompartmentHandler.Handle(request, CancellationToken.None); + SearchCompartmentResponse actualResponse = await _searchCompartmentHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/ConformanceBuilderTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/ConformanceBuilderTests.cs index 30e72a1de4..813df420a7 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/ConformanceBuilderTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/ConformanceBuilderTests.cs @@ -11,7 +11,7 @@ using Hl7.Fhir.ElementModel.Types; using Hl7.Fhir.Model; using Hl7.FhirPath; -using MediatR; +using Medino; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Core.Configs; using Microsoft.Health.Fhir.Core.Extensions; diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/DocRefRequestConverterTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/DocRefRequestConverterTests.cs index 9dd029af2d..31d04fb09a 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/DocRefRequestConverterTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/DocRefRequestConverterTests.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -37,7 +37,7 @@ public class DocRefRequestConverterTests public DocRefRequestConverterTests() { _mediator = Substitute.For(); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns(Task.FromResult(new SearchResourceResponse(new Bundle().ToResourceElement()))); @@ -70,7 +70,7 @@ public async Task GivenParameters_WhenConverting_ThenSearchResourceShouldBeCalle var unsupported = parametersToValidate.ContainsKey(DocRefRequestConverter.OnDemandParameterName) || parametersToValidate.ContainsKey(DocRefRequestConverter.ProfileParameterName); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns( @@ -119,7 +119,7 @@ await _converter.ConvertAsync( Assert.False(valid); } - await _mediator.Received(valid && !unsupported ? 1 : 0).Send( + await _mediator.Received(valid && !unsupported ? 1 : 0).SendAsync( Arg.Any(), Arg.Any()); _bundleFactory.Received(unsupported ? 1 : 0).CreateSearchBundle( diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs index fb2c257a50..56b866c738 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -37,7 +37,7 @@ public async Task GivenASmartConfigurationHandler_WhenSecurityConfigurationNotEn var handler = new GetSmartConfigurationHandler(Options.Create(securityConfiguration)); - OperationFailedException e = await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + OperationFailedException e = await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); Assert.Equal(HttpStatusCode.BadRequest, e.ResponseStatusCode); } @@ -53,7 +53,7 @@ public async Task GivenASmartConfigurationHandler_WhenSecurityConfigurationEnabl var handler = new GetSmartConfigurationHandler(Options.Create(securityConfiguration)); - GetSmartConfigurationResponse response = await handler.Handle(request, CancellationToken.None); + GetSmartConfigurationResponse response = await handler.HandleAsync(request, CancellationToken.None); Assert.Equal(response.AuthorizationEndpoint.ToString(), baseEndpoint + "/authorize"); Assert.Equal(response.TokenEndpoint.ToString(), baseEndpoint + "/token"); @@ -81,7 +81,7 @@ public async Task GivenASmartConfigurationHandler_WhenBaseEndpointIsInvalid_Then var handler = new GetSmartConfigurationHandler(Options.Create(securityConfiguration)); - OperationFailedException exception = await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + OperationFailedException exception = await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); Assert.Equal(HttpStatusCode.BadRequest, exception.ResponseStatusCode); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/TerminologyRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/TerminologyRequestHandlerTests.cs index fb8928ceca..af6672d731 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/TerminologyRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/TerminologyRequestHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -9,7 +9,7 @@ using System.Threading; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Extensions; @@ -54,7 +54,7 @@ public TerminologyRequestHandlerTests() .Returns(Task.FromResult(CreateValueSet(Guid.NewGuid().ToString()).ToResourceElement())); _mediator = Substitute.For(); - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns(Task.FromResult(CreateGetResourceResponse(CreateValueSet(Guid.NewGuid().ToString())))); @@ -77,7 +77,7 @@ public async Task GivenExpandRequest_WhenHandling_ThenProxyShouldBeCalledWithCor ExpandRequest request, Exception exception) { - _mediator.Send( + _mediator.SendAsync( Arg.Any(), Arg.Any()) .Returns( @@ -161,7 +161,7 @@ public async Task GivenExpandRequest_WhenHandling_ThenProxyShouldBeCalledWithCor }); try { - await _handler.Handle( + await _handler.HandleAsync( request, CancellationToken.None); Assert.Null(exception); @@ -171,7 +171,7 @@ await _handler.Handle( Assert.NotNull(exception); } - await _mediator.Received(string.IsNullOrEmpty(request.ResourceId) ? 0 : 1).Send( + await _mediator.Received(string.IsNullOrEmpty(request.ResourceId) ? 0 : 1).SendAsync( Arg.Any(), Arg.Any()); } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/ConvertData/ConvertDataRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/ConvertData/ConvertDataRequestHandlerTests.cs index 5fac204917..21111f2a99 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/ConvertData/ConvertDataRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/ConvertData/ConvertDataRequestHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -33,7 +33,7 @@ public class ConvertDataRequestHandlerTests public async Task GivenAHl7v2ConvertRequest_WhenConvertData_CorrectResponseShouldReturn() { var convertDataRequestHandler = GetRequestHandler(); - var response = await convertDataRequestHandler.Handle(GetSampleHl7v2Request(), default); + var response = await convertDataRequestHandler.HandleAsync(GetSampleHl7v2Request(), default); var setting = new ParserSettings() { @@ -53,7 +53,7 @@ public async Task GivenAHl7v2ConvertRequest_WhenConvertData_CorrectResponseShoul public async Task GivenACcdaConvertRequest_WhenConvertData_CorrectResponseShouldReturn() { var convertDataRequestHandler = GetRequestHandler(); - var response = await convertDataRequestHandler.Handle(GetSampleCcdaRequest(), default); + var response = await convertDataRequestHandler.HandleAsync(GetSampleCcdaRequest(), default); var setting = new ParserSettings() { @@ -73,7 +73,7 @@ public async Task GivenACcdaConvertRequest_WhenConvertData_CorrectResponseShould public async Task GivenAJsonConvertRequest_WhenConvertData_CorrectResponseShouldReturn() { var convertDataRequestHandler = GetRequestHandler(); - var response = await convertDataRequestHandler.Handle(GetSampleJsonRequest(), default); + var response = await convertDataRequestHandler.HandleAsync(GetSampleJsonRequest(), default); var setting = new ParserSettings() { @@ -93,7 +93,7 @@ public async Task GivenAJsonConvertRequest_WhenConvertData_CorrectResponseShould public async Task GivenAFhirConvertRequest_WhenConvertData_CorrectResponseShouldReturn() { var convertDataRequestHandler = GetRequestHandler(); - var response = await convertDataRequestHandler.Handle(GetSampleFhirRequest(), default); + var response = await convertDataRequestHandler.HandleAsync(GetSampleFhirRequest(), default); var setting = new ParserSettings() { diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Everything/EverythingOperationHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Everything/EverythingOperationHandlerTests.cs index c2556fd196..cd698dad63 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Everything/EverythingOperationHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Everything/EverythingOperationHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -59,7 +59,7 @@ public async Task GivenAnEverythingOperationRequest_WhenHandled_ThenABundleShoul _bundleFactory.CreateSearchBundle(searchResult).Returns(expectedBundle); - EverythingOperationResponse actualResponse = await _everythingOperationHandler.Handle(request, CancellationToken.None); + EverythingOperationResponse actualResponse = await _everythingOperationHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexOrchestratorJobTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexOrchestratorJobTests.cs index a01e2b04ee..4915c0bce3 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexOrchestratorJobTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexOrchestratorJobTests.cs @@ -8,7 +8,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Core.Configs; diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexSingleResourceRequestHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexSingleResourceRequestHandlerTests.cs index 5cffd9877b..57a80984bf 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexSingleResourceRequestHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/Reindex/ReindexSingleResourceRequestHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -71,7 +71,7 @@ public async Task GivenUserDoesNotHavePermissionForReindex_WhenHandle_ThenUnauth _authorizationService.CheckAccess(Arg.Is(DataActions.Reindex), Arg.Any()).Returns(DataActions.None); var request = GetReindexRequest(HttpGetName); - await Assert.ThrowsAsync(() => _reindexHandler.Handle(request, _cancellationToken)); + await Assert.ThrowsAsync(() => _reindexHandler.HandleAsync(request, _cancellationToken)); } [Fact] @@ -80,7 +80,7 @@ public async Task GivenResourceDoesNotExist_WhenHandle_ThenResourceNotFoundExcep _fhirDataStore.GetAsync(Arg.Any(), _cancellationToken).Returns(Task.FromResult(null)); var request = GetReindexRequest(HttpGetName); - await Assert.ThrowsAsync(() => _reindexHandler.Handle(request, _cancellationToken)); + await Assert.ThrowsAsync(() => _reindexHandler.HandleAsync(request, _cancellationToken)); } [Theory] @@ -99,7 +99,7 @@ public async Task GivenNewSearchIndicesGetRequest_WhenHandle_ThenTheirValuesAreP var request = GetReindexRequest(httpMethodName); - ReindexSingleResourceResponse response = await _reindexHandler.Handle(request, _cancellationToken); + ReindexSingleResourceResponse response = await _reindexHandler.HandleAsync(request, _cancellationToken); Assert.NotNull(response.ParameterResource); Parameters parameterResponse = response.ParameterResource.ToPoco(); @@ -142,7 +142,7 @@ public async Task GivenDuplicateNewSearchIndices_WhenHandle_ThenBothValuesArePre var request = GetReindexRequest(httpMethodName); - ReindexSingleResourceResponse response = await _reindexHandler.Handle(request, _cancellationToken); + ReindexSingleResourceResponse response = await _reindexHandler.HandleAsync(request, _cancellationToken); Assert.NotNull(response.ParameterResource); Parameters parameterResponse = response.ParameterResource.ToPoco(); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateHandlerTests.cs index f3ab6423b4..105a3c90b8 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -9,7 +9,7 @@ using System.Linq; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core.Features.Security.Authorization; @@ -190,7 +190,7 @@ public async Task GivenARequestWithNoQueries_WhenHandling_ThenAllSearchParameter var request = new SearchParameterStateRequest(new List>()); // Act - var response = await _searchParameterHandler.Handle(request, _cancellationToken); + var response = await _searchParameterHandler.HandleAsync(request, _cancellationToken); // Assert Assert.NotNull(response); @@ -213,7 +213,7 @@ public async Task GivenARequestWithAValidUrl_WhenHandling_ThenSearchParameterMat var request = new SearchParameterStateRequest(new List>() { new Tuple(SearchParameterStateProperties.Url, ResourceId) }); // Act - var response = await _searchParameterHandler.Handle(request, _cancellationToken); + var response = await _searchParameterHandler.HandleAsync(request, _cancellationToken); // Assert Assert.NotNull(response); @@ -230,7 +230,7 @@ public async Task GivenARequestWithAValidCode_WhenHandling_ThenSearchParameterMa var request = new SearchParameterStateRequest(new List>() { new Tuple(SearchParameterStateProperties.Code, "lastUpdated") }); // Act - var response = await _searchParameterHandler.Handle(request, _cancellationToken); + var response = await _searchParameterHandler.HandleAsync(request, _cancellationToken); // Assert Assert.NotNull(response); @@ -248,7 +248,7 @@ public async Task GivenARequestWithAValidResourceType_WhenHandling_ThenSearchPar var request = new SearchParameterStateRequest(new List>() { new Tuple(SearchParameterStateProperties.ResourceType, "Resource") }); // Act - var response = await _searchParameterHandler.Handle(request, _cancellationToken); + var response = await _searchParameterHandler.HandleAsync(request, _cancellationToken); // Assert Assert.NotNull(response); @@ -269,7 +269,7 @@ public async Task GivenARequestWithAValidCodeAndResourceType_WhenHandling_ThenSe var request = new SearchParameterStateRequest(new List>() { new Tuple(SearchParameterStateProperties.Code, "lastUpdated"), new Tuple(SearchParameterStateProperties.ResourceType, "Resource") }); // Act - var response = await _searchParameterHandler.Handle(request, _cancellationToken); + var response = await _searchParameterHandler.HandleAsync(request, _cancellationToken); // Assert Assert.NotNull(response); @@ -287,7 +287,7 @@ public async Task GivenARequestWithAValidCodeAndResourceTypeThatDonotHaveMatchin // Act // Assert - await Assert.ThrowsAsync(() => _searchParameterHandler.Handle(request, _cancellationToken)); + await Assert.ThrowsAsync(() => _searchParameterHandler.HandleAsync(request, _cancellationToken)); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandlerTests.cs index ce29ca6672..fffba97795 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -9,7 +9,7 @@ using System.Linq; using System.Threading; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; @@ -238,7 +238,7 @@ public async Task GivenARequestToUpdateSearchParameterStatus_WhenTheStatusIsEnab new Tuple(new Uri(ResourceId), SearchParameterStatus.Supported), }; - SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.Handle(new SearchParameterStateUpdateRequest(updates), default); + SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.HandleAsync(new SearchParameterStateUpdateRequest(updates), default); Assert.NotNull(response); Assert.NotNull(response.UpdateStatus); @@ -259,7 +259,7 @@ public async Task GivenARequestToUpdateSearchParameterStatus_WhenTheResourceIsNo new Tuple(new Uri(NotFoundResource), SearchParameterStatus.Supported), }; - SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.Handle(new SearchParameterStateUpdateRequest(updates), default); + SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.HandleAsync(new SearchParameterStateUpdateRequest(updates), default); Assert.NotNull(response); Assert.NotNull(response.UpdateStatus); @@ -279,7 +279,7 @@ public async Task GivenARequestToUpdateSearchParameterStatus_WhenStatusIsNotSupp new Tuple(new Uri(ResourceId), SearchParameterStatus.Deleted), }; - SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.Handle(new SearchParameterStateUpdateRequest(updates), default); + SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.HandleAsync(new SearchParameterStateUpdateRequest(updates), default); Assert.NotNull(response); Assert.NotNull(response.UpdateStatus); @@ -301,7 +301,7 @@ public async Task GivenARequestToUpdateSearchParameterStatus_WhenStatusIsDisable new Tuple(new Uri(ResourceId), SearchParameterStatus.Disabled), }; - SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.Handle(new SearchParameterStateUpdateRequest(updates), default); + SearchParameterStateUpdateResponse response = await _searchParameterStateUpdateHandler.HandleAsync(new SearchParameterStateUpdateRequest(updates), default); Assert.NotNull(response); Assert.NotNull(response.UpdateStatus); @@ -326,7 +326,7 @@ public async Task GivenARequestToUpdateSearchParameterStatus_WhenRequestIsValied new Tuple(new Uri(ResourceId), SearchParameterStatus.Disabled), }; - SearchParameterStateUpdateResponse response = await searchParameterStateUpdateHandler.Handle(new SearchParameterStateUpdateRequest(updates), default); + SearchParameterStateUpdateResponse response = await searchParameterStateUpdateHandler.HandleAsync(new SearchParameterStateUpdateRequest(updates), default); Assert.NotNull(response); Assert.NotNull(response.UpdateStatus); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/ConditionalCreateResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/ConditionalCreateResourceHandlerTests.cs index b5e27b7565..da30f4d33e 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/ConditionalCreateResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/ConditionalCreateResourceHandlerTests.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Extensions.DependencyInjection; @@ -90,11 +90,11 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserHasSearchAndCre var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalCreateHandler.Handle(request, CancellationToken.None); + await _conditionalCreateHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -110,11 +110,11 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserHasLegacyReadAn var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalCreateHandler.Handle(request, CancellationToken.None); + await _conditionalCreateHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -130,7 +130,7 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserHasOnlySearchPe var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalCreateHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalCreateHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -146,7 +146,7 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserHasOnlyCreatePe var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalCreateHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalCreateHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -162,7 +162,7 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserHasOnlyReadPerm var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalCreateHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalCreateHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -178,6 +178,6 @@ public async Task GivenAConditionalCreateResourceHandler_WhenUserLacksAllPermiss var request = new ConditionalCreateResourceRequest(patient, conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalCreateHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalCreateHandler.HandleAsync(request, CancellationToken.None)); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Get/GetResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Get/GetResourceHandlerTests.cs index 56db1b818d..fe191dea1a 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Get/GetResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Get/GetResourceHandlerTests.cs @@ -94,7 +94,7 @@ public async Task GivenAGetResourceRequest_WhenUserHasReadPermission_ThenGetShou var request = new GetResourceRequest(new ResourceKey("Patient", "123"), bundleResourceContext: null); // Act & Assert - Should not throw UnauthorizedFhirActionException - var result = await getResourceHandler.Handle(request, CancellationToken.None); + var result = await getResourceHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.Resource); @@ -122,7 +122,7 @@ public async Task GivenAGetResourceRequest_WhenUserHasReadByIdPermission_ThenGet var request = new GetResourceRequest(new ResourceKey("Patient", "123"), bundleResourceContext: null); // Act & Assert - Should not throw UnauthorizedFhirActionException - var result = await getResourceHandler.Handle(request, CancellationToken.None); + var result = await getResourceHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.Resource); @@ -151,7 +151,7 @@ public async Task GivenAGetResourceRequest_WhenUserLacksPermissions_ThenUnauthor // Act & Assert await Assert.ThrowsAsync(() => - getResourceHandler.Handle(request, CancellationToken.None)); + getResourceHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -177,7 +177,7 @@ public async Task GivenAGetResourceRequest_WhenUserHasOnlyWritePermission_ThenUn // Act & Assert await Assert.ThrowsAsync(() => - getResourceHandler.Handle(request, CancellationToken.None)); + getResourceHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -203,7 +203,7 @@ public async Task GivenAGetResourceRequest_WhenUserHasOnlySearchPermission_ThenU // Act & Assert await Assert.ThrowsAsync(() => - getResourceHandler.Handle(request, CancellationToken.None)); + getResourceHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -233,6 +233,6 @@ public async Task GivenAGetResourceRequest_WhenResourceNotFound_ThenResourceNotF // Act & Assert await Assert.ThrowsAsync(() => - getResourceHandler.Handle(request, CancellationToken.None)); + getResourceHandler.HandleAsync(request, CancellationToken.None)); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/ConditionalPatchResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/ConditionalPatchResourceHandlerTests.cs index 8b377243b8..ea30b7b115 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/ConditionalPatchResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/ConditionalPatchResourceHandlerTests.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -88,11 +88,11 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserHasSearchAndUpda var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalPatchHandler.Handle(request, CancellationToken.None); + await _conditionalPatchHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -107,11 +107,11 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserHasLegacyReadAnd var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalPatchHandler.Handle(request, CancellationToken.None); + await _conditionalPatchHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -126,7 +126,7 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserHasOnlySearchPer var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalPatchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalPatchHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -141,7 +141,7 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserHasOnlyUpdatePer var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalPatchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalPatchHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -156,7 +156,7 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserHasOnlyReadPermi var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalPatchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalPatchHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -171,7 +171,7 @@ public async Task GivenAConditionalPatchResourceHandler_WhenUserLacksAllPermissi var request = new ConditionalPatchResourceRequest("Patient", new FhirPathPatchPayload(new Parameters()), conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalPatchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalPatchHandler.HandleAsync(request, CancellationToken.None)); } private static IReadOnlyCollection GenerateSearchResult(string resourceType) diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/PatchResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/PatchResourceHandlerTests.cs index 3d7984887e..cb3368b552 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/PatchResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Patch/PatchResourceHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -66,11 +66,11 @@ public async Task GivenAPatchResourceHandler_WhenHandlingAPatchResourceRequestWi var etag = WeakETag.FromWeakETag("W/\"1\""); var request = new PatchResourceRequest(new ResourceKey("Patient", "123"), new FhirPathPatchPayload(new Parameters()), bundleResourceContext: null, weakETag: etag); - await _patchHandler.Handle(request, CancellationToken.None); + await _patchHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Is(x => x.WeakETag.VersionId == etag.VersionId), Arg.Any()); + .SendAsync(Arg.Is(x => x.WeakETag.VersionId == etag.VersionId), Arg.Any()); } [Fact] @@ -80,7 +80,7 @@ public async Task GivenAPatchResourceHandler_WhenHandlingAPatchResourceRequestWi var request = new PatchResourceRequest(new ResourceKey("Patient", "123"), new FhirPathPatchPayload(new Parameters()), bundleResourceContext: null, weakETag: etag); - await Assert.ThrowsAsync(async () => await _patchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(async () => await _patchHandler.HandleAsync(request, CancellationToken.None)); } [Theory] @@ -115,11 +115,11 @@ public async Task GivenAPatchResourceHandler_WhenUserHasSufficientPermissions_Th var request = new PatchResourceRequest(new ResourceKey("Patient", "123"), new FhirPathPatchPayload(new Parameters()), bundleResourceContext: null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await patchHandler.Handle(request, CancellationToken.None); + await patchHandler.HandleAsync(request, CancellationToken.None); await mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Theory] @@ -142,6 +142,6 @@ public async Task GivenAPatchResourceHandler_WhenUserLacksPermission_ThenUnautho var request = new PatchResourceRequest(new ResourceKey("Patient", "123"), new FhirPathPatchPayload(new Parameters()), bundleResourceContext: null); // Act & Assert - await Assert.ThrowsAsync(() => patchHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => patchHandler.HandleAsync(request, CancellationToken.None)); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests.cs index 1a74ab9b1e..2ab33901f4 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -12,7 +12,7 @@ using Hl7.Fhir.Model; using Hl7.Fhir.Rest; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -489,7 +489,7 @@ public async Task GivenUpsertRequestWithPostHttpVerb_WhenUserHasCreatePermission var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleContext); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); } @@ -508,7 +508,7 @@ public async Task GivenUpsertRequestWithPostHttpVerb_WhenUserLacksCreatePermissi var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleContext); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -525,7 +525,7 @@ public async Task GivenUpsertRequestWithPutHttpVerb_WhenUserHasUpdatePermission_ var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleContext); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); } @@ -544,7 +544,7 @@ public async Task GivenUpsertRequestWithPutHttpVerb_WhenUserLacksUpdatePermissio var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleContext); - await Assert.ThrowsAsync(() => handler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => handler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -560,7 +560,7 @@ public async Task GivenUpsertRequestWithInvalidHttpVerb_WhenResourceHasNoId_Then var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleResourceContext: null); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); } @@ -577,7 +577,7 @@ public async Task GivenUpsertRequestWithRequestContextPost_WhenNoBundleContext_T var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleResourceContext: null); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); } @@ -594,7 +594,7 @@ public async Task GivenUpsertRequestWithRequestContextPut_WhenNoBundleContext_Th var handler = new UpsertResourceHandler(_fhirDataStore, new Lazy(() => _conformanceProvider), _resourceWrapperFactory, _resourceIdProvider, new ResourceReferenceResolver(_searchService, new TestQueryStringParser(), Substitute.For>()), contextAccessor, _authorizationService, ModelInfoProvider.Instance); var request = new UpsertResourceRequest(resource, bundleResourceContext: null); - var result = await handler.Handle(request, CancellationToken.None); + var result = await handler.HandleAsync(request, CancellationToken.None); Assert.NotNull(result); } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalCreate.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalCreate.cs index 5c60d7807c..7b8608caca 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalCreate.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalCreate.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -33,7 +33,7 @@ public async Task GivenAResource_WhenCreatingConditionallyWithNoExisting_ThenThe { ConditionalCreateResourceRequest message = SetupConditionalCreate(Samples.GetDefaultObservation(), DefaultSearchParams); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(SaveOutcomeType.Created, result.Outcome.Outcome); @@ -54,7 +54,7 @@ public async Task GivenAResource_WhenCreatingConditionallyWithOneMatch_ThenTheSe DefaultSearchParams, mockResultEntry); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.NotNull(result?.Outcome); Assert.Equal(SaveOutcomeType.MatchFound, result.Outcome.Outcome); @@ -74,7 +74,7 @@ public async Task GivenAResource_WhenCreatingConditionallyWithMultipleMatches_Th mockResultEntry1, mockResultEntry2); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(() => _mediator.SendAsync(message)); } [Fact] @@ -88,7 +88,7 @@ public async Task GivenAResource_WhenCreatingConditionallyWithFilteredSearchPara Tuple.Create("_summary", "count"), }); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(() => _mediator.SendAsync(message)); } [Fact] @@ -110,7 +110,7 @@ public async Task GivenAResource_WhenCreatingConditionallyWithUnsupportedParams_ _searchService.SearchAsync(Arg.Any(), Arg.Any>>(), CancellationToken.None) .Returns(searchResult); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(() => _mediator.SendAsync(message)); } private ConditionalCreateResourceRequest SetupConditionalCreate( diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalDelete.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalDelete.cs index 6f673d09f3..09936fd832 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalDelete.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalDelete.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -30,7 +30,7 @@ public async Task GivenNoExistingResources_WhenDeletingConditionally_TheServerSh { ConditionalDeleteResourceRequest message = SetupConditionalDelete(KnownResourceTypes.Observation, DefaultSearchParams); - DeleteResourceResponse result = await _mediator.Send(message); + DeleteResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(0, result.ResourcesDeleted); } @@ -47,7 +47,7 @@ public async Task GivenOneMatchingResource_WhenDeletingConditionally_TheServerSh count: 1, mockResultEntry); - DeleteResourceResponse result = await _mediator.Send(message); + DeleteResourceResponse result = await _mediator.SendAsync(message); Assert.NotNull(result); Assert.Equal(1, result.ResourcesDeleted); @@ -67,7 +67,7 @@ public async Task GivenOneMatchingResource_WhenDeletingConditionallyWithHardDele count: 1, mockResultEntry); - DeleteResourceResponse result = await _mediator.Send(message); + DeleteResourceResponse result = await _mediator.SendAsync(message); Assert.NotNull(result); Assert.Equal(1, result.ResourcesDeleted); @@ -91,7 +91,7 @@ public async Task GivenMultipleMatchingResources_WhenDeletingConditionally_TheSe mockResultEntry1, mockResultEntry2); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(() => _mediator.SendAsync(message)); } [Fact] @@ -108,7 +108,7 @@ public async Task GivenMultipleMatchingResources_WhenDeletingConditionallyWithMu mockResultEntry1, mockResultEntry2); - DeleteResourceResponse result = await _mediator.Send(message); + DeleteResourceResponse result = await _mediator.SendAsync(message); Assert.NotNull(result); Assert.Equal(2, result.ResourcesDeleted); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalUpsert.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalUpsert.cs index fd12eb454e..12b79d3a60 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalUpsert.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/ResourceHandlerTests_ConditionalUpsert.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -31,7 +31,7 @@ public async Task GivenAResource_WhenUpsertingConditionallyWithNoIdAndNoExisting { ConditionalUpsertResourceRequest message = SetupConditionalUpdate(SaveOutcomeType.Created, Samples.GetDefaultObservation()); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(SaveOutcomeType.Created, result.Outcome.Outcome); var deserialized = result.Outcome.RawResourceElement.ToPoco(Deserializers.ResourceDeserializer).ToResourceElement(); @@ -45,7 +45,7 @@ public async Task GivenAResource_WhenUpsertingConditionallyWithAnIdAndNoExisting ConditionalUpsertResourceRequest message = SetupConditionalUpdate(SaveOutcomeType.Created, Samples.GetDefaultObservation().UpdateId(id)); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(SaveOutcomeType.Created, result.Outcome.Outcome); @@ -66,7 +66,7 @@ public async Task GivenAResourceWithNoId_WhenUpsertingConditionallyWithOneMatch_ Samples.GetDefaultObservation(), mockResultEntry); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(SaveOutcomeType.Updated, result.Outcome.Outcome); @@ -89,7 +89,7 @@ public async Task GivenAResourceWithCorrectId_WhenUpsertingConditionallyWithOneM Samples.GetDefaultObservation().UpdateId(id), mockResultEntry); - UpsertResourceResponse result = await _mediator.Send(message); + UpsertResourceResponse result = await _mediator.SendAsync(message); Assert.Equal(SaveOutcomeType.Updated, result.Outcome.Outcome); @@ -108,7 +108,7 @@ public async Task GivenAResourceWithIncorrectId_WhenUpsertingConditionallyWithOn Samples.GetDefaultObservation().UpdateId(Guid.NewGuid().ToString()), mockResultEntry); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(async () => await _mediator.SendAsync(message)); } [Fact] @@ -123,7 +123,7 @@ public async Task GivenAResource_WhenUpsertingConditionallyWithMultipleMatches_T mockResultEntry1, mockResultEntry2); - await Assert.ThrowsAsync(() => _mediator.Send(message)); + await Assert.ThrowsAsync(async () => await _mediator.SendAsync(message)); } private ConditionalUpsertResourceRequest SetupConditionalUpdate( diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Upsert/ConditionalUpsertResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Upsert/ConditionalUpsertResourceHandlerTests.cs index a509e350b4..9681b37a1f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Upsert/ConditionalUpsertResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Upsert/ConditionalUpsertResourceHandlerTests.cs @@ -12,7 +12,7 @@ using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -89,11 +89,11 @@ public async Task GivenAConditionalUpsertResourceHandler_WhenUserHasSearchAndUpd var request = new ConditionalUpsertResourceRequest(patient, conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalUpsertHandler.Handle(request, CancellationToken.None); + await _conditionalUpsertHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Fact] @@ -120,11 +120,11 @@ public async Task GivenAConditionalUpsertResourceHandler_WhenUserHasLegacyReadAn var request = new ConditionalUpsertResourceRequest(patient, conditionalParameters, null); // Act & Assert - Should not throw UnauthorizedFhirActionException - await _conditionalUpsertHandler.Handle(request, CancellationToken.None); + await _conditionalUpsertHandler.HandleAsync(request, CancellationToken.None); await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } [Theory] @@ -156,7 +156,7 @@ public async Task GivenAConditionalUpsertResourceHandler_WhenUserhasInsufficient var request = new ConditionalUpsertResourceRequest(patient, conditionalParameters, null); // Act & Assert - await Assert.ThrowsAsync(() => _conditionalUpsertHandler.Handle(request, CancellationToken.None)); + await Assert.ThrowsAsync(() => _conditionalUpsertHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -186,12 +186,12 @@ public async Task GivenAConditionalUpsertResourceHandler_WhenNoMatchFoundAndReso var request = new ConditionalUpsertResourceRequest(patient.ToResourceElement(), conditionalParameters, null); // Act - await _conditionalUpsertHandler.Handle(request, CancellationToken.None); + await _conditionalUpsertHandler.HandleAsync(request, CancellationToken.None); // Assert - Should call create since no ID and no matches await _mediator .Received() - .Send(Arg.Any(), Arg.Any()); + .SendAsync(Arg.Any(), Arg.Any()); } private SearchResult GetSearchResult(ResourceElement resourceElement) diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/Behaviors/ListSearchBehaviorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/Behaviors/ListSearchBehaviorTests.cs index 74ae179b4d..1cd5a5bef2 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/Behaviors/ListSearchBehaviorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/Behaviors/ListSearchBehaviorTests.cs @@ -123,9 +123,9 @@ public async Task GivenARequest_WhenNoListQuery_QueriesUnchanged() var getResourceRequest = Substitute.For("Patient", list, false); - SearchResourceResponse response = await behavior.Handle( + SearchResourceResponse response = await behavior.HandleAsync( getResourceRequest, - (ct) => { return Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)); }, + () => Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)), CancellationToken.None); Assert.Equal(_nonEmptyBundle, response.Bundle); @@ -152,12 +152,9 @@ public async Task GivenARequest_WhenListValueMissing_EmptyResultsReturned() }; var getResourceRequest = Substitute.For("Patient", list, false); - SearchResourceResponse response = await behavior.Handle( + SearchResourceResponse response = await behavior.HandleAsync( getResourceRequest, - (ct) => - { - return Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)); - }, + () => Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)), CancellationToken.None); Assert.Equal(_nonEmptyBundle, response.Bundle); @@ -181,12 +178,9 @@ public async Task GivenARequest_WhenListValueExistsButValueNotFound_EmptyRespons var getResourceRequest = Substitute.For("Patient", list, false); Assert.True(getResourceRequest.Queries.Count == 3); - SearchResourceResponse response = await behavior.Handle( + SearchResourceResponse response = await behavior.HandleAsync( getResourceRequest, - (ct) => - { - return Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)); - }, + () => Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)), CancellationToken.None); var emptyResponse = behavior.CreateEmptySearchResponse(getResourceRequest); @@ -207,12 +201,9 @@ public async Task GivenARequest_WhenListValueFound_ExpectedIdQueriesAdded() Assert.Equal("_list", getResourceRequest.Queries[0].Item1); Assert.Equal("existing-list", getResourceRequest.Queries[0].Item2); - SearchResourceResponse response = await behavior.Handle( + SearchResourceResponse response = await behavior.HandleAsync( getResourceRequest, - (ct) => - { - return Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)); - }, + () => Task.FromResult(new SearchResourceResponse(_nonEmptyBundle)), CancellationToken.None); Assert.Single(getResourceRequest.Received().Queries); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchConverterForAllSearchTypes.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchConverterForAllSearchTypes.cs index b1ecedd605..9e086ba892 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchConverterForAllSearchTypes.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchConverterForAllSearchTypes.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading.Tasks; using Hl7.FhirPath.Expressions; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Definition; using Microsoft.Health.Fhir.Core.Features.Search; using Microsoft.Health.Fhir.Core.Features.Search.Converters; diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterBehaviorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterBehaviorTests.cs index d4f590343e..0e1198c1c7 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterBehaviorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterBehaviorTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ public async Task GivenACreateResourceRequest_WhenCreatingAResourceOtherThanSear var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created)); var behavior = new CreateOrUpdateSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); // Ensure for non-SearchParameter, that we do not call Add SearchParameter await _searchParameterOperations.DidNotReceive().AddSearchParameterAsync(Arg.Any(), Arg.Any()); @@ -91,7 +91,7 @@ public async Task GivenACreateResourceRequest_WhenCreatingASearchParameterResour var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created)); var behavior = new CreateOrUpdateSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); await _searchParameterOperations.Received().AddSearchParameterAsync(Arg.Any(), Arg.Any()); } @@ -110,7 +110,7 @@ public async Task GivenADeleteResourceRequest_WhenDeletingAResourceOtherThanSear var response = new DeleteResourceResponse(key); var behavior = new DeleteSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); // Ensure for non-SearchParameter, that we do not call Add SearchParameter await _searchParameterOperations.DidNotReceive().DeleteSearchParameterAsync(Arg.Any(), Arg.Any()); @@ -131,7 +131,7 @@ public async Task GivenADeleteResourceRequest_WhenDeletingASearchParameterResour var response = new DeleteResourceResponse(key); var behavior = new DeleteSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); await _searchParameterOperations.Received().DeleteSearchParameterAsync(Arg.Any(), Arg.Any()); } @@ -151,7 +151,7 @@ public async Task GivenADeleteResourceRequest_WhenDeletingAnAlreadyDeletedSearch var response = new DeleteResourceResponse(key); var behavior = new DeleteSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); await _searchParameterOperations.DidNotReceive().DeleteSearchParameterAsync(Arg.Any(), Arg.Any()); } @@ -172,7 +172,7 @@ public async Task GivenAnUpsertResourceRequest_WhenSearchParameterDoesNotExist_T var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created)); var behavior = new CreateOrUpdateSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); // Should call AddSearchParameterAsync since the resource doesn't exist await _searchParameterOperations.Received().AddSearchParameterAsync(Arg.Any(), Arg.Any()); @@ -199,7 +199,7 @@ public async Task GivenAnUpsertResourceRequest_WhenSearchParameterExists_ThenUpd var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(newWrapper), SaveOutcomeType.Updated)); var behavior = new CreateOrUpdateSearchParameterBehavior(_searchParameterOperations, _fhirDataStore); - await behavior.Handle(request, async (ct) => await Task.Run(() => response), CancellationToken.None); + await behavior.HandleAsync(request, async () => await Task.Run(() => response), CancellationToken.None); // Should call UpdateSearchParameterAsync since the resource exists await _searchParameterOperations.DidNotReceive().AddSearchParameterAsync(Arg.Any(), Arg.Any()); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs index 2808a6add8..b5bf5627c9 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -11,7 +11,7 @@ using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core.Features.Context; using Microsoft.Health.Extensions.DependencyInjection; @@ -415,7 +415,7 @@ public void GivenASearchParameterDefinitionManager_WhenGettingSearchParameterHas [Fact] public async Task GivenASPDefinitionManager_WhenInitialed_ThenSearchParametersHashHasValues() { - await _searchParameterDefinitionManager.Handle(new Messages.Search.SearchParametersUpdatedNotification(new List()), CancellationToken.None); + await _searchParameterDefinitionManager.HandleAsync(new Messages.Search.SearchParametersUpdatedNotification(new List()), CancellationToken.None); var searchParams = _searchParameterDefinitionManager.GetSearchParameters("Patient"); var patientHash = searchParams.CalculateSearchParameterHash(); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterFixtureData.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterFixtureData.cs index e9d5e93978..d2a3b2d60d 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterFixtureData.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterFixtureData.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Hl7.Fhir.FhirPath; using Hl7.FhirPath; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Fhir.Core.Features.Context; diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHandlerTests.cs index b37d636b24..b193028ad3 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -56,7 +56,7 @@ public async Task GivenASearchResourceRequest_WhenHandled_ThenABundleShouldBeRet _bundleFactory.CreateSearchBundle(searchResult).Returns(expectedBundle); - SearchResourceResponse actualResponse = await _searchResourceHandler.Handle(request, CancellationToken.None); + SearchResourceResponse actualResponse = await _searchResourceHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); @@ -83,7 +83,7 @@ public async Task GivenASearchResourceRequest_WhenUserHasSearchPermission_ThenSe _searchService.SearchAsync(request.ResourceType, request.Queries, CancellationToken.None).Returns(searchResult); _bundleFactory.CreateSearchBundle(searchResult).Returns(expectedBundle); - SearchResourceResponse actualResponse = await searchResourceHandler.Handle(request, CancellationToken.None); + SearchResourceResponse actualResponse = await searchResourceHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); @@ -108,7 +108,7 @@ public async Task GivenASearchResourceRequest_WhenUserHasOnlyReadPermission_Then var request = new SearchResourceRequest("Patient", null); await Assert.ThrowsAsync(() => - searchResourceHandler.Handle(request, CancellationToken.None)); + searchResourceHandler.HandleAsync(request, CancellationToken.None)); } [Fact] @@ -133,7 +133,7 @@ public async Task GivenASearchResourceRequest_WhenUserHasReadAndSearchPermission _searchService.SearchAsync(request.ResourceType, request.Queries, CancellationToken.None).Returns(searchResult); _bundleFactory.CreateSearchBundle(searchResult).Returns(expectedBundle); - SearchResourceResponse actualResponse = await searchResourceHandler.Handle(request, CancellationToken.None); + SearchResourceResponse actualResponse = await searchResourceHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); @@ -156,7 +156,7 @@ public async Task GivenASearchResourceRequest_WhenUserHasNoPermissions_ThenUnaut .Returns(DataActions.None); await Assert.ThrowsAsync(() => - searchResourceHandler.Handle(request, CancellationToken.None)); + searchResourceHandler.HandleAsync(request, CancellationToken.None)); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHistoryHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHistoryHandlerTests.cs index 3dab103a8b..c2027243ea 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHistoryHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchResourceHistoryHandlerTests.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- @@ -54,7 +54,7 @@ public async Task GivenASearchResourceHistoryRequest_WhenHandled_ThenABundleShou _bundleFactory.CreateHistoryBundle(searchResult).Returns(expectedBundle); - SearchResourceHistoryResponse actualResponse = await _searchResourceHistoryHandler.Handle(request, CancellationToken.None); + SearchResourceHistoryResponse actualResponse = await _searchResourceHistoryHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); @@ -85,7 +85,7 @@ public async Task GivenASearchResourceHistoryRequest_WhenUserHasReadPermission_T _bundleFactory.CreateHistoryBundle(searchResult).Returns(expectedBundle); // Act & Assert - Should not throw UnauthorizedFhirActionException - var actualResponse = await searchResourceHistoryHandler.Handle(request, CancellationToken.None); + var actualResponse = await searchResourceHistoryHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(actualResponse); Assert.Equal(expectedBundle, actualResponse.Bundle); @@ -113,7 +113,7 @@ public async Task GivenASearchResourceHistoryRequest_WhenUserLacksPermissions_Th // Act & Assert await Assert.ThrowsAsync(() => - searchResourceHistoryHandler.Handle(request, CancellationToken.None)); + searchResourceHistoryHandler.HandleAsync(request, CancellationToken.None)); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateCapabilityPreProcessorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateCapabilityPreProcessorTests.cs index b9764c8984..17042b16f3 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateCapabilityPreProcessorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateCapabilityPreProcessorTests.cs @@ -4,12 +4,14 @@ // ------------------------------------------------------------------------------------------------- using System; +using System.Net.Http; using System.Threading; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; using Microsoft.Health.Fhir.Core.Features.Conformance; +using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Features.Validation; using Microsoft.Health.Fhir.Core.Messages.Delete; using Microsoft.Health.Fhir.Core.Messages.Get; @@ -44,11 +46,13 @@ public ValidateCapabilityPreProcessorTests() [Fact] public async Task GivenARequest_WhenValidatingCapability_ThenAllValidationRulesShouldRun() { - var preProcessor = new ValidateCapabilityPreProcessor(_conformanceProvider); + var preProcessor = new ValidateCapabilityPreProcessor(_conformanceProvider); var getResourceRequest = new GetResourceRequest("Observation", Guid.NewGuid().ToString(), bundleResourceContext: null); + var resource = Samples.GetDefaultObservation().UpdateId("observation1"); + var mockResponse = new GetResourceResponse(CreateRawResourceElement(resource)); - await preProcessor.Process(getResourceRequest, CancellationToken.None); + await preProcessor.HandleAsync(getResourceRequest, () => Task.FromResult(mockResponse), CancellationToken.None); } [Theory] @@ -56,11 +60,30 @@ public async Task GivenARequest_WhenValidatingCapability_ThenAllValidationRulesS [InlineData(DeleteOperation.HardDelete)] public async Task GivenARequestNotAllowed_WhenValidatingCapability_ThenMethodNotAllowedExceptionShouldThrow(DeleteOperation deleteOperation) { - var preProcessor = new ValidateCapabilityPreProcessor(_conformanceProvider); + var preProcessor = new ValidateCapabilityPreProcessor(_conformanceProvider); var deleteResourceRequest = new DeleteResourceRequest("Observation", Guid.NewGuid().ToString(), deleteOperation, bundleResourceContext: null); - await Assert.ThrowsAsync(async () => await preProcessor.Process(deleteResourceRequest, CancellationToken.None)); + await Assert.ThrowsAsync( + async () => await preProcessor.HandleAsync( + deleteResourceRequest, + () => Task.FromResult(new DeleteResourceResponse(new ResourceKey("Observation", "test-id"))), + CancellationToken.None)); + } + + private static RawResourceElement CreateRawResourceElement(ResourceElement resource) + { + var rawResource = new RawResource("data", FhirResourceFormat.Json, isMetaSet: true); + var wrapper = new ResourceWrapper( + resource, + rawResource, + new ResourceRequest(HttpMethod.Post, "http://fhir"), + deleted: false, + searchIndices: null, + compartmentIndices: null, + lastModifiedClaims: null); + + return new RawResourceElement(wrapper); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateRequestPreProcessorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateRequestPreProcessorTests.cs index a961cb89a2..5c79adf1f1 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateRequestPreProcessorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Validation/ValidateRequestPreProcessorTests.cs @@ -3,10 +3,14 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using FluentValidation; using FluentValidation.Results; +using Medino; +using Microsoft.Health.Fhir.Core.Extensions; +using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.Core.Features.Validation; using Microsoft.Health.Fhir.Core.Messages.Upsert; using Microsoft.Health.Fhir.Core.Models; @@ -28,17 +32,22 @@ public async Task GivenARequest_WhenValidatingThatType_ThenAllValidationRulesSho var mockValidator2 = Substitute.For>(); var validators = new[] { mockValidator1, mockValidator2 }; - var upsertValidationHandler = new ValidateRequestPreProcessor(validators); - var upsertResourceRequest = new UpsertResourceRequest(Samples.GetDefaultObservation()); + var upsertValidationHandler = new ValidateRequestPreProcessor(validators); + var resource = Samples.GetDefaultObservation().UpdateId("observation1"); + var upsertResourceRequest = new UpsertResourceRequest(resource); + var mockResponse = new UpsertResourceResponse(new SaveOutcome(CreateRawResourceElement(resource), SaveOutcomeType.Created)); - await upsertValidationHandler.Process(upsertResourceRequest, CancellationToken.None); + await upsertValidationHandler.HandleAsync( + upsertResourceRequest, + () => Task.FromResult(mockResponse), + CancellationToken.None); await mockValidator1.Received().ValidateAsync( Arg.Is>(ctx => ctx.InstanceToValidate == upsertResourceRequest), - Arg.Is(ct => ct == CancellationToken.None)); + Arg.Any()); await mockValidator2.Received().ValidateAsync( Arg.Is>(ctx => ctx.InstanceToValidate == upsertResourceRequest), - Arg.Is(ct => ct == CancellationToken.None)); + Arg.Any()); } [Fact] @@ -48,19 +57,23 @@ public async Task GivenARequest_WhenValidatingThatTypeWithFailingRule_ThenAValid var mockValidator2 = Substitute.For>(); var validators = new[] { mockValidator1, mockValidator2 }; - var upsertValidationHandler = new ValidateRequestPreProcessor(validators); - var upsertResourceRequest = new UpsertResourceRequest(Samples.GetDefaultObservation()); + var upsertValidationHandler = new ValidateRequestPreProcessor(validators); + var resource = Samples.GetDefaultObservation().UpdateId("observation1"); + var upsertResourceRequest = new UpsertResourceRequest(resource); var validationError = Task.FromResult(new ValidationResult(new[] { new ValidationFailure("Id", "Id should not be null") })); mockValidator2 .ValidateAsync( Arg.Is>(ctx => ctx.InstanceToValidate == upsertResourceRequest), - Arg.Is(ct => ct == CancellationToken.None)) + Arg.Any()) .Returns(validationError); await Assert.ThrowsAsync( - async () => await upsertValidationHandler.Process(upsertResourceRequest, CancellationToken.None)); + async () => await upsertValidationHandler.HandleAsync( + upsertResourceRequest, + () => Task.FromResult(new UpsertResourceResponse(new SaveOutcome(CreateRawResourceElement(resource), SaveOutcomeType.Created))), + CancellationToken.None)); } [Fact] @@ -69,8 +82,9 @@ public async Task GivenARequest_WhenReturningFhirValidationFailure_ThenOperation var mockValidator = Substitute.For>(); var validators = new[] { mockValidator }; - var upsertValidationHandler = new ValidateRequestPreProcessor(validators); - var upsertResourceRequest = new UpsertResourceRequest(Samples.GetDefaultObservation()); + var upsertValidationHandler = new ValidateRequestPreProcessor(validators); + var resource = Samples.GetDefaultObservation().UpdateId("observation1"); + var upsertResourceRequest = new UpsertResourceRequest(resource); var operationOutcomeIssue = new OperationOutcomeIssue( OperationOutcomeConstants.IssueSeverity.Error, @@ -83,13 +97,31 @@ public async Task GivenARequest_WhenReturningFhirValidationFailure_ThenOperation mockValidator .ValidateAsync( Arg.Is>(ctx => ctx.InstanceToValidate == upsertResourceRequest), - Arg.Is(ct => ct == CancellationToken.None)) + Arg.Any()) .Returns(Task.FromResult(validationError)); var exception = await Assert.ThrowsAsync( - async () => await upsertValidationHandler.Process(upsertResourceRequest, CancellationToken.None)); + async () => await upsertValidationHandler.HandleAsync( + upsertResourceRequest, + () => Task.FromResult(new UpsertResourceResponse(new SaveOutcome(CreateRawResourceElement(resource), SaveOutcomeType.Created))), + CancellationToken.None)); Assert.Contains(operationOutcomeIssue, exception.Issues); } + + private static RawResourceElement CreateRawResourceElement(ResourceElement resource) + { + var rawResource = new RawResource("data", FhirResourceFormat.Json, isMetaSet: true); + var wrapper = new ResourceWrapper( + resource, + rawResource, + new ResourceRequest(HttpMethod.Post, "http://fhir"), + deleted: false, + searchIndices: null, + compartmentIndices: null, + lastModifiedClaims: null); + + return new RawResourceElement(wrapper); + } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/FhirMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/FhirMediatorExtensions.cs index 3e52301f8d..a654826e1a 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/FhirMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/FhirMediatorExtensions.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations; using Microsoft.Health.Fhir.Core.Features.Operations.Versions; using Microsoft.Health.Fhir.Core.Features.Persistence; @@ -35,7 +35,7 @@ public static async Task CreateResourceAsync(this IMediator EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(createResourceRequest, nameof(createResourceRequest)); - UpsertResourceResponse result = await mediator.Send(createResourceRequest, cancellationToken); + UpsertResourceResponse result = await mediator.SendAsync(createResourceRequest, cancellationToken); return result.Outcome.RawResourceElement; } @@ -50,7 +50,7 @@ public static async Task UpsertResourceAsync(this IMediator mediato EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(upsertResourceRequest, nameof(upsertResourceRequest)); - UpsertResourceResponse result = await mediator.Send(upsertResourceRequest, cancellationToken); + UpsertResourceResponse result = await mediator.SendAsync(upsertResourceRequest, cancellationToken); return result.Outcome; } @@ -65,7 +65,7 @@ public static async Task GetResourceAsync(this IMediator med EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(getResourceRequest, nameof(getResourceRequest)); - GetResourceResponse result = await mediator.Send(getResourceRequest, cancellationToken); + GetResourceResponse result = await mediator.SendAsync(getResourceRequest, cancellationToken); return result.Resource; } @@ -80,7 +80,7 @@ public static async Task DeleteResourceAsync(this IMedia EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(deleteResourceRequest, nameof(deleteResourceRequest)); - var result = await mediator.Send(deleteResourceRequest, cancellationToken); + var result = await mediator.SendAsync(deleteResourceRequest, cancellationToken); return result; } @@ -90,7 +90,7 @@ public static async Task PatchResourceAsync(this IMediat EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(patchResourceRequest, nameof(patchResourceRequest)); - UpsertResourceResponse result = await mediator.Send(patchResourceRequest, cancellationToken); + UpsertResourceResponse result = await mediator.SendAsync(patchResourceRequest, cancellationToken); return result; } @@ -100,7 +100,7 @@ public static async Task ConditionalPatchResourceAsync(t EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(conditionalPatchResourceRequest, nameof(conditionalPatchResourceRequest)); - UpsertResourceResponse result = await mediator.Send(conditionalPatchResourceRequest, cancellationToken); + UpsertResourceResponse result = await mediator.SendAsync(conditionalPatchResourceRequest, cancellationToken); return result; } @@ -109,7 +109,7 @@ public static async Task SearchResourceAsync(this IMediator med { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchResourceRequest(type, queries), cancellationToken); + var result = await mediator.SendAsync(new SearchResourceRequest(type, queries), cancellationToken); return result.Bundle; } @@ -118,7 +118,7 @@ public static async Task SearchResourceHistoryAsync(this IMedia { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchResourceHistoryRequest(since, before, at, count, summary, continuationToken, sort), cancellationToken); + var result = await mediator.SendAsync(new SearchResourceHistoryRequest(since, before, at, count, summary, continuationToken, sort), cancellationToken); return result.Bundle; } @@ -127,7 +127,7 @@ public static async Task SearchResourceHistoryAsync(this IMedia { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchResourceHistoryRequest(resourceType, since, before, at, count, summary, continuationToken, sort), cancellationToken); + var result = await mediator.SendAsync(new SearchResourceHistoryRequest(resourceType, since, before, at, count, summary, continuationToken, sort), cancellationToken); return result.Bundle; } @@ -136,7 +136,7 @@ public static async Task SearchResourceHistoryAsync(this IMedia { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchResourceHistoryRequest(resourceType, resourceId, since, before, at, count, summary, continuationToken, sort), cancellationToken); + var result = await mediator.SendAsync(new SearchResourceHistoryRequest(resourceType, resourceId, since, before, at, count, summary, continuationToken, sort), cancellationToken); return result.Bundle; } @@ -145,7 +145,7 @@ public static async Task SearchResourceCompartmentAsync(this IM { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchCompartmentRequest(compartmentType, compartmentId, resourceType, queries), cancellationToken); + var result = await mediator.SendAsync(new SearchCompartmentRequest(compartmentType, compartmentId, resourceType, queries), cancellationToken); return result.Bundle; } @@ -154,7 +154,7 @@ public static async Task SearchIncludeResourceAsync(this IMedia { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var result = await mediator.Send(new SearchResourceRequest(type, queries, true), cancellationToken); + var result = await mediator.SendAsync(new SearchResourceRequest(type, queries, true), cancellationToken); return result.Bundle; } @@ -163,7 +163,7 @@ public static async Task GetCapabilitiesAsync(this IMediator me { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var response = await mediator.Send(new GetCapabilitiesRequest(), cancellationToken); + var response = await mediator.SendAsync(new GetCapabilitiesRequest(), cancellationToken); return response.CapabilityStatement; } @@ -171,7 +171,7 @@ public static async Task GetSmartConfigurationAsync(th { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var response = await mediator.Send(new GetSmartConfigurationRequest(), cancellationToken); + var response = await mediator.SendAsync(new GetSmartConfigurationRequest(), cancellationToken); return new SmartConfigurationResult(response.AuthorizationEndpoint, response.TokenEndpoint, response.Capabilities, response.ScopesSupported); } @@ -180,7 +180,7 @@ public static async Task GetOperationVersionsAsync(this IMediato { EnsureArg.IsNotNull(mediator, nameof(mediator)); - var response = await mediator.Send(new GetOperationVersionsRequest(), cancellationToken); + var response = await mediator.SendAsync(new GetOperationVersionsRequest(), cancellationToken); return new VersionsResult(response.SupportedVersions, response.DefaultVersion); } @@ -190,7 +190,7 @@ public static async Task PostBundle(this IMediator mediator, Re EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(bundle, nameof(bundle)); - BundleResponse result = await mediator.Send(new BundleRequest(bundle), cancellationToken); + BundleResponse result = await mediator.SendAsync(new BundleRequest(bundle), cancellationToken); return result.Bundle; } diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/OperationDefinitionMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/OperationDefinitionMediatorExtensions.cs index 2f829bdd49..99a3edcc59 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/OperationDefinitionMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/OperationDefinitionMediatorExtensions.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Messages.Operation; namespace Microsoft.Health.Fhir.Shared.Core.Extensions @@ -18,7 +18,7 @@ public static async Task GetOperationDefinitionAsyn EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNullOrWhiteSpace(operationName, nameof(operationName)); - return await mediator.Send(new OperationDefinitionRequest(operationName), cancellationToken); + return await mediator.SendAsync(new OperationDefinitionRequest(operationName), cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/ReindexMediatorExtensions.cs b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/ReindexMediatorExtensions.cs index 00081220c6..bc155f12a5 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Extensions/ReindexMediatorExtensions.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Extensions/ReindexMediatorExtensions.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Messages.Reindex; using Microsoft.Health.Fhir.Core.Models; @@ -58,7 +58,7 @@ public static async Task CreateReindexJobAsync( var request = new CreateReindexRequest(targetResourceTypes, targetSearchParamTypes, maxResourcesPerQuery, maxResourcesPerWrite, queryDelay, targetDataStoreResourcePercentage); - CreateReindexResponse response = await mediator.Send(request, cancellationToken); + CreateReindexResponse response = await mediator.SendAsync(request, cancellationToken); return response.Job.ToParametersResourceElement(); } @@ -73,7 +73,7 @@ public static async Task SendReindexSingleResourc var request = new ReindexSingleResourceRequest(httpMethod, resourceType, resourceId); - ReindexSingleResourceResponse response = await mediator.Send(request, cancellationToken); + ReindexSingleResourceResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -83,7 +83,7 @@ public static async Task GetReindexJobAsync(this IMediator medi var request = new GetReindexRequest(jobId); - GetReindexResponse response = await mediator.Send(request, cancellationToken); + GetReindexResponse response = await mediator.SendAsync(request, cancellationToken); return response.Job.ToParametersResourceElement(); } @@ -94,7 +94,7 @@ public static async Task CancelReindexAsync(this IMediator medi var request = new CancelReindexRequest(jobId); - var response = await mediator.Send(request, cancellationToken); + var response = await mediator.SendAsync(request, cancellationToken); return response.Job.ToParametersResourceElement(); } diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/DocRefRequestConverter.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/DocRefRequestConverter.cs index 35bdfcb2dc..5b2ceeff7f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/DocRefRequestConverter.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/DocRefRequestConverter.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Fhir.Core; using Microsoft.Health.Fhir.Core.Exceptions; diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/TerminologyRequestHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/TerminologyRequestHandler.cs index fd8d5060b0..366213bbc5 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/TerminologyRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Conformance/TerminologyRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -45,7 +45,7 @@ public TerminologyRequestHandler( _logger = logger; } - public async Task Handle( + public async Task HandleAsync( ExpandRequest request, CancellationToken cancellationToken) { diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Everything/EverythingOperationHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Everything/EverythingOperationHandler.cs index a7bf284dbd..837d082172 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Everything/EverythingOperationHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Everything/EverythingOperationHandler.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Search; @@ -39,7 +39,7 @@ public EverythingOperationHandler(IPatientEverythingService patientEverythingSer _dataResourceFilter = dataResourceFilter; } - public async Task Handle(EverythingOperationRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(EverythingOperationRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/MemberMatch/MemberMatchHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/MemberMatch/MemberMatchHandler.cs index eb907cae14..403b973902 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/MemberMatch/MemberMatchHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/MemberMatch/MemberMatchHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -30,7 +30,7 @@ public MemberMatchHandler( _authorizationService = authorizationService; } - public async Task Handle(MemberMatchRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(MemberMatchRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Reindex/ReindexSingleResourceRequestHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Reindex/ReindexSingleResourceRequestHandler.cs index 0043ec0827..c25bbc64be 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Reindex/ReindexSingleResourceRequestHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/Reindex/ReindexSingleResourceRequestHandler.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -57,7 +57,7 @@ public ReindexSingleResourceRequestHandler( _searchParameterDefinitionManager = searchParameterDefinitionManager; } - public async Task Handle(ReindexSingleResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(ReindexSingleResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateHandler.cs index 7b334b47f2..00042dc281 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateHandler.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -40,7 +40,7 @@ public SearchParameterStateHandler(IAuthorizationService authorizat _searchParameterStatusManager = searchParameterStatusManager; } - public async Task Handle(SearchParameterStateRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(SearchParameterStateRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandler.cs index 70f7336d51..3c96e2b5b4 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Operations/SearchParameterState/SearchParameterStateUpdateHandler.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core; using Microsoft.Health.Core.Features.Audit; @@ -57,7 +57,7 @@ public SearchParameterStateUpdateHandler(IAuthorizationService auth _fhirOperationDataStoreFactory = fhirOperationDataStoreFactory; } - public async Task Handle(SearchParameterStateUpdateRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(SearchParameterStateUpdateRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/ConditionalResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/ConditionalResourceHandler.cs index 39f00e559a..bffa3b71c1 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/ConditionalResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/ConditionalResourceHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -45,7 +45,7 @@ protected ConditionalResourceHandler( _logger = logger; } - public async Task Handle(TRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(TRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/ConditionalCreateResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/ConditionalCreateResourceHandler.cs index fe3252011c..60cdd84e2f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/ConditionalCreateResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/ConditionalCreateResourceHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Build.Framework; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; @@ -43,7 +43,7 @@ public ConditionalCreateResourceHandler( public override async Task HandleNoMatch(ConditionalCreateResourceRequest request, CancellationToken cancellationToken) { - return await _mediator.Send(new CreateResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); + return await _mediator.SendAsync(new CreateResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); } public override Task HandleSingleMatch(ConditionalCreateResourceRequest request, SearchResultEntry match, CancellationToken cancellationToken) diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/CreateResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/CreateResourceHandler.cs index 1f3c95602f..ddc14c786f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/CreateResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Create/CreateResourceHandler.cs @@ -10,7 +10,7 @@ using EnsureThat; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -43,7 +43,7 @@ public CreateResourceHandler( _referenceIdDictionary = new Dictionary(); } - public async Task Handle(CreateResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(CreateResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/ConditionalDeleteResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/ConditionalDeleteResourceHandler.cs index c6f0ba2e6d..1894efd258 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/ConditionalDeleteResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/ConditionalDeleteResourceHandler.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Build.Framework; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -63,7 +63,7 @@ public ConditionalDeleteResourceHandler( _logger = logger; } - public async Task Handle(ConditionalDeleteResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(ConditionalDeleteResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeleteResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeleteResourceHandler.cs index 85af63426e..0aa7416f08 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeleteResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Delete/DeleteResourceHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; @@ -35,7 +35,7 @@ public DeleteResourceHandler( _deleter = EnsureArg.IsNotNull(deleter, nameof(deleter)); } - public async Task Handle(DeleteResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(DeleteResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Get/GetResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Get/GetResourceHandler.cs index c35120dea3..aa7b1b6b85 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Get/GetResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Get/GetResourceHandler.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Context; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -45,7 +45,7 @@ public GetResourceHandler( _searchService = EnsureArg.IsNotNull(searchService, nameof(searchService)); } - public async Task Handle(GetResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(GetResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/ConditionalPatchResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/ConditionalPatchResourceHandler.cs index 41154b40a6..214029daf4 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/ConditionalPatchResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/ConditionalPatchResourceHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Build.Framework; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; @@ -63,7 +63,7 @@ public override async Task HandleSingleMatch(Conditional } var patchedResource = request.Payload.Patch(match.Resource); - return await _mediator.Send(new UpsertResourceRequest(patchedResource, bundleResourceContext: null), cancellationToken); + return await _mediator.SendAsync(new UpsertResourceRequest(patchedResource, bundleResourceContext: null), cancellationToken); } /// diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/PatchResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/PatchResourceHandler.cs index e1c91a7a9d..b43258fb46 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/PatchResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Patch/PatchResourceHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -42,7 +42,7 @@ public PatchResourceHandler( _logger = logger; } - public async Task Handle(PatchResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(PatchResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); @@ -79,7 +79,7 @@ public async Task Handle(PatchResourceRequest request, C } ResourceElement patchedResource = request.Payload.Patch(currentDoc); - return await _mediator.Send(new UpsertResourceRequest(patchedResource, request.BundleResourceContext, request.WeakETag), cancellationToken); + return await _mediator.SendAsync(new UpsertResourceRequest(patchedResource, request.BundleResourceContext, request.WeakETag), cancellationToken); } } } diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/ConditionalUpsertResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/ConditionalUpsertResourceHandler.cs index c19c35dd85..b2c0106727 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/ConditionalUpsertResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/ConditionalUpsertResourceHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using EnsureThat; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Build.Framework; using Microsoft.Extensions.Logging; using Microsoft.Health.Core.Features.Security.Authorization; @@ -51,13 +51,13 @@ public override async Task HandleNoMatch(ConditionalUpse { // No matches, no id provided: The server creates the resource // TODO: There is a potential contention issue here in that this could create another new resource with a different id - return await _mediator.Send(new CreateResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); + return await _mediator.SendAsync(new CreateResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); } else { // No matches, id provided: The server treats the interaction as an Update as Create interaction (or rejects it, if it does not support Update as Create) // TODO: There is a potential contention issue here that this could replace an existing resource - return await _mediator.Send(new UpsertResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); + return await _mediator.SendAsync(new UpsertResourceRequest(request.Resource, request.BundleResourceContext), cancellationToken); } } @@ -71,7 +71,7 @@ public override async Task HandleSingleMatch(Conditional if (string.IsNullOrEmpty(resource.Id) || string.Equals(resource.Id, resourceWrapper.ResourceId, StringComparison.Ordinal)) { resource.Id = resourceWrapper.ResourceId; - return await _mediator.Send(new UpsertResourceRequest(resource.ToResourceElement(), request.BundleResourceContext, version), cancellationToken); + return await _mediator.SendAsync(new UpsertResourceRequest(resource.ToResourceElement(), request.BundleResourceContext, version), cancellationToken); } else { diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/UpsertResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/UpsertResourceHandler.cs index f725fa09f4..710218c5ae 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/UpsertResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Resources/Upsert/UpsertResourceHandler.cs @@ -11,7 +11,7 @@ using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Hl7.Fhir.Rest; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Context; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; @@ -56,7 +56,7 @@ public UpsertResourceHandler( _referenceIdDictionary = new Dictionary(); } - public async Task Handle(UpsertResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(UpsertResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/Behaviors/ListSearchPipeBehavior.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/Behaviors/ListSearchPipeBehavior.cs index b41f70177e..df79489617 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/Behaviors/ListSearchPipeBehavior.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/Behaviors/ListSearchPipeBehavior.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Extensions; using Microsoft.Health.Fhir.Core.Features.Persistence; @@ -50,7 +50,7 @@ public ListSearchPipeBehavior( _referenceSearchValueParser = referenceSearchValueParser; } - public async Task Handle(SearchResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task HandleAsync(SearchResourceRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); @@ -60,7 +60,7 @@ public async Task Handle(SearchResourceRequest request, // if _list was not requested, or _list was requested with invalid value, continue... if ((listParameter == null) || string.IsNullOrWhiteSpace(listParameter.Item2)) { - return await next(cancellationToken); + return await next(); } ResourceWrapper listWrapper = @@ -92,7 +92,7 @@ public async Task Handle(SearchResourceRequest request, query = query.Concat(new[] { Tuple.Create(KnownQueryParameterNames.Id, string.Join(",", references.Select(x => x.ResourceId))) }); request.Queries = query.ToArray(); - return await next(cancellationToken); + return await next(); } public SearchResourceResponse CreateEmptySearchResponse(SearchResourceRequest request) diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHandler.cs index c6a1037445..e6a89aeb09 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -46,7 +46,7 @@ public SearchResourceHandler(ISearchService searchService, IBundleFactory bundle } /// - public async Task Handle(SearchResourceRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(SearchResourceRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHistoryHandler.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHistoryHandler.cs index ba6a397ac3..84260b0ca6 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHistoryHandler.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchResourceHistoryHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Core.Features.Security.Authorization; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Features.Security; @@ -35,7 +35,7 @@ public SearchResourceHistoryHandler(ISearchService searchService, IBundleFactory _dataResourceFilter = dataResourceFilter; } - public async Task Handle(SearchResourceHistoryRequest request, CancellationToken cancellationToken) + public async Task HandleAsync(SearchResourceHistoryRequest request, CancellationToken cancellationToken) { EnsureArg.IsNotNull(request, nameof(request)); diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Validation/ServerProvideProfileValidation.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Validation/ServerProvideProfileValidation.cs index 2da853d55a..3b366c3438 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Validation/ServerProvideProfileValidation.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Validation/ServerProvideProfileValidation.cs @@ -17,7 +17,7 @@ using Hl7.Fhir.Serialization; using Hl7.Fhir.Specification.Source; using Hl7.Fhir.Specification.Summary; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Health.Core.Extensions; @@ -108,7 +108,7 @@ private async Task> ListSummariesAsync(Cancellation if (newHash != oldHash) { _logger.LogDebug("New Profiles found."); - await _mediator.Publish(new RebuildCapabilityStatement(RebuildPart.Profiles)); + await _mediator.PublishAsync(new RebuildCapabilityStatement(RebuildPart.Profiles)); } _logger.LogDebug("Profiles updated."); diff --git a/src/Microsoft.Health.Fhir.Shared.Web/Startup.cs b/src/Microsoft.Health.Fhir.Shared.Web/Startup.cs index 3e95679fc1..48eaf49fff 100644 --- a/src/Microsoft.Health.Fhir.Shared.Web/Startup.cs +++ b/src/Microsoft.Health.Fhir.Shared.Web/Startup.cs @@ -9,7 +9,7 @@ using System.Globalization; using System.Linq; using Azure.Monitor.OpenTelemetry.AspNetCore; -using MediatR; +using Medino; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; diff --git a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportOrchestratorJobTests.cs b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportOrchestratorJobTests.cs index 93e6dd1d35..113ed177bb 100644 --- a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportOrchestratorJobTests.cs +++ b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportOrchestratorJobTests.cs @@ -9,7 +9,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; @@ -84,7 +84,7 @@ public async Task GivenAnOrchestratorJobAndWrongEtag_WhenOrchestratorJobStart_Th Assert.Equal(HttpStatusCode.BadRequest, resultDetails.HttpStatusCode); Assert.NotEmpty(resultDetails.ErrorMessage); - _ = mediator.Received().Publish( + _ = mediator.Received().PublishAsync( Arg.Is( notification => notification.Id == orchestratorJobInfo.Id.ToString() && notification.Status == JobStatus.Failed.ToString() && @@ -177,7 +177,7 @@ public async Task GivenAnOrchestratorJob_WhenIntegrationExceptionThrown_ThenJobS Assert.Equal(HttpStatusCode.Unauthorized, resultDetails.HttpStatusCode); Assert.NotEmpty(resultDetails.ErrorMessage); - _ = mediator.Received().Publish( + _ = mediator.Received().PublishAsync( Arg.Is( notification => notification.Id == orchestratorJobInfo.Id.ToString() && notification.Status == JobStatus.Failed.ToString() && diff --git a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportProcessingJobTests.cs b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportProcessingJobTests.cs index b569dd4b21..7873e82dc8 100644 --- a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportProcessingJobTests.cs +++ b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Operations/Import/ImportProcessingJobTests.cs @@ -10,7 +10,7 @@ using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Core.Features.Context; diff --git a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/Expressions/IncludeRewriterTests.cs b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/Expressions/IncludeRewriterTests.cs index a5aacb6c31..4dfb489fc8 100644 --- a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/Expressions/IncludeRewriterTests.cs +++ b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/Expressions/IncludeRewriterTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Health.Fhir.Core.Features.Definition; using Microsoft.Health.Fhir.Core.Features.Persistence; diff --git a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Storage/SqlExceptionActionProcessorTests.cs b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Storage/SqlExceptionActionProcessorTests.cs index e577bf33b0..bdad09b2d0 100644 --- a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Storage/SqlExceptionActionProcessorTests.cs +++ b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Storage/SqlExceptionActionProcessorTests.cs @@ -45,7 +45,7 @@ public async Task GivenSqlTruncateException_WhenExecuting_ThenResourceSqlTruncat // Act & Assert var exception = await Assert.ThrowsAsync(() => - processor.Execute("test-request", sqlTruncateException, CancellationToken.None)); + processor.ExecuteAsync("test-request", sqlTruncateException, CancellationToken.None)); Assert.Equal("Truncate error", exception.Message); @@ -69,7 +69,7 @@ public async Task GivenSqlException_WhenExecuting_ThenSpecificExceptionIsThrown( // Act & Assert await Assert.ThrowsAsync(expectedExceptionType, () => - processor.Execute("test-request", sqlException, CancellationToken.None)); + processor.ExecuteAsync("test-request", sqlException, CancellationToken.None)); // Verify logger _mockLogger.Received(1).LogError( @@ -90,7 +90,7 @@ public async Task GivenSqlExceptionWithCmkError_WhenExecuting_ThenCustomerManage // Act & Assert var exception = await Assert.ThrowsAsync(() => - processor.Execute("test-request", sqlException, CancellationToken.None)); + processor.ExecuteAsync("test-request", sqlException, CancellationToken.None)); Assert.Equal(Core.Resources.OperationFailedForCustomerManagedKey, exception.Message); @@ -109,7 +109,7 @@ public async Task GivenSqlExceptionWithUnhandledError_WhenExecuting_ThenResource // Act & Assert var exception = await Assert.ThrowsAsync(() => - processor.Execute("test-request", sqlException, CancellationToken.None)); + processor.ExecuteAsync("test-request", sqlException, CancellationToken.None)); Assert.Equal(Core.Resources.InternalServerError, exception.Message); diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportOrchestratorJob.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportOrchestratorJob.cs index 5a38770ef9..2a0c48c8aa 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportOrchestratorJob.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportOrchestratorJob.cs @@ -15,7 +15,7 @@ using EnsureThat; using Hl7.Fhir.Rest; using Hl7.Fhir.Utility; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -232,7 +232,7 @@ internal static async Task SendNotification(JobStatus status, JobInfo info, l failed, importMode); - await mediator.Publish(importJobMetricsNotification, CancellationToken.None); + await mediator.PublishAsync(importJobMetricsNotification, CancellationToken.None); } private async Task EnqueueProcessingJobsAsync(JobInfo coord, ImportOrchestratorJobDefinition coordDefinition, ImportOrchestratorJobResult result, CancellationToken cancellationToken) diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportProcessingJob.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportProcessingJob.cs index 13a32902eb..e7bb651650 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportProcessingJob.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Operations/Import/ImportProcessingJob.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; using Azure; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SchemaUpgradedHandler.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SchemaUpgradedHandler.cs index 91f2fa0ed9..e2617d9541 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SchemaUpgradedHandler.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SchemaUpgradedHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.SqlServer.Features.Schema.Messages.Notifications; namespace Microsoft.Health.Fhir.SqlServer.Features.Storage @@ -22,7 +22,7 @@ public SchemaUpgradedHandler(SqlServerFhirModel sqlServerFhirModel) _sqlServerFhirModel = sqlServerFhirModel; } - public async Task Handle(SchemaUpgradedNotification notification, CancellationToken cancellationToken) + public async Task HandleAsync(SchemaUpgradedNotification notification, CancellationToken cancellationToken) { EnsureArg.IsNotNull(notification, nameof(notification)); diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlExceptionActionProcessor.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlExceptionActionProcessor.cs index 6813daa591..41f98fbb7e 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlExceptionActionProcessor.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlExceptionActionProcessor.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR.Pipeline; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging; using Microsoft.Health.Fhir.Core.Exceptions; @@ -18,7 +17,14 @@ namespace Microsoft.Health.Fhir.SqlServer.Features.Storage { - public class SqlExceptionActionProcessor : IRequestExceptionAction + /// + /// Utility class for handling SQL-specific exceptions and converting them to FHIR exceptions. + /// Note: IRequestExceptionAction interface was removed in new Medino version. + /// This class is kept as a utility for future integration with exception handling middleware. + /// + /// The request type associated with the exception. + /// The exception type to handle. + public class SqlExceptionActionProcessor where TException : Exception { private readonly ILogger> _logger; @@ -29,7 +35,7 @@ public SqlExceptionActionProcessor(ILogger)) .Transient() - .AsSelf() - .AsService(typeof(IRequestExceptionAction<,>)); + .AsSelf(); services.Add() .Singleton() @@ -185,7 +185,7 @@ public static IFhirServerBuilder AddSqlServer(this IFhirServerBuilder fhirServer services.Add().Singleton().AsSelf(); - services.RemoveServiceTypeExact>() // Mediatr registers handlers as Transient by default, this extension ensures these aren't still there, only needed when service != Transient + services.RemoveServiceTypeExact>() // Medino registers handlers as Transient by default, this extension ensures these aren't still there, only needed when service != Transient .Add() .Singleton() .AsSelf() // this is needed to create the instance the delegates resolve diff --git a/src/Microsoft.Health.Fhir.Stu3.Api/Microsoft.Health.Fhir.Stu3.Api.csproj b/src/Microsoft.Health.Fhir.Stu3.Api/Microsoft.Health.Fhir.Stu3.Api.csproj index d5f6bee4ff..de013f88ae 100644 --- a/src/Microsoft.Health.Fhir.Stu3.Api/Microsoft.Health.Fhir.Stu3.Api.csproj +++ b/src/Microsoft.Health.Fhir.Stu3.Api/Microsoft.Health.Fhir.Stu3.Api.csproj @@ -17,7 +17,8 @@ - + + diff --git a/src/Microsoft.Health.Fhir.Stu3.Core/Microsoft.Health.Fhir.Stu3.Core.csproj b/src/Microsoft.Health.Fhir.Stu3.Core/Microsoft.Health.Fhir.Stu3.Core.csproj index c09018aeb2..37ebcdde11 100644 --- a/src/Microsoft.Health.Fhir.Stu3.Core/Microsoft.Health.Fhir.Stu3.Core.csproj +++ b/src/Microsoft.Health.Fhir.Stu3.Core/Microsoft.Health.Fhir.Stu3.Core.csproj @@ -20,7 +20,7 @@ - + diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/ExportDataTestFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/ExportDataTestFixture.cs index 5d01e245e6..b88754ad6d 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/ExportDataTestFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/ExportDataTestFixture.cs @@ -9,7 +9,7 @@ using System.Text.RegularExpressions; using Antlr4.Runtime.Atn; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Client; using Microsoft.Health.Fhir.Core.Features.Operations.Export; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/StartupForExportTestProvider.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/StartupForExportTestProvider.cs index 295535f474..1ef439c7ed 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/StartupForExportTestProvider.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Export/StartupForExportTestProvider.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTestFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTestFixture.cs index 950f5839d9..711a19ae52 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTestFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTestFixture.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Core.Features.Operations.Import; using Microsoft.Health.Fhir.Tests.Common.FixtureParameters; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTests.cs index 6e61373bb4..9393aca016 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/ImportTests.cs @@ -17,7 +17,7 @@ using EnsureThat; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Health.Fhir.Api.Features.Operations.Import; using Microsoft.Health.Fhir.Client; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/StartupForImportTestProvider.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/StartupForImportTestProvider.cs index 4531c817b2..b8e84c6855 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/StartupForImportTestProvider.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Import/StartupForImportTestProvider.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricHandler.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricHandler.cs index 4a19fb7a28..ce77dc92ee 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricHandler.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricHandler.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Tests.E2E.Rest.Metric { @@ -24,7 +24,7 @@ public void ResetCount() NotificationMapping.Clear(); } - public Task Handle(INotification notification, CancellationToken cancellationToken) + public Task HandleAsync(INotification notification, CancellationToken cancellationToken) { Type notificationType = notification.GetType(); if (NotificationMapping.TryGetValue(notificationType, out List foundNotifications)) diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricTestFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricTestFixture.cs index 75d9fef3ba..11681921b9 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricTestFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/MetricTestFixture.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Fhir.Api.Features.ApiNotifications; using Microsoft.Health.Fhir.Tests.Common.FixtureParameters; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/StartupWithMetricHandler.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/StartupWithMetricHandler.cs index 9e3d659fc7..c2dfe36f5d 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/StartupWithMetricHandler.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Metric/StartupWithMetricHandler.cs @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Health.Extensions.DependencyInjection; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Search/SortTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Search/SortTests.cs index d1cbdf7b2c..a864d8d035 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Search/SortTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/Search/SortTests.cs @@ -489,7 +489,7 @@ public async Task GivenQueryWithRevinclude_WhenSearchedWithSortParamOnDatetimeWi observations.Add(obs.First()); } - resources.AddRange(patients.Reverse()); + resources.AddRange(((IEnumerable)patients).Reverse()); resources.AddRange(observations); // Ask to get all patient with specific tag order by birthdate (timestamp) @@ -561,7 +561,7 @@ public async Task GivenQueryWithRevinclude_WhenSearchedWithSortParamOnLastupdate observations.Add(obs.First()); } - resources.AddRange(patients.Reverse()); + resources.AddRange(((IEnumerable)patients).Reverse()); observations.Reverse(); resources.AddRange(observations); diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureDisabledTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureDisabledTests.cs index 692a6aa66e..d73dc69120 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureDisabledTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureDisabledTests.cs @@ -7,7 +7,7 @@ using System.Numerics; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Core.Configs; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureFixture.cs index 750f583b12..43cbf06f67 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureFixture.cs @@ -6,7 +6,7 @@ using System; using System.Numerics; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Extensions.Options; using Microsoft.Health.Fhir.Core.Configs; using Microsoft.Health.Fhir.Core.Features.Persistence; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Export/CreateExportRequestHandlerTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Export/CreateExportRequestHandlerTests.cs index dd6ac7a3c9..5685977041 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Export/CreateExportRequestHandlerTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Export/CreateExportRequestHandlerTests.cs @@ -313,7 +313,7 @@ public async Task GivenThereIsNoMatchingJob_WhenCreatingAnExportJob_ThenNewJobSh { var request = new CreateExportRequest(requestUrl, ExportJobType.All, since: since); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); Assert.NotNull(response); Assert.False(string.IsNullOrWhiteSpace(response.JobId)); @@ -325,11 +325,11 @@ public async Task GivenDifferentRequestUrl_WhenCreatingAnExportJob_ThenNewJobSho { var request = new CreateExportRequest(requestUri, ExportJobType.All, since: since); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); var newRequest = new CreateExportRequest(newRequestUri, ExportJobType.All, since: newSince); - CreateExportResponse newResponse = await _createExportRequestHandler.Handle(newRequest, _cancellationToken); + CreateExportResponse newResponse = await _createExportRequestHandler.HandleAsync(newRequest, _cancellationToken); Assert.NotNull(newResponse); Assert.NotEqual(response.JobId, newResponse.JobId); @@ -342,13 +342,13 @@ public async Task GivenDifferentRequestor_WhenCreatingAnExportJob_ThenNewJobShou var request = new CreateExportRequest(RequestUrl, ExportJobType.All); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); _claimsExtractor.ExtractImpl = () => new[] { KeyValuePair.Create("oid", "user2") }; var newRequest = new CreateExportRequest(RequestUrl, ExportJobType.All); - CreateExportResponse newResponse = await _createExportRequestHandler.Handle(newRequest, _cancellationToken); + CreateExportResponse newResponse = await _createExportRequestHandler.HandleAsync(newRequest, _cancellationToken); Assert.NotNull(newResponse); Assert.NotEqual(response.JobId, newResponse.JobId); @@ -386,7 +386,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( Arg.Any()); var request = new CreateExportRequest(RequestUrl, ExportJobType.All, null, formatName: formatName); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); Assert.Equal(expectedFormat, actualRecord.ExportFormat); } @@ -407,7 +407,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( Arg.Any()); var request = new CreateExportRequest(RequestUrl, ExportJobType.All, containerName: containerSpecified ? "test" : null); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); Assert.Equal(expectedFormat, actualRecord.ExportFormat); } @@ -417,7 +417,7 @@ public async Task GivenARequestWithANonexistantFormatName_WhenConverted_ThenABad { var formatName = "invalid"; var request = new CreateExportRequest(RequestUrl, ExportJobType.All, formatName: formatName); - var exception = await Assert.ThrowsAsync(() => _createExportRequestHandler.Handle(request, _cancellationToken)); + var exception = await Assert.ThrowsAsync(() => _createExportRequestHandler.HandleAsync(request, _cancellationToken)); Assert.Equal(string.Format(Resources.ExportFormatNotFound, formatName), exception.Message); } @@ -434,7 +434,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( Arg.Any()); var request = new CreateExportRequest(RequestUrl, ExportJobType.All, filters: filters); - CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); + CreateExportResponse response = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); Assert.Collection( actualRecord.Filters, @@ -452,7 +452,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( public async Task GivenARequestWithIncorectFilters_WhenConverted_ThenABadRequestIsReturned(string filters, string errorMessage) { var request = new CreateExportRequest(RequestUrl, ExportJobType.All, filters: filters); - var exception = await Assert.ThrowsAsync(() => _createExportRequestHandler.Handle(request, _cancellationToken)); + var exception = await Assert.ThrowsAsync(() => _createExportRequestHandler.HandleAsync(request, _cancellationToken)); Assert.Equal(string.Format(Resources.TypeFilterUnparseable, errorMessage), exception.Message); } @@ -509,7 +509,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( var request = new CreateExportRequest(RequestUrl, ExportJobType.All, filters: filterString.ToString()); try { - _ = await _createExportRequestHandler.Handle(request, _cancellationToken); + _ = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); if (invalidParameters.Any()) { Assert.Fail($"{nameof(BadRequestException)} should be thrown."); @@ -592,7 +592,7 @@ await _fhirOperationDataStore.CreateExportJobAsync( } var request = new CreateExportRequest(RequestUrl, ExportJobType.All, filters: filterString.ToString()); - _ = await _createExportRequestHandler.Handle(request, _cancellationToken); + _ = await _createExportRequestHandler.HandleAsync(request, _cancellationToken); _searchOptionsFactory.DidNotReceiveWithAnyArgs(); } diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/FhirOperationDataStoreReindexTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/FhirOperationDataStoreReindexTests.cs index edf54bba81..bdbb37a43f 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/FhirOperationDataStoreReindexTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/FhirOperationDataStoreReindexTests.cs @@ -293,7 +293,7 @@ private async Task CancelActiveReindexJobIfExists(CancellationToken cancellation if (found && !string.IsNullOrEmpty(id)) { var cancelReindexHandler = new CancelReindexRequestHandler(_operationDataStore, DisabledFhirAuthorizationService.Instance); - await cancelReindexHandler.Handle(new CancelReindexRequest(id), cancellationToken); + await cancelReindexHandler.HandleAsync(new CancelReindexRequest(id), cancellationToken); // Optionally, wait for the job to be marked as canceled var job = await _operationDataStore.GetReindexJobByIdAsync(id, cancellationToken); diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Reindex/ReindexJobTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Reindex/ReindexJobTests.cs index 71116b318b..5d22c79e88 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Reindex/ReindexJobTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Operations/Reindex/ReindexJobTests.cs @@ -14,7 +14,7 @@ using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; using Hl7.FhirPath; -using MediatR; +using Medino; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -336,7 +336,7 @@ public async Task GivenReindexJobQueuedWithBackgroundService_WhenJobCompleted_Th // Create a reindex job var request = new CreateReindexRequest(new List(), new List()); - CreateReindexResponse response = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse response = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.NotNull(response.Job); @@ -386,7 +386,7 @@ public async Task GivenLessThanMaximumRunningJobs_WhenCreatingAReindexJob_ThenNe await CancelActiveReindexJobIfExists(); var request = new CreateReindexRequest(new List(), new List()); - CreateReindexResponse response = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse response = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.False(string.IsNullOrWhiteSpace(response.Job.JobRecord.Id)); @@ -416,7 +416,7 @@ public async Task GivenOutOfRangeReindexParameter_WhenCreatingAReindexJob_ThenEx break; } - CreateReindexResponse response = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse response = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); } catch (FhirException fhirExp) { @@ -448,7 +448,7 @@ public async Task GivenValidReindexParameter_WhenCreatingAReindexJob_ThenNewJobS break; } - CreateReindexResponse response = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse response = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.False(string.IsNullOrWhiteSpace(response.Job.JobRecord.Id)); } @@ -460,7 +460,7 @@ public async Task GivenSingleResourceReindex_ThenReindexJobShouldComplete() UpsertOutcome observationSample = await CreateObservationResource(observationId); var request = GetReindexRequest("POST", observationId, "Observation"); - ReindexSingleResourceResponse response = await _reindexSingleResourceRequestHandler.Handle(request, CancellationToken.None); + ReindexSingleResourceResponse response = await _reindexSingleResourceRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); } @@ -530,7 +530,7 @@ public async Task GivenAlreadyRunningJob_WhenCreatingAReindexJob_ThenActiveJobSh await CancelActiveReindexJobIfExists(); var request = new CreateReindexRequest(new List(), new List()); - CreateReindexResponse firstResponse = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse firstResponse = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(firstResponse); Assert.False(string.IsNullOrWhiteSpace(firstResponse.Job.JobRecord.Id)); @@ -540,7 +540,7 @@ public async Task GivenAlreadyRunningJob_WhenCreatingAReindexJob_ThenActiveJobSh OperationStatus originalStatus = firstResponse.Job.JobRecord.Status; // Create another reindex request - should return the same job instead of throwing an exception - CreateReindexResponse secondResponse = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse secondResponse = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(secondResponse); Assert.Equal(originalJobId, secondResponse.Job.JobRecord.Id); @@ -710,7 +710,7 @@ public async Task GivenReindexJobRunning_WhenReindexJobCancelRequest_ThenReindex try { var cancelReindexHandler = new CancelReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - await cancelReindexHandler.Handle(new CancelReindexRequest(response.Job.JobRecord.Id), CancellationToken.None); + await cancelReindexHandler.HandleAsync(new CancelReindexRequest(response.Job.JobRecord.Id), CancellationToken.None); var reindexWrapper = await _fhirOperationDataStore.GetReindexJobByIdAsync(response.Job.JobRecord.Id, cancellationTokenSource.Token); Assert.Equal(OperationStatus.Canceled, reindexWrapper.JobRecord.Status); @@ -1106,7 +1106,7 @@ private async Task SetUpForReindexing(CreateReindexReques request = new CreateReindexRequest(new List(), new List()); } - CreateReindexResponse response = await _createReindexRequestHandler.Handle(request, CancellationToken.None); + CreateReindexResponse response = await _createReindexRequestHandler.HandleAsync(request, CancellationToken.None); Assert.NotNull(response); Assert.False(string.IsNullOrWhiteSpace(response.Job.JobRecord.Id)); @@ -1271,7 +1271,7 @@ private async Task CancelActiveReindexJobIfExists(CancellationToken cancellation if (found && !string.IsNullOrEmpty(id)) { var cancelReindexHandler = new CancelReindexRequestHandler(_fhirOperationDataStore, DisabledFhirAuthorizationService.Instance); - await cancelReindexHandler.Handle(new CancelReindexRequest(id), cancellationToken); + await cancelReindexHandler.HandleAsync(new CancelReindexRequest(id), cancellationToken); // Optionally, wait for the job to be marked as canceled var job = await _fhirOperationDataStore.GetReindexJobByIdAsync(id, cancellationToken); diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Smart/SmartSearchTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Smart/SmartSearchTests.cs index e29978d5c5..dd20b54689 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Smart/SmartSearchTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/Smart/SmartSearchTests.cs @@ -635,7 +635,7 @@ public async Task GivenFhirUserClaimPatient_WhenPatientInOtherCompartmentRequest _contextAccessor.RequestContext.AccessControlContext.CompartmentId = "smart-patient-A"; _contextAccessor.RequestContext.AccessControlContext.CompartmentResourceType = "Patient"; - await Assert.ThrowsAsync(() => _fixture.GetResourceHandler.Handle(new GetResourceRequest(new ResourceKey("Patient", "smart-patient-B"), bundleResourceContext: null), CancellationToken.None)); + await Assert.ThrowsAsync(() => _fixture.GetResourceHandler.HandleAsync(new GetResourceRequest(new ResourceKey("Patient", "smart-patient-B"), bundleResourceContext: null), CancellationToken.None)); } [SkippableFact] @@ -1219,7 +1219,7 @@ public async Task GivenSmartV2ReadScope_WhenReadingPatient_ThenPatientIsReturned _contextAccessor.RequestContext.AccessControlContext.CompartmentId = "smart-patient-A"; _contextAccessor.RequestContext.AccessControlContext.CompartmentResourceType = "Patient"; - var result = await _fixture.GetResourceHandler.Handle( + var result = await _fixture.GetResourceHandler.HandleAsync( new GetResourceRequest(new ResourceKey("Patient", "smart-patient-A"), bundleResourceContext: null), CancellationToken.None); diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/CosmosDbFhirStorageTestsFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/CosmosDbFhirStorageTestsFixture.cs index 6f5a43f1c7..d4351506c8 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/CosmosDbFhirStorageTestsFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/CosmosDbFhirStorageTestsFixture.cs @@ -11,7 +11,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging.Abstractions; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTests.cs index 9b83c3a5d1..4592bf1e75 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTests.cs @@ -13,7 +13,7 @@ using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Health.Abstractions.Exceptions; using Microsoft.Health.Abstractions.Features.Transactions; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTestsFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTestsFixture.cs index 99c352f677..e57352aa6c 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTestsFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageTestsFixture.cs @@ -10,7 +10,7 @@ using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageVersioningPolicyTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageVersioningPolicyTests.cs index 2a7a22fe7a..259c6f1bde 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageVersioningPolicyTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/FhirStorageVersioningPolicyTests.cs @@ -6,7 +6,7 @@ using System; using System.Linq; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Exceptions; using Microsoft.Health.Fhir.Core.Extensions; using Microsoft.Health.Fhir.Core.Features.Persistence; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestHelper.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestHelper.cs index ad9622ce83..e6a68cc604 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestHelper.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestHelper.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestsFixture.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestsFixture.cs index ce3aacd67e..7542824425 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestsFixture.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerFhirStorageTestsFixture.cs @@ -9,7 +9,7 @@ using System.Numerics; using System.Threading; using Azure.Identity; -using MediatR; +using Medino; using Microsoft.AspNetCore.Components.Forms; using Microsoft.Data.SqlClient; using Microsoft.Extensions.DependencyInjection; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSchemaUpgradeTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSchemaUpgradeTests.cs index 860da9fd4f..d3f57be3cf 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSchemaUpgradeTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSchemaUpgradeTests.cs @@ -11,7 +11,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; using Microsoft.Data.SqlClient; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging.Abstractions; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSqlCompatibilityTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSqlCompatibilityTests.cs index 3d925a9cf0..b0d352e301 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSqlCompatibilityTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerSqlCompatibilityTests.cs @@ -8,7 +8,7 @@ using System.Linq; using System.Threading.Tasks; using Hl7.Fhir.Model; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Extensions; using Microsoft.Health.Fhir.Core.Features.Persistence; using Microsoft.Health.Fhir.SqlServer.Features.Schema; diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerWatchdogTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerWatchdogTests.cs index d817bedc59..a97eba6c83 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerWatchdogTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerWatchdogTests.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Hl7.Fhir.Serialization; -using MediatR; +using Medino; using Microsoft.Azure.Cosmos.Spatial; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Primitives; diff --git a/tools/AsyncJobGenerator/Templates/MediatorCreateRequest.template b/tools/AsyncJobGenerator/Templates/MediatorCreateRequest.template index 064b069c11..71429b28c0 100644 --- a/tools/AsyncJobGenerator/Templates/MediatorCreateRequest.template +++ b/tools/AsyncJobGenerator/Templates/MediatorCreateRequest.template @@ -3,7 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations..Mediator { diff --git a/tools/AsyncJobGenerator/Templates/MediatorExtensions.template b/tools/AsyncJobGenerator/Templates/MediatorExtensions.template index dc0ba8518e..68945ad3c7 100644 --- a/tools/AsyncJobGenerator/Templates/MediatorExtensions.template +++ b/tools/AsyncJobGenerator/Templates/MediatorExtensions.template @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using EnsureThat; -using MediatR; +using Medino; using Microsoft.Health.Fhir.Core.Features.Operations..Mediator; namespace Microsoft.Health.Fhir.Core.Extensions @@ -19,7 +19,7 @@ namespace Microsoft.Health.Fhir.Core.Extensions var request = new CreateRequest(); - CreateResponse response = await mediator.Send(request, cancellationToken); + CreateResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -30,7 +30,7 @@ namespace Microsoft.Health.Fhir.Core.Extensions var request = new GetRequest(jobId); - GetResponse response = await mediator.Send(request, cancellationToken); + GetResponse response = await mediator.SendAsync(request, cancellationToken); return response; } @@ -41,7 +41,7 @@ namespace Microsoft.Health.Fhir.Core.Extensions var request = new CancelRequest(jobId); - return await mediator.Send(request, cancellationToken); + return await mediator.SendAsync(request, cancellationToken); } } } diff --git a/tools/AsyncJobGenerator/Templates/MediatorHandler.template b/tools/AsyncJobGenerator/Templates/MediatorHandler.template index a1b5b1f144..d941156f40 100644 --- a/tools/AsyncJobGenerator/Templates/MediatorHandler.template +++ b/tools/AsyncJobGenerator/Templates/MediatorHandler.template @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations..Mediator { @@ -13,6 +13,6 @@ namespace Microsoft.Health.Fhir.Core.Features.Operations..Mediator { public Handler() { } - public async Task<Response> Handle(Request request, CancellationToken cancellationToken) { } + public async Task<Response> HandleAsync(Request request, CancellationToken cancellationToken) { } } } diff --git a/tools/AsyncJobGenerator/Templates/MediatorRequest.template b/tools/AsyncJobGenerator/Templates/MediatorRequest.template index 4fa63898f2..ddc2dc2cdf 100644 --- a/tools/AsyncJobGenerator/Templates/MediatorRequest.template +++ b/tools/AsyncJobGenerator/Templates/MediatorRequest.template @@ -4,7 +4,7 @@ // ------------------------------------------------------------------------------------------------- using EnsureThat; -using MediatR; +using Medino; namespace Microsoft.Health.Fhir.Core.Features.Operations..Mediator {