@Before public void beforeEach() { rule = RewriteAsRangeCriteria.INSTANCE; rules = new LinkedList<OptimizerRule>(); rules.add(rule); ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); print = false; }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.BuildQuery#execute() */ public QueryResults execute() { Batch batch = batch(); ExecutionContext context = getContext(); TypeSystem typeSystem = context.getValueFactories().getTypeSystem(); QueryContext queryContext = new GraphQueryContext(context, schemata, typeSystem, hints, problems, variables, batch); QueryEngine engine = getQueryEngine(); return engine.execute(queryContext, query); } };
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); rule = PushSelectCriteria.INSTANCE; }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); bestRule = ChooseJoinAlgorithm.USE_BEST_JOIN_ALGORITHM; nestedRule = ChooseJoinAlgorithm.USE_ONLY_NESTED_JOIN_ALGORITHM; }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); rule = AddAccessNodes.INSTANCE; }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); rule = RightOuterToLeftOuterJoins.INSTANCE; }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); context = new QueryContext(execContext, mock(Schemata.class), execContext.getValueFactories().getTypeSystem()); rule = AddJoinConditionColumnsToSources.INSTANCE; context.getHints().hasJoin = true; }
@Test( expected = IllegalArgumentException.class ) public void shouldFailToParseUnknownLanguage() { TypeSystem typeSystem = new ExecutionContext().getValueFactories().getTypeSystem(); parsers.parse(typeSystem, "unknown language", "This is a bogus query"); }
@Before public void beforeEach() { context = new ExecutionContext(); builder = ImmutableSchemata.createBuilder(context, context.getValueFactories().getTypeSystem()); }
@Before public void beforeEach() { typeSystem = new ExecutionContext().getValueFactories().getTypeSystem(); parser = new SqlQueryParser(); }
@Before public void beforeEach() { MockitoAnnotations.initMocks(this); this.context = new ExecutionContext(); executor = Executors.newSingleThreadExecutor(); typeSystem = context.getValueFactories().getTypeSystem(); schemata = ImmutableSchemata.createBuilder(context, typeSystem).addTable("t1", "c1", "c2", "c3").build(); sql = new SqlQueryParser(); InMemoryRepositorySource source = new InMemoryRepositorySource(); source.setName("source1"); this.wrapped = source; // Create the request processor that will be called for the search engine searchRequests = new LinkedList<Request>(); searchProcessor = new MockSearchEngineProcessor("source1", context, searchRequests); // Stub the search engine methods ... when(searchEngine.createProcessor(context, null, true)).thenReturn(searchProcessor); when(searchEngine.createProcessor(context, null, false)).thenReturn(searchProcessor); }
@Before public void beforeEach() { builder = new QueryBuilder(new ExecutionContext().getValueFactories().getTypeSystem()); }
@Test public void shouldPerformQueryWhenConnectorSupportsQueries() { // Set the expected results that will be returned from the connector ... List<Object[]> tuples = Collections.singletonList(new Object[] {"v1", "v2", "v3"}); Statistics statistics = mock(Statistics.class); nextTuples = tuples; nextStatistics = statistics; // Execute the query, and verify the results were consumed by the processor ... TypeSystem typeSystem = context.getValueFactories().getTypeSystem(); Schemata schemata = ImmutableSchemata.createBuilder(context, typeSystem).addTable("t1", "c1", "c2", "c3").build(); QueryCommand query = new SqlQueryParser().parseQuery("SELECT * FROM t1", typeSystem); QueryResults results = graph.query(query, schemata).execute(); assertThat(nextColumns, is(nullValue())); assertThat(nextTuples, is(nullValue())); assertThat(nextStatistics, is(nullValue())); // The actual results should be what the processor returned ... assertThat(results.getColumns(), is(notNullValue())); assertThat(results.getTuples(), is(tuples)); assertThat(results.getStatistics(), is(notNullValue())); assertNextRequestAccessQuery(graph.getCurrentWorkspaceName(), "t1", columns("t1", "c1", "c2", "c3"), Limit.NONE); }
@Before public void beforeEach() { planner = new CanonicalPlanner(); context = new ExecutionContext(); typeSystem = context.getValueFactories().getTypeSystem(); hints = new PlanHints(); builder = new QueryBuilder(typeSystem); problems = new SimpleProblems(); schemataBuilder = ImmutableSchemata.createBuilder(context, typeSystem); print = false; }
@Test( expected = InvalidRequestException.class ) public void shouldFailToPerformQueryWhenConnectorDoesNotSupportsQueries() { // Set the expected results that will be returned from the connector ... nextColumns = null; nextTuples = null; nextStatistics = null; // Execute the query, and verify the results were consumed by the processor ... TypeSystem typeSystem = context.getValueFactories().getTypeSystem(); Schemata schemata = ImmutableSchemata.createBuilder(context, typeSystem).addTable("t1", "c1", "c2", "c3").build(); QueryCommand query = new SqlQueryParser().parseQuery("SELECT * FROM t1", typeSystem); graph.query(query, schemata).execute(); }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); TypeSystem typeSystem = execContext.getValueFactories().getTypeSystem(); rule = ReplaceViews.INSTANCE; builder = ImmutableSchemata.createBuilder(execContext, typeSystem); builder.addTable("t1", "c11", "c12", "c13"); builder.addTable("t2", "c21", "c22", "c23"); builder.addView("v1", "SELECT c11, c12 FROM t1 WHERE c13 < CAST('3' AS LONG)"); builder.addView("v2", "SELECT t1.c11, t1.c12, t2.c23 FROM t1 JOIN t2 ON t1.c11 = t2.c21"); schemata = builder.build(); context = new QueryContext(execContext, schemata, typeSystem); }
@Before public void beforeEach() { ExecutionContext execContext = new ExecutionContext(); TypeSystem typeSystem = execContext.getValueFactories().getTypeSystem(); ImmutableSchemata.Builder builder = ImmutableSchemata.createBuilder(execContext, typeSystem); builder.addTable("t1", "c11", "c12", "c13");