public ExportJobTaskTests() { _cancellationToken = _cancellationTokenSource.Token; _exportJobRecord = new ExportJobRecord( new Uri("https://localhost/ExportJob/"), "Patient", "hash"); _fhirOperationDataStore.UpdateExportJobAsync(_exportJobRecord, _weakETag, _cancellationToken).Returns(x => { _lastExportJobOutcome = new ExportJobOutcome(_exportJobRecord, _weakETag); return(_lastExportJobOutcome); }); _secretStore.GetSecretAsync(Arg.Any <string>(), _cancellationToken).Returns(x => new SecretWrapper(x.ArgAt <string>(0), "{\"destinationType\": \"in-memory\"}")); _exportDestinationClientFactory.Create("in-memory").Returns(_inMemoryDestinationClient); _resourceToByteArraySerializer.Serialize(Arg.Any <ResourceWrapper>()).Returns(x => Encoding.UTF8.GetBytes(x.ArgAt <ResourceWrapper>(0).ResourceId)); _exportJobTask = new ExportJobTask( () => _fhirOperationDataStore.CreateMockScope(), _secretStore, Options.Create(_exportJobConfiguration), () => _searchService.CreateMockScope(), _resourceToByteArraySerializer, _exportDestinationClientFactory, NullLogger <ExportJobTask> .Instance); }
public ExportJobTaskTests() { _cancellationToken = _cancellationTokenSource.Token; SetupExportJobRecordAndOperationDataStore(); _resourceToByteArraySerializer.Serialize(Arg.Any <ResourceWrapper>()).Returns(x => Encoding.UTF8.GetBytes(x.ArgAt <ResourceWrapper>(0).ResourceId)); _exportJobTask = new ExportJobTask( () => _fhirOperationDataStore.CreateMockScope(), Options.Create(_exportJobConfiguration), () => _searchService.CreateMockScope(), _resourceToByteArraySerializer, _inMemoryDestinationClient, NullLogger <ExportJobTask> .Instance); }
public ReindexJobTaskTests() { _cancellationToken = _cancellationTokenSource.Token; var job = CreateReindexJobRecord(); _fhirOperationDataStore.UpdateReindexJobAsync(job, _weakETag, _cancellationToken).ReturnsForAnyArgs(new ReindexJobWrapper(job, _weakETag)); _searchService.SearchForReindexAsync( Arg.Any <IReadOnlyList <Tuple <string, string> > >(), Arg.Any <string>(), true, Arg.Any <CancellationToken>()). Returns(new SearchResult(5, new List <Tuple <string, string> >())); _reindexJobTask = new ReindexJobTask( () => _fhirOperationDataStore.CreateMockScope(), Options.Create(_reindexJobConfiguration), () => _searchService.CreateMockScope(), SearchParameterFixtureData.SupportedSearchDefinitionManager, _reindexUtilities, NullLogger <ReindexJobTask> .Instance); _reindexUtilities.UpdateSearchParameters(Arg.Any <IReadOnlyCollection <string> >(), Arg.Any <CancellationToken>()).Returns(x => (true, null)); }
public async Task InitializeAsync() { _fhirOperationDataStore = _fixture.OperationDataStore; _fhirStorageTestHelper = _fixture.TestHelper; _scopedOperationDataStore = _fhirOperationDataStore.CreateMockScope(); _scopedDataStore = _fixture.DataStore.CreateMockScope(); _jobConfiguration = new ReindexJobConfiguration(); IOptions <ReindexJobConfiguration> optionsReindexConfig = Substitute.For <IOptions <ReindexJobConfiguration> >(); optionsReindexConfig.Value.Returns(_jobConfiguration); _searchParameterDefinitionManager = _fixture.SearchParameterDefinitionManager; _supportedSearchParameterDefinitionManager = _fixture.SupportedSearchParameterDefinitionManager; ResourceWrapperFactory wrapperFactory = Mock.TypeWithArguments <ResourceWrapperFactory>( new RawResourceFactory(new FhirJsonSerializer()), new FhirRequestContextAccessor(), _searchIndexer, _searchParameterDefinitionManager, Deserializers.ResourceDeserializer); _searchParameterStatusManager = _fixture.SearchParameterStatusManager; _createReindexRequestHandler = new CreateReindexRequestHandler( _fhirOperationDataStore, DisabledFhirAuthorizationService.Instance, optionsReindexConfig, _searchParameterDefinitionManager, _searchParameterOperations); _reindexUtilities = new ReindexUtilities( () => _scopedDataStore, _searchIndexer, Deserializers.ResourceDeserializer, _supportedSearchParameterDefinitionManager, _searchParameterStatusManager, wrapperFactory); _searchService = _fixture.SearchService.CreateMockScope(); await _fhirStorageTestHelper.DeleteAllReindexJobRecordsAsync(CancellationToken.None); _throttleController.GetThrottleBasedDelay().Returns(0); _throttleController.GetThrottleBatchSize().Returns(100U); }
public async Task GivenInvalidSearchParam_WhenValidatingSearchParam_ThenResourceNotValidExceptionThrown(SearchParameter searchParam, string method) { var validator = new SearchParameterValidator(() => _fhirOperationDataStore.CreateMockScope(), _authorizationService, _searchParameterDefinitionManager); await Assert.ThrowsAsync <ResourceNotValidException>(() => validator.ValidateSearchParamterInput(searchParam, method, CancellationToken.None)); }