return helpTestProcess(sql, metadata, dataMgr, expectedException, new DefaultCapabilitiesFinder(), expectedDoc);
}
static ProcessorPlan helpTestProcess(String sql, FakeMetadataFacade metadata, FakeDataManager dataMgr, Class expectedException, CapabilitiesFinder capFinder, String... expectedDoc) throws Exception{
Command command = helpGetCommand(sql, metadata);
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
try {
CommandContext planningContext = new CommandContext(); //this should be the same as the processing context, but that's not easy to do
planningContext.setMetadata(new TempMetadataAdapter(metadata, new TempMetadataStore()));
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, planningContext);
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
List[] expected = new List[expectedDoc.length];
for (int i = 0; i < expectedDoc.length; i++) {
expected[i] = Arrays.asList(expectedDoc[i]);
}
TestProcessor.helpProcess(plan, planningContext, dataMgr, expected);
assertNull("Expected failure", expectedException);
return plan;
} catch (Exception e) {
if (expectedException == null) {
throw e;
}
assertTrue(expectedException.isInstance(e));
} finally {
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
}
}
return null;
}