use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestExpressionEvaluator method helpTestCommandPayload.
public void helpTestCommandPayload(Serializable payload, String property, String expectedValue) throws Exception {
// $NON-NLS-1$
Function func = new Function("commandpayload", new Expression[] {});
Class[] parameterSignature = null;
if (property == null) {
parameterSignature = new Class[] {};
} else {
parameterSignature = new Class[] { String.class };
}
// $NON-NLS-1$
FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("commandpayload", parameterSignature);
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
CommandContext context = new CommandContext(null, "user", payload, "vdb", 1, false);
if (property != null) {
func.setArgs(new Expression[] { new Constant(property) });
}
String actual = (String) new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList());
assertEquals(expectedValue, actual);
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestExpressionEvaluator method testLookupFunction.
@Test
public void testLookupFunction() {
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("e1");
e1.setType(String.class);
// $NON-NLS-1$
ElementSymbol e2 = new ElementSymbol("e2");
e1.setType(Integer.class);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), e1 });
// $NON-NLS-1$
FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class });
func.setFunctionDescriptor(desc);
Expression[] elements = new Expression[] { e1, e2 };
Object[] values = new Object[] { // $NON-NLS-1$
"xyz", // $NON-NLS-1$
new Integer(5) };
FakeDataManager dataMgr = new FakeDataManager();
Map valueMap = new HashMap();
// $NON-NLS-1$
valueMap.put("xyz", new Integer(5));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dataMgr.defineCodeTable("pm1.g1", "e1", "e2", valueMap);
helpTestEval(func, elements, values, dataMgr, null, new Integer(5));
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestAccessNode method testExecCount.
@Test
public void testExecCount() throws Exception {
// Setup
AccessNode node = new AccessNode(1);
// $NON-NLS-1$
Query query = (Query) TestResolver.helpResolve("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5", RealMetadataFactory.example1Cached());
node.setCommand(query);
CommandContext context = new CommandContext();
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
node.setElements(query.getProjectedSymbols());
node.initialize(context, bm, dataManager);
// Call open()
node.open();
// $NON-NLS-1$
assertEquals(Arrays.asList("SELECT e1, e2 FROM pm1.g1 WHERE e2 = 5"), dataManager.getQueries());
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestPreparedStatement method testLimitParam.
@Test
public void testLimitParam() throws Exception {
// $NON-NLS-1$
String preparedSql = "select e1 from pm1.g1 order by e1 desc limit ?";
List<?> values = Arrays.asList(1);
List<?>[] expected = new List<?>[] { // $NON-NLS-1$s
Arrays.asList("c") };
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
helpTestProcessing(preparedSql, values, expected, dataManager, RealMetadataFactory.example1Cached(), false, false, RealMetadataFactory.example1VDB());
}
use of org.teiid.query.processor.FakeDataManager in project teiid by teiid.
the class TestPreparedStatement method testExecParam.
@Test
public void testExecParam() throws Exception {
// $NON-NLS-1$
String preparedSql = "exec pm1.sq2(?)";
// $NON-NLS-1$
List<String> values = Arrays.asList("c");
List<?>[] expected = new List<?>[] { Arrays.asList("c", 1) };
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
helpTestProcessing(preparedSql, values, expected, dataManager, RealMetadataFactory.example1Cached(), false, false, RealMetadataFactory.example1VDB());
}
Aggregations