public async Task GivenFhirServer_WhenGroupDataWithNoMemberPatientIdIsExported_ThenNoDataIsExported() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Add data for test string groupId = await CreateGroupWithoutPatientIds(); // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync($"Group/{groupId}/"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation); Assert.Empty(blobUris); async Task <string> CreateGroupWithoutPatientIds() { var group = new FhirGroup() { Type = FhirGroup.GroupType.Person, Actual = true, }; var groupResponse = await _testFhirClient.CreateAsync(group); return(groupResponse.Resource.Id); } }
public async Task GivenFhirServer_WhenPatientDataIsExported_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync("Patient/"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download resources from fhir server Uri address = new Uri(_testFhirClient.HttpClient.BaseAddress, "Patient/"); Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, address, _fhirJsonParser, _outputHelper); Dictionary <(string resourceType, string resourceId), Resource> compartmentData = new Dictionary <(string resourceType, string resourceId), Resource>(); foreach ((string resourceType, string resourceId)key in dataFromFhirServer.Keys) { address = new Uri(_testFhirClient.HttpClient.BaseAddress, "Patient/" + key.resourceId + "/*"); // copies all the new values into the compartment data dictionary (await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, address, _fhirJsonParser, _outputHelper)) .ToList() .ForEach(x => compartmentData.TryAdd(x.Key, x.Value)); } compartmentData.ToList().ForEach(x => dataFromFhirServer.TryAdd(x.Key, x.Value)); dataFromFhirServer.Union(compartmentData); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenGroupDataIsExportedWithTypeParameter_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Add data for test var(dataInFhirServer, groupId) = await CreateGroupWithPatient(false); // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync($"Group/{groupId}/", "_type=RelatedPerson,Encounter"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Assert both sets of data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataInFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenAllDataIsExported_ThenExportedDataIsSameAsDataInFhirServer() { // NOTE: Azure Storage Emulator is required to run these tests locally. // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync(); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download all resources from fhir server Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, _testFhirClient.HttpClient.BaseAddress, _fhirJsonParser, _outputHelper); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); }
public async Task GivenFhirServer_WhenAllDataIsExportedToASpecificContainer_ThenExportedDataIsInTheSpecifiedContianer() { // NOTE: Azure Storage Emulator is required to run these tests locally. string testContainer = "test-container"; // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync(parameters : $"_container={testContainer}"); IList <Uri> blobUris = await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation, timeToWaitInMinutes : 15); // Download exported data from storage account Dictionary <(string resourceType, string resourceId), Resource> dataFromExport = await ExportTestHelper.DownloadBlobAndParse(blobUris, _fhirJsonParser, _outputHelper); // Download all resources from fhir server Dictionary <(string resourceType, string resourceId), Resource> dataFromFhirServer = await ExportTestHelper.GetResourcesFromFhirServer(_testFhirClient, _testFhirClient.HttpClient.BaseAddress, _fhirJsonParser, _outputHelper); // Assert both data are equal Assert.True(ExportTestHelper.ValidateDataFromBothSources(dataFromFhirServer, dataFromExport, _outputHelper)); Assert.True(blobUris.All((url) => url.OriginalString.Contains(testContainer))); }
public async Task GivenFhirServer_WhenDataIsExported_ThenExportTaskMetricsNotificationShouldBePosted() { // NOTE: Azure Storage Emulator is required to run these tests locally. if (!_fixture.IsUsingInProcTestServer) { // This test only works with the in-proc server with a customized metric handler. return; } // Clean notification before tests _fixture.MetricHandler.ResetCount(); // Add data for test var(_, groupId) = await CreateGroupWithPatient(true); // Trigger export request and check for export status Uri contentLocation = await _testFhirClient.ExportAsync($"Group/{groupId}/"); await ExportTestHelper.CheckExportStatus(_testFhirClient, contentLocation); // Assert at least one notification handled. Assert.Single(_fixture.MetricHandler.NotificationMapping[typeof(ExportTaskMetricsNotification)]); }