public async Task GivenImportOperationEnabled_WhenImportOperationTriggeredWithoutEtag_ThenDataShouldBeImported() { string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string _) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Type = "Patient", }, }, }; await ImportCheckAsync(request); }
public async Task GivenImportOperationEnabled_WhenImportDuplicatedResource_ThenDupResourceShouldBeCleaned() { string patientNdJsonResource = Samples.GetNdJson("Import-DupPatientTemplate"); string resourceId = Guid.NewGuid().ToString("N"); patientNdJsonResource = patientNdJsonResource.Replace("##PatientID##", resourceId); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Etag = etag, Type = "Patient", }, }, }; await ImportCheckAsync(request, errorCount : 1); await ImportCheckAsync(request, errorCount : 2); Patient patient = await _client.ReadAsync <Patient>(ResourceType.Patient, resourceId); Assert.Equal(resourceId, patient.Id); }
public async Task GivenImportOperationEnabled_WhenImportInvalidResourceUrl_ThenBadRequestShouldBeReturned() { var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = new Uri("https://fhirtest-invalid.com"), Type = "Patient", }, }, }; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); FhirException fhirException = await Assert.ThrowsAsync <FhirException>( async() => { HttpResponseMessage response; while ((response = await _client.CheckImportAsync(checkLocation, CancellationToken.None)).StatusCode == System.Net.HttpStatusCode.Accepted) { await Task.Delay(TimeSpan.FromSeconds(5)); } }); Assert.Equal(HttpStatusCode.BadRequest, fhirException.StatusCode); }
public async Task GivenImportOperationEnabled_WhenImportInvalidResourceType_ThenBadRequestShouldBeReturned() { string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Type = "Invalid", }, }, }; FhirException fhirException = await Assert.ThrowsAsync <FhirException>( async() => await ImportTestHelper.CreateImportTaskAsync(_client, request)); Assert.Equal(HttpStatusCode.BadRequest, fhirException.StatusCode); }
public async Task GivenAUserWithImportPermissions_WhenImportData_TheServerShouldReturnSuccess() { TestFhirClient tempClient = _client.CreateClientForUser(TestUsers.BulkImportUser, TestApplications.NativeClient); string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Type = "Patient", }, }, }; await ImportCheckAsync(request, tempClient); }
private async Task <Uri> ImportCheckAsync(ImportRequest request, TestFhirClient client = null, int?errorCount = null) { client = client ?? _client; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(client, request); HttpResponseMessage response; while ((response = await client.CheckImportAsync(checkLocation, CancellationToken.None)).StatusCode == System.Net.HttpStatusCode.Accepted) { await Task.Delay(TimeSpan.FromSeconds(5)); } Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); ImportTaskResult result = JsonConvert.DeserializeObject <ImportTaskResult>(await response.Content.ReadAsStringAsync()); Assert.NotEmpty(result.Output); if (errorCount != null) { Assert.Equal(errorCount.Value, result.Error.First().Count); } else { Assert.Empty(result.Error); } Assert.NotEmpty(result.Request); return(checkLocation); }
public async Task GivenAUserWithoutImportPermissions_WhenImportData_ThenServerShouldReturnForbidden() { TestFhirClient tempClient = _client.CreateClientForUser(TestUsers.ReadOnlyUser, TestApplications.NativeClient); string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Type = "Patient", }, }, }; request.Mode = ImportConstants.InitialLoadMode; request.Force = true; FhirException fhirException = await Assert.ThrowsAsync <FhirException>(async() => await tempClient.ImportAsync(request.ToParameters(), CancellationToken.None)); Assert.Equal(ForbiddenMessage, fhirException.Message); Assert.Equal(HttpStatusCode.Forbidden, fhirException.StatusCode); }
public async Task GivenImportedResourceWithVariousValues_WhenSearchedWithMultipleParams_ThenOnlyResourcesMatchingAllSearchParamsShouldBeReturned() { Patient patientAddressCityAndFamily = _fixture.PatientAddressCityAndFamily; string query = string.Format("Patient?address-city={0}&family={1}&_tag={2}", patientAddressCityAndFamily.Address[0].City, patientAddressCityAndFamily.Name[0].Family, _fixture.FixtureTag); await ImportTestHelper.VerifySearchResultAsync(_fixture.TestFhirClient, query, patientAddressCityAndFamily); }
protected override async Task OnInitializedAsync() { Patients = await ImportTestHelper.ImportToServerAsync <Patient>( TestFhirClient, CloudStorageAccount, p => SetPatientInfo(p, "Seattle", "Smith", given: "Bea"), p => SetPatientInfo(p, "Portland", "Williams"), p => SetPatientInfo(p, "Vancouver", "Anderson"), p => SetPatientInfo(p, LongString, "Murphy"), p => SetPatientInfo(p, "Montreal", "Richard", given: "Bea"), p => SetPatientInfo(p, "New York", "Muller"), p => SetPatientInfo(p, "Portland", "Müller"), p => SetPatientInfo(p, "Moscow", "Richard,Muller")); void SetPatientInfo(Patient patient, string city, string family, string given = null) { patient.Address = new List <Address>() { new Address { City = city }, }; patient.Name = new List <HumanName>() { new HumanName { Family = family, Given = new[] { given } }, }; patient.AddTestTag(FixtureTag); } }
private async Task SearchAndValidateObservations(string queryValue, string[] expectedObservationNames) { Bundle bundle = await SearchAsync(ResourceType.Observation, queryValue); Observation[] expected = expectedObservationNames.Select(name => _fixture.Observations[name]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenANumberSearchParam_WhenSearched_ThenCorrectBundleShouldBeReturned(string queryValue, params int[] expectedIndices) { Bundle bundle = await _client.SearchAsync(ResourceType.RiskAssessment, $"probability={queryValue}&_tag={_fixture.FixtureTag}"); RiskAssessment[] expected = expectedIndices.Select(i => _fixture.RiskAssessments[i]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenMultipleTokenSearchParametersWithNotModifiers_WhenSearched_ThenCorrectBundleShouldBeReturned(string queryValue, params int[] excludeIndices) { Bundle bundle = await _client.SearchAsync(ResourceType.Observation, $"category:not=test&value-concept:not={queryValue}&_tag={_fixture.FixtureTag}"); Observation[] expected = _fixture.Observations.Where((_, i) => !excludeIndices.Contains(i)).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenATokenSearchParameterWithNotModifier_WhenSearchedOverMissingValue_ThenCorrectBundleShouldBeReturned() { Bundle bundle = await _client.SearchAsync(ResourceType.Observation, $"category:not=test&_tag={_fixture.FixtureTag}"); Observation[] expected = _fixture.Observations.Where((_, i) => i != 8).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenAUriSearchParam_WhenSearched_ThenCorrectBundleShouldBeReturned(string modifier, string queryValue, params int[] expectedIndices) { Bundle bundle = await _client.SearchAsync(ResourceType.ValueSet, $"url{modifier}={HttpUtility.UrlEncode(queryValue)}&_tag={_fixture.FixtureTag}"); ValueSet[] expected = expectedIndices.Select(i => _fixture.ValueSets[i]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenImportedResourceWithVariousValues_WhenSearchedWithTheMissingModifer_ThenOnlyTheResourcesWithMissingOrPresentParametersAreReturned() { string queryMissingFalse = string.Format("Patient?gender:missing=false&_tag={0}", _fixture.FixtureTag); await ImportTestHelper.VerifySearchResultAsync(_fixture.TestFhirClient, queryMissingFalse, _fixture.PatientWithGender); string queryMissing = string.Format("Patient?gender:missing=true&_tag={0}", _fixture.FixtureTag); await ImportTestHelper.VerifySearchResultAsync(_fixture.TestFhirClient, queryMissing, _fixture.PatientAddressCityAndFamily, _fixture.PatientWithSameCity1, _fixture.PatientWithSameCity2); }
public async Task GivenAQuantitySearchParameterWithQuantity_WhenSearched_ThenCorrectBundleShouldBeReturned(string queryValue, params int[] expectedIndices) { Bundle bundle = await _client.SearchAsync(ResourceType.Observation, $"value-quantity={queryValue}&_tag={_fixture.FixtureTag}"); Observation[] expected = expectedIndices.Select(i => _fixture.Observations[i]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenIdWithNotModifier_WhenSearched_ThenCorrectBundleShouldBeReturned(int count) { Bundle bundle = await _client.SearchAsync(ResourceType.Observation, $"_id:not={string.Join(",", _fixture.Observations.Take(count).Select(x => x.Id))}&_tag={_fixture.FixtureTag}"); Observation[] expected = _fixture.Observations.Skip(count).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
private async Task SearchAndValidateDocumentReferences(string queryValue, string[] expectedDocumentReferenceNames) { Bundle bundle = await SearchAsync(ResourceType.DocumentReference, queryValue); DocumentReference[] expected = expectedDocumentReferenceNames.Select(name => _fixture.DocumentReferences[name]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
public async Task GivenAReferenceSearchParam_WhenSearched_ThenCorrectBundleShouldBeReturned(string query, params int[] matchIndices) { Bundle bundle = await _client.SearchAsync(ResourceType.Patient, $"{query}&_tag={_fixture.FixtureTag}"); Patient[] expected = matchIndices.Select(i => _fixture.Patients[i]).ToArray(); ImportTestHelper.VerifyBundle(bundle, expected); }
protected override async Task OnInitializedAsync() { await ImportTestHelper.ImportToServerAsync( TestFhirClient, CloudStorageAccount, PatientAddressCityAndFamily.AddTestTag(FixtureTag), PatientWithSameCity1.AddTestTag(FixtureTag), PatientWithSameCity2.AddTestTag(FixtureTag), PatientWithGender.AddTestTag(FixtureTag)); }
public async Task GivenImportOperationEnabled_WhenImportResourceWithWrongType_ThenErrorLogShouldBeUploaded() { _metricHandler?.ResetCount(); string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Etag = etag, Type = "Observation", // not match the resource }, }, }; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); HttpResponseMessage response; while ((response = await _client.CheckImportAsync(checkLocation, CancellationToken.None)).StatusCode == System.Net.HttpStatusCode.Accepted) { await Task.Delay(TimeSpan.FromSeconds(5)); } Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); ImportTaskResult result = JsonConvert.DeserializeObject <ImportTaskResult>(await response.Content.ReadAsStringAsync()); Assert.Single(result.Error); Assert.NotEmpty(result.Error.First().Url); // Only check metric for local tests if (_fixture.IsUsingInProcTestServer) { var resourceCount = Regex.Matches(patientNdJsonResource, "{\"resourceType\":").Count; var notificationList = _metricHandler.NotificationMapping[typeof(ImportTaskMetricsNotification)]; Assert.Single(notificationList); var notification = notificationList.First() as ImportTaskMetricsNotification; Assert.Equal(TaskResult.Success.ToString(), notification.Status); Assert.NotNull(notification.DataSize); Assert.Equal(0, notification.SucceedCount); Assert.Equal(resourceCount, notification.FailedCount); } }
public async Task GivenImportOperationEnabled_WhenCancelImportTask_ThenTaskShouldBeCanceled() { _metricHandler?.ResetCount(); string patientNdJsonResource = Samples.GetNdJson("Import-Patient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Etag = etag, Type = "Patient", }, }, }; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); var respone = await _client.CancelImport(checkLocation); FhirException fhirException = await Assert.ThrowsAsync <FhirException>(async() => await _client.CheckImportAsync(checkLocation)); Assert.Equal(HttpStatusCode.BadRequest, fhirException.StatusCode); // wait task completed while (respone.StatusCode != HttpStatusCode.Conflict) { respone = await _client.CancelImport(checkLocation); await Task.Delay(TimeSpan.FromSeconds(3)); } // Only check metric for local tests if (_fixture.IsUsingInProcTestServer) { var notificationList = _metricHandler.NotificationMapping[typeof(ImportTaskMetricsNotification)]; var notification = notificationList.First() as ImportTaskMetricsNotification; Assert.Single(notificationList); Assert.Equal(TaskResult.Canceled.ToString(), notification.Status); Assert.Null(notification.SucceedCount); Assert.Null(notification.FailedCount); } }
public async Task GivenImportOperationEnabled_WhenImportDuplicatedResource_ThenDupResourceShouldBeCleaned() { _metricHandler?.ResetCount(); string patientNdJsonResource = Samples.GetNdJson("Import-DupPatientTemplate"); string resourceId = Guid.NewGuid().ToString("N"); patientNdJsonResource = patientNdJsonResource.Replace("##PatientID##", resourceId); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Etag = etag, Type = "Patient", }, }, }; await ImportCheckAsync(request, errorCount : 1); await ImportCheckAsync(request, errorCount : 2); Patient patient = await _client.ReadAsync <Patient>(ResourceType.Patient, resourceId); Assert.Equal(resourceId, patient.Id); // Only check metric for local tests if (_fixture.IsUsingInProcTestServer) { var notificationList = _metricHandler.NotificationMapping[typeof(ImportTaskMetricsNotification)]; Assert.Equal(2, notificationList.Count); var notification1 = notificationList.First() as ImportTaskMetricsNotification; Assert.Equal(TaskResult.Success.ToString(), notification1.Status); Assert.Equal(1, notification1.SucceedCount); Assert.Equal(1, notification1.FailedCount); var notification2 = notificationList[1] as ImportTaskMetricsNotification; Assert.Equal(TaskResult.Success.ToString(), notification1.Status); Assert.Equal(0, notification2.SucceedCount); Assert.Equal(2, notification2.FailedCount); } }
public async Task GivenImportOperationEnabled_WhenImportOperationTriggeredWithMultipleFiles_ThenDataShouldBeImported() { _metricHandler?.ResetCount(); string patientNdJsonResource = Samples.GetNdJson("Import-SinglePatientTemplate"); string resourceId1 = Guid.NewGuid().ToString("N"); string patientNdJsonResource1 = patientNdJsonResource.Replace("##PatientID##", resourceId1); string resourceId2 = Guid.NewGuid().ToString("N"); string patientNdJsonResource2 = patientNdJsonResource.Replace("##PatientID##", resourceId2); (Uri location1, string _) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource1, _fixture.CloudStorageAccount); (Uri location2, string _) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource2, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location1, Type = "Patient", }, new InputResource() { Url = location2, Type = "Patient", }, }, }; await ImportCheckAsync(request); // Only check metric for local tests if (_fixture.IsUsingInProcTestServer) { var resourceCount = Regex.Matches(patientNdJsonResource, "{\"resourceType\":").Count * 2; var notificationList = _metricHandler.NotificationMapping[typeof(ImportTaskMetricsNotification)]; Assert.Single(notificationList); var notification = notificationList.First() as ImportTaskMetricsNotification; Assert.Equal(TaskResult.Success.ToString(), notification.Status); Assert.NotNull(notification.DataSize); Assert.Equal(resourceCount, notification.SucceedCount); Assert.Equal(0, notification.FailedCount); } }
protected override async Task OnInitializedAsync() { await TestFhirClient.CreateResourcesAsync <Patient>(p => { p.AddTestTag(FixtureTag); }); Observations = await ImportTestHelper.ImportToServerAsync <Observation>( TestFhirClient, CloudStorageAccount, o => SetObservation(o, cc => cc.Coding.Add(new Coding("system1", "code1"))), o => SetObservation(o, cc => cc.Coding.Add(new Coding("system2", "code2"))), o => SetObservation(o, cc => cc.Text = "text"), o => SetObservation(o, cc => cc.Coding.Add(new Coding("system1", "code2", "text2"))), o => SetObservation(o, cc => cc.Coding.Add(new Coding("system3", "code3", "text"))), o => SetObservation(o, cc => { cc.Text = "text"; cc.Coding.Add(new Coding("system1", "code1")); cc.Coding.Add(new Coding("system3", "code2")); }), o => SetObservation(o, cc => { cc.Coding.Add(new Coding("system2", "code1")); cc.Coding.Add(new Coding("system3", "code3", "text2")); }), o => SetObservation(o, cc => cc.Coding.Add(new Coding(null, "code3"))), o => { SetObservation(o, cc => { }); o.Category = new List <CodeableConcept> { new CodeableConcept("system", "test"), }; }); void SetObservation(Observation observation, Action <CodeableConcept> codeableConceptCustomizer) { observation.AddTestTag(FixtureTag); observation.Code = new CodeableConcept("system", "code"); observation.Status = ObservationStatus.Registered; var codeableConcept = new CodeableConcept(); codeableConceptCustomizer(codeableConcept); observation.Value = codeableConcept; } }
protected override async Task OnInitializedAsync() { Observations = CreateResultDictionary <Observation>(ObservationTestFileNames); DocumentReferences = CreateResultDictionary <DocumentReference>(DocumentReferenceTestFiles); List <Resource> resources = new List <Resource>(); resources.AddRange(Observations.Values); resources.AddRange(DocumentReferences.Values); await ImportTestHelper.ImportToServerAsync( TestFhirClient, CloudStorageAccount, resources.ToArray()); }
protected override async Task OnInitializedAsync() { Patients = await ImportTestHelper.ImportToServerAsync <Patient>( TestFhirClient, CloudStorageAccount, p => p.AddTestTag(FixtureTag).ManagingOrganization = new ResourceReference("Organization/123"), p => p.AddTestTag(FixtureTag).ManagingOrganization = new ResourceReference("Organization/abc"), p => p.AddTestTag(FixtureTag).ManagingOrganization = new ResourceReference("ijk"), // type not specified, but known constrained to be Organization p => p.AddTestTag(FixtureTag).GeneralPractitioner = new List <ResourceReference> { new ResourceReference("Practitioner/p1") }, p => p.AddTestTag(FixtureTag).GeneralPractitioner = new List <ResourceReference> { new ResourceReference("p2") }); // type not specified and not known because it could be Practitioner, Organization, or PractitionerRole }
public async Task GivenImportOperationEnabled_WhenImportInvalidResourceUrl_ThenBadRequestShouldBeReturned() { _metricHandler?.ResetCount(); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = new Uri("https://fhirtest-invalid.com"), Type = "Patient", }, }, }; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); FhirException fhirException = await Assert.ThrowsAsync <FhirException>( async() => { HttpResponseMessage response; while ((response = await _client.CheckImportAsync(checkLocation, CancellationToken.None)).StatusCode == System.Net.HttpStatusCode.Accepted) { await Task.Delay(TimeSpan.FromSeconds(5)); } }); Assert.Equal(HttpStatusCode.BadRequest, fhirException.StatusCode); // Only check metric for local tests if (_fixture.IsUsingInProcTestServer) { var notificationList = _metricHandler.NotificationMapping[typeof(ImportTaskMetricsNotification)]; Assert.Single(notificationList); var notification = notificationList.First() as ImportTaskMetricsNotification; Assert.Equal(TaskResult.Fail.ToString(), notification.Status); Assert.Null(notification.DataSize); Assert.Null(notification.SucceedCount); Assert.Null(notification.FailedCount); } }
public async Task GivenImportOperationEnabled_WhenImportInvalidResource_ThenErrorLogsShouldBeOutput() { string patientNdJsonResource = Samples.GetNdJson("Import-InvalidPatient"); patientNdJsonResource = Regex.Replace(patientNdJsonResource, "##PatientID##", m => Guid.NewGuid().ToString("N")); (Uri location, string etag) = await ImportTestHelper.UploadFileAsync(patientNdJsonResource, _fixture.CloudStorageAccount); var request = new ImportRequest() { InputFormat = "application/fhir+ndjson", InputSource = new Uri("https://other-server.example.org"), StorageDetail = new ImportRequestStorageDetail() { Type = "azure-blob" }, Input = new List <InputResource>() { new InputResource() { Url = location, Etag = etag, Type = "Patient", }, }, }; Uri checkLocation = await ImportTestHelper.CreateImportTaskAsync(_client, request); HttpResponseMessage response; while ((response = await _client.CheckImportAsync(checkLocation, CancellationToken.None)).StatusCode == System.Net.HttpStatusCode.Accepted) { await Task.Delay(TimeSpan.FromSeconds(5)); } Assert.Equal(System.Net.HttpStatusCode.OK, response.StatusCode); ImportTaskResult result = JsonConvert.DeserializeObject <ImportTaskResult>(await response.Content.ReadAsStringAsync()); Assert.NotEmpty(result.Output); Assert.Equal(1, result.Error.Count); Assert.NotEmpty(result.Request); string errorLoation = result.Error.ToArray()[0].Url; string[] errorContents = (await ImportTestHelper.DownloadFileAsync(errorLoation, _fixture.CloudStorageAccount)).Split("\r\n", StringSplitOptions.RemoveEmptyEntries); Assert.Single(errorContents); }
protected override async Task OnInitializedAsync() { FixtureTag = Guid.NewGuid().ToString(); ValueSets = await ImportTestHelper.ImportToServerAsync <ValueSet>( TestFhirClient, CloudStorageAccount, vs => AddValueSet(vs, "http://somewhere.com/test/system"), vs => AddValueSet(vs, "urn://localhost/test"), vs => AddValueSet(vs, "http://example.org/rdf#54135-9"), vs => AddValueSet(vs, "http://example.org/rdf#54135-9-9")); void AddValueSet(ValueSet vs, string url) { vs.Status = PublicationStatus.Active; vs.Url = url; vs.AddTestTag(FixtureTag); } }