public async Task InitializeAsync()
        {
            _fhirOperationDataStore         = _fixture.OperationDataStore;
            _fhirStorageTestHelper          = _fixture.TestHelper;
            _scopedOperationDataStore       = _fixture.OperationDataStore.CreateMockScope();
            _scopedDataStore                = _fixture.DataStore.CreateMockScope();
            _searchParameterStatusDataStore = _fixture.SearchParameterStatusDataStore;

            _jobConfiguration = new ReindexJobConfiguration();
            IOptions <ReindexJobConfiguration> optionsReindexConfig = Substitute.For <IOptions <ReindexJobConfiguration> >();

            optionsReindexConfig.Value.Returns(_jobConfiguration);

            _searchParameterDefinitionManager = new SearchParameterDefinitionManager(ModelInfoProvider.Instance);
            await _searchParameterDefinitionManager.StartAsync(CancellationToken.None);

            _supportedSearchParameterDefinitionManager = new SupportedSearchParameterDefinitionManager(_searchParameterDefinitionManager);
            var fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();

            _searchableSearchParameterDefinitionManager = new SearchableSearchParameterDefinitionManager(_searchParameterDefinitionManager, fhirRequestContextAccessor);

            ResourceWrapperFactory wrapperFactory = Mock.TypeWithArguments <ResourceWrapperFactory>(
                new RawResourceFactory(new FhirJsonSerializer()),
                _searchIndexer,
                _searchableSearchParameterDefinitionManager,
                Deserializers.ResourceDeserializer);

            _searchParameterStatusManager = new SearchParameterStatusManager(
                _searchParameterStatusDataStore,
                _searchParameterDefinitionManager,
                _searchParameterSupportResolver,
                _mediator);

            _createReindexRequestHandler = new CreateReindexRequestHandler(
                _fhirOperationDataStore,
                DisabledFhirAuthorizationService.Instance,
                optionsReindexConfig,
                _searchParameterDefinitionManager);
            _reindexUtilities = new ReindexUtilities(
                () => _scopedDataStore,
                _searchIndexer,
                Deserializers.ResourceDeserializer,
                _supportedSearchParameterDefinitionManager,
                _searchParameterStatusManager,
                wrapperFactory);

            coreOptions.Value.Returns(new CoreFeatureConfiguration());

            var searchParameterExpressionParser = new SearchParameterExpressionParser(new ReferenceSearchValueParser(fhirRequestContextAccessor));
            var expressionParser     = new ExpressionParser(() => _searchableSearchParameterDefinitionManager, searchParameterExpressionParser);
            var searchOptionsFactory = new SearchOptionsFactory(expressionParser, () => _searchableSearchParameterDefinitionManager, coreOptions, fhirRequestContextAccessor, _sortingValidator, NullLogger <SearchOptionsFactory> .Instance);
            var cosmosSearchService  = new FhirCosmosSearchService(searchOptionsFactory, _fixture.DataStore as CosmosFhirDataStore, new QueryBuilder(), _searchParameterDefinitionManager, fhirRequestContextAccessor) as ISearchService;

            _searchService = cosmosSearchService.CreateMockScope();

            await _fhirStorageTestHelper.DeleteAllReindexJobRecordsAsync(CancellationToken.None);
        }
Exemple #2
0
        public ReindexJobTests(FhirStorageTestsFixture fixture)
        {
            _fhirOperationDataStore   = fixture.OperationDataStore;
            _fhirStorageTestHelper    = fixture.TestHelper;
            _scopedOperationDataStore = fixture.OperationDataStore.CreateMockScope();
            _scopedOperationDataStore = fixture.OperationDataStore.CreateMockScope();
            _scopedDataStore          = fixture.DataStore.CreateMockScope();

            _jobConfiguration = new ReindexJobConfiguration();
            IOptions <ReindexJobConfiguration> optionsReindexConfig = Substitute.For <IOptions <ReindexJobConfiguration> >();

            optionsReindexConfig.Value.Returns(_jobConfiguration);

            _searchParameterDefinitionManager = new SearchParameterDefinitionManager(ModelInfoProvider.Instance);
            _searchParameterDefinitionManager.Start();
            _searchParameterDefinitionManager.UpdateSearchParameterHashMap(new Dictionary <string, string>()
            {
                { "Patient", "newHash" }
            });
            _supportedSearchParameterDefinitionManager = new SupportedSearchParameterDefinitionManager(_searchParameterDefinitionManager);
            var fhirRequestContextAccessor = Substitute.For <IFhirRequestContextAccessor>();

            _searchableSearchParameterDefinitionManager = new SearchableSearchParameterDefinitionManager(_searchParameterDefinitionManager, fhirRequestContextAccessor);

            _createReindexRequestHandler = new CreateReindexRequestHandler(
                _fhirOperationDataStore,
                DisabledFhirAuthorizationService.Instance,
                optionsReindexConfig,
                _searchParameterDefinitionManager);
            _reindexUtilities = new ReindexUtilities(
                () => _scopedDataStore,
                _searchIndexer,
                Deserializers.ResourceDeserializer,
                _supportedSearchParameterDefinitionManager,
                _searchParameterRegistry);

            coreOptions.Value.Returns(new CoreFeatureConfiguration());

            var searchParameterExpressionParser = new SearchParameterExpressionParser(() => _searchParameterDefinitionManager, new ReferenceSearchValueParser(fhirRequestContextAccessor));
            var expressionParser     = new ExpressionParser(() => _searchableSearchParameterDefinitionManager, searchParameterExpressionParser);
            var searchOptionsFactory = new SearchOptionsFactory(expressionParser, () => _searchableSearchParameterDefinitionManager, coreOptions, fhirRequestContextAccessor, NullLogger <SearchOptionsFactory> .Instance);
            var cosmosSearchService  = new FhirCosmosSearchService(searchOptionsFactory, fixture.DataStore as CosmosFhirDataStore, new QueryBuilder()) as ISearchService;

            _searchService = cosmosSearchService.CreateMockScope();
        }