public void GivenATransactionContextAndImagingStudyWithNewEndpointReference_WhenProcessedForStudyWithEndpoint_ThenEndpointIsAdded() { ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>() { DefaultSeriesInstanceUid }, new List <string>() { DefaultSopInstanceUid }, DefaultPatientResourceId); // Simulate the imaging study with an existing endpoint. Endpoint existingEndpoint = FhirResourceBuilder.CreateEndpointResource(id: "2345", name: "new wado-rs"); var existingEndpointResourceId = new ServerResourceId(ResourceType.Endpoint, existingEndpoint.Id); var existingEndpointReference = existingEndpointResourceId.ToResourceReference(); imagingStudy.Endpoint.Add(existingEndpointReference); Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(); var endpointResourceId = new ServerResourceId(ResourceType.Endpoint, endpoint.Id); var endpointReference = endpointResourceId.ToResourceReference(); FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset()); context.Request.Endpoint = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Endpoint>(endpointResourceId); _imagingStudyPropertySynchronizer.Synchronize(context, imagingStudy); Assert.Collection( imagingStudy.Endpoint, endPoint => Assert.Equal(existingEndpointReference, endPoint), endPoint => Assert.Equal(endpointReference, endPoint)); }
public async Task GivenATransactionContextAndImagingStudyWithExistingEndpointReference_WhenProcessedForStudy_ThenEndpointResourceIsNotAddedAsync() { ImagingStudy imagingStudy = FhirResourceBuilder.CreateNewImagingStudy(DefaultStudyInstanceUid, new List <string>() { DefaultSeriesInstanceUid }, new List <string>() { DefaultSopInstanceUid }, DefaultPatientResourceId); Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(); var endpointResourceId = new ServerResourceId(ResourceType.Endpoint, endpoint.Id); var endpointReference = endpointResourceId.ToResourceReference(); FhirTransactionContext context = FhirTransactionContextBuilder.DefaultFhirTransactionContext(FhirTransactionContextBuilder.CreateDicomDataset()); context.Request.Endpoint = FhirTransactionRequestEntryGenerator.GenerateDefaultNoChangeRequestEntry <Endpoint>(endpointResourceId); imagingStudy.Endpoint.Add(endpointReference); await _imagingStudyPropertySynchronizer.SynchronizeAsync(context, imagingStudy); Assert.Collection( imagingStudy.Endpoint, endPoint => Assert.Equal(endpointReference, endPoint)); }
public async Task GivenAnExistingEndpointWithDifferentAddress_WhenRequestIsPrepared_ThenFhirResourceValidationExceptionShouldBeThrown() { var context = new FhirTransactionContext(ChangeFeedGenerator.Generate()); Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(address: "https://dicom2"); _fhirService.RetrieveEndpointAsync(Arg.Any <string>(), DefaultCancellationToken).Returns(endpoint); await Assert.ThrowsAsync <FhirResourceValidationException>(() => _endpointPipeline.PrepareRequestAsync(context, DefaultCancellationToken)); }
public async Task GivenAnExistingEndpointWithMatchingAddress_WhenRequestIsPrepared_ThenCorrectRequestEntryShouldBeCreated() { var context = new FhirTransactionContext(ChangeFeedGenerator.Generate()); Endpoint endpoint = FhirResourceBuilder.CreateEndpointResource(address: DefaultDicomWebEndpoint); _fhirService.RetrieveEndpointAsync(Arg.Any <string>(), DefaultCancellationToken).Returns(endpoint); await _endpointPipeline.PrepareRequestAsync(context, DefaultCancellationToken); FhirTransactionRequestEntry actualEndPointEntry = context.Request.Endpoint; ValidationUtility.ValidateRequestEntryMinimumRequirementForNoChange(endpoint.ToServerResourceId(), actualEndPointEntry); }