Beispiel #1
0
        public static QueryExecutionEngine Initialize(Dependencies deps, GraphDatabaseAPI graphAPI, IEnumerable <QueryEngineProvider> providers)
        {
            IList <QueryEngineProvider> engineProviders = new IList <QueryEngineProvider> {
                providers
            };

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            engineProviders.sort(System.Collections.IComparer.comparingInt(QueryEngineProvider::enginePriority));
            QueryEngineProvider provider = Iterables.firstOrNull(engineProviders);

            if (provider == null)
            {
                return(NoEngine());
            }
            QueryExecutionEngine engine = provider.CreateEngine(deps, graphAPI);

            return(deps.SatisfyDependency(engine));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPickTheOneAndOnlyQueryEngineAvailable()
        public virtual void ShouldPickTheOneAndOnlyQueryEngineAvailable()
        {
            // Given
            QueryEngineProvider provider = mock(typeof(QueryEngineProvider));

            when(provider.EnginePriority()).thenReturn(1);
            Dependencies         deps            = new Dependencies();
            GraphDatabaseAPI     graphAPI        = mock(typeof(GraphDatabaseAPI));
            QueryExecutionEngine executionEngine = mock(typeof(QueryExecutionEngine));

            when(provider.CreateEngine(any(), any())).thenReturn(executionEngine);

            // When
            IEnumerable <QueryEngineProvider> providers = Iterables.asIterable(provider);
            QueryExecutionEngine engine = QueryEngineProvider.Initialize(deps, graphAPI, providers);

            // Then
            assertSame(executionEngine, engine);
        }