/** * Construct a new tree with the given source of function metadata. * @param source The metadata source */ public FunctionTree(String name, FunctionMetadataSource source, boolean validateClass) { // Load data structures this.schemaName = name; this.validateClass = validateClass; boolean system = CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name) || CoreConstants.SYSTEM_ADMIN_MODEL.equalsIgnoreCase(name); Collection<FunctionMethod> functions = source.getFunctionMethods(); for (FunctionMethod method : functions) { if (!containsIndistinguishableFunction(method)){ // Add to tree addFunction(name, source, method, system); } else if (!CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name)) { LogManager.logWarning(LogConstants.CTX_FUNCTION_TREE, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30011, new Object[]{method})); } } }
Class<?> methodClass = source.getInvocationClass(method.getInvocationClass()); ReflectionHelper helper = new ReflectionHelper(methodClass); try { source.getClassLoader()); if (validateClass && method.getAggregateAttributes() != null && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) { try {
Class<?> methodClass = source.getInvocationClass(method.getInvocationClass()); ReflectionHelper helper = new ReflectionHelper(methodClass); try { source.getClassLoader()); if (validateClass && method.getAggregateAttributes() != null && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) { try {
Class<?> methodClass = source.getInvocationClass(method.getInvocationClass()); ReflectionHelper helper = new ReflectionHelper(methodClass); try { source.getClassLoader()); if (validateClass && method.getAggregateAttributes() != null && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) { try {
/** * Construct a new tree with the given source of function metadata. * @param source The metadata source */ public FunctionTree(String name, FunctionMetadataSource source, boolean validateClass) { // Load data structures this.schemaName = name; this.validateClass = validateClass; boolean system = CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name) || CoreConstants.SYSTEM_ADMIN_MODEL.equalsIgnoreCase(name); Collection<FunctionMethod> functions = source.getFunctionMethods(); for (FunctionMethod method : functions) { if (!containsIndistinguishableFunction(method)){ // Add to tree addFunction(name, source, method, system); } else if (!CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name)) { LogManager.logWarning(LogConstants.CTX_FUNCTION_TREE, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30011, new Object[]{method})); } } }
/** * Construct a new tree with the given source of function metadata. * @param source The metadata source */ public FunctionTree(String name, FunctionMetadataSource source, boolean validateClass) { // Load data structures this.schemaName = name; this.validateClass = validateClass; boolean system = CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name) || CoreConstants.SYSTEM_ADMIN_MODEL.equalsIgnoreCase(name); Collection<FunctionMethod> functions = source.getFunctionMethods(); for (FunctionMethod method : functions) { if (!containsIndistinguishableFunction(method)){ // Add to tree addFunction(name, source, method, system); } else if (!CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name)) { LogManager.logWarning(LogConstants.CTX_FUNCTION_TREE, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30011, new Object[]{method})); } } }
@Test public void testNullCategory() { FunctionMethod method = new FunctionMethod( "dummy", null, null, PushDown.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ new ArrayList<FunctionParameter>(0), new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$ 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()); }