public ReindexJobTaskTests() { _cancellationToken = _cancellationTokenSource.Token; var job = new ReindexJobRecord(null, 1, null); _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, () => _fhirDataStore.CreateMockScope(), NullLogger <ReindexJobTask> .Instance); }
public async System.Threading.Tasks.Task GivenResourcesWithUnchangedOrChangedIndices_WhenResultsProcessed_ThenCorrectResourcesHaveIndicesUpdated() { Func <Health.Extensions.DependencyInjection.IScoped <IFhirDataStore> > fhirDataStoreScope = () => _fhirDataStore.CreateMockScope(); var utilities = new ReindexUtilities(fhirDataStoreScope, _searchIndexer, _resourceDeserializer); var searchIndices1 = new List <SearchIndexEntry>() { new SearchIndexEntry(new Core.Models.SearchParameterInfo("param1"), new StringSearchValue("value1")) }; var searchIndices2 = new List <SearchIndexEntry>() { new SearchIndexEntry(new Core.Models.SearchParameterInfo("param2"), new StringSearchValue("value2")) }; _searchIndexer.Extract(Arg.Any <Core.Models.ResourceElement>()).Returns(searchIndices1); var entry1 = CreateSearchResultEntry("Patient", searchIndices1); _output.WriteLine($"Loaded Patient with id: {entry1.Resource.ResourceId}"); var entry2 = CreateSearchResultEntry("Observation-For-Patient-f001", searchIndices2); _output.WriteLine($"Loaded Observation with id: {entry2.Resource.ResourceId}"); var resultList = new List <SearchResultEntry>(); resultList.Add(entry1); resultList.Add(entry2); var result = new SearchResult(resultList, new List <Tuple <string, string> >(), new List <(string, string)>(), "token"); await utilities.ProcessSearchResultsAsync(result, "hash", CancellationToken.None); await _fhirDataStore.Received().UpdateSearchParameterHashBatchAsync( Arg.Is <IReadOnlyCollection <ResourceWrapper> >( c => c.Where(r => r.SearchIndices == searchIndices1 && r.ResourceTypeName.Equals("Patient")).Count() == 1), Arg.Any <CancellationToken>()); await _fhirDataStore.Received().UpdateSearchParameterIndicesBatchAsync( Arg.Is <IReadOnlyCollection <ResourceWrapper> >( c => c.Where(r => r.SearchIndices == searchIndices1 && r.ResourceTypeName.Equals("Observation")).Count() == 1), Arg.Any <CancellationToken>()); }
public ReindexUtilitiesTests(ITestOutputHelper output) { _output = output; _searchParameterHashMap = new Dictionary <string, string>() { { "Patient", "hash1" } }; Func <Health.Extensions.DependencyInjection.IScoped <IFhirDataStore> > fhirDataStoreScope = () => _fhirDataStore.CreateMockScope(); _reindexUtilities = new ReindexUtilities(fhirDataStoreScope, _searchIndexer, _resourceDeserializer, _searchParameterDefinitionManager, _searchParameterRegistry); }
public ReindexUtilitiesTests(ITestOutputHelper output) { _output = output; _searchParameterHashMap = new Dictionary <string, string>() { { "Patient", "hash1" } }; Func <Health.Extensions.DependencyInjection.IScoped <IFhirDataStore> > fhirDataStoreScope = () => _fhirDataStore.CreateMockScope(); _searchParameterStatusManager = new SearchParameterStatusManager(_searchParameterStatusDataStore, _searchParameterDefinitionManager, _searchParameterSupportResolver, _mediator, NullLogger <SearchParameterStatusManager> .Instance); _reindexUtilities = new ReindexUtilities(fhirDataStoreScope, _searchIndexer, _resourceDeserializer, _searchParameterDefinitionManager, _searchParameterStatusManager, _resourceWrapperFactory); }