use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestFunctionTree method testMultiPartName.
@Test
public void testMultiPartName() throws Exception {
FunctionMethod method = new FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"x.y.dummy", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.CANNOT_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
TestFunctionTree.class.getName(), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"toString", // $NON-NLS-1$
Arrays.asList(new FunctionParameter("in", DataTypeManager.DefaultDataTypes.VARBINARY)), // $NON-NLS-1$
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), true, Determinism.DETERMINISTIC);
FunctionTree sys = RealMetadataFactory.SFM.getSystemFunctions();
FunctionLibrary fl = new FunctionLibrary(sys, new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true));
assertNotNull(fl.findFunction("dummy", new Class<?>[] { DataTypeManager.DefaultDataClasses.VARBINARY }));
assertNotNull(fl.findFunction("y.dummy", new Class<?>[] { DataTypeManager.DefaultDataClasses.VARBINARY }));
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestFunctionTree method testNullCategory.
@Test
public void testNullCategory() {
FunctionMethod method = new FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"dummy", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
null, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.MUST_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"nonexistentClass", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"noMethod", new ArrayList<FunctionParameter>(0), // $NON-NLS-1$
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), false, Determinism.DETERMINISTIC);
Collection<org.teiid.metadata.FunctionMethod> list = Arrays.asList(method);
FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
Mockito.stub(fms.getFunctionMethods()).toReturn(list);
FunctionTree ft = new FunctionTree("foo", fms);
assertEquals(1, ft.getFunctionsInCategory(FunctionCategoryConstants.MISCELLANEOUS).size());
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestFunctionMethod method testEquivalence1.
@Test
public void testEquivalence1() {
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter p1 = new FunctionParameter("in", "string");
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string");
FunctionMethod m1 = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
"length", // $NON-NLS-1$ //$NON-NLS-2$
"", // $NON-NLS-1$ //$NON-NLS-2$
FunctionCategoryConstants.STRING, // $NON-NLS-1$ //$NON-NLS-2$
"com.metamatrix.query.function.FunctionMethods", // $NON-NLS-1$ //$NON-NLS-2$
"length", new FunctionParameter[] { p1 }, pout);
UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestFunctionMethod method testEquivalence11.
@Test
public void testEquivalence11() {
// $NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string");
FunctionMethod m1 = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
"length", // $NON-NLS-1$ //$NON-NLS-2$
"", // $NON-NLS-1$ //$NON-NLS-2$
FunctionCategoryConstants.STRING, // $NON-NLS-1$ //$NON-NLS-2$
"com.metamatrix.query.function.FunctionMethods", // $NON-NLS-1$ //$NON-NLS-2$
"length", null, pout);
UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestLocalConnections method oneTimeSetup.
@SuppressWarnings("serial")
@BeforeClass
public static void oneTimeSetup() throws Exception {
server.setUseCallingThread(true);
server.setConnectorManagerRepository(new ConnectorManagerRepository() {
@Override
public ConnectorManager getConnectorManager(String connectorName) {
return new ConnectorManager(connectorName, connectorName) {
@Override
public ExecutionFactory<Object, Object> getExecutionFactory() {
return new ExecutionFactory<Object, Object>() {
@Override
public boolean isSourceRequired() {
return false;
}
@Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws TranslatorException {
return new ResultSetExecution() {
boolean returnedRow = false;
@Override
public void execute() throws TranslatorException {
lock.lock();
try {
sourceCounter.release();
if (!wait.await(5, TimeUnit.SECONDS)) {
throw new RuntimeException();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
lock.unlock();
}
}
@Override
public void close() {
}
@Override
public void cancel() throws TranslatorException {
}
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
if (returnedRow) {
return null;
}
returnedRow = true;
return new ArrayList<Object>(Collections.singleton(null));
}
};
}
};
}
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
}
});
FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), false, FunctionMethod.Determinism.NONDETERMINISTIC);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
udfs.put("test", Arrays.asList(function));
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", new DeployVDBParameter(udfs, null));
}
Aggregations