OverloadResolver { public OverloadResult<V> get(String name, List<? extends TPreptimeValue> inputs) { Iterable<? extends ScalarsGroup<V>> scalarsGroup = overloadsRegistry.get(name); if (scalarsGroup == null) { throw new NoSuchFunctionException(name); } return inputBasedResolution(name, inputs, scalarsGroup); } OverloadResolver(ResolvablesRegistry<V> overloadsRegistry, TCastResolver castsResolver); boolean isDefined(String name); OverloadResult<V> get(String name, List<? extends TPreptimeValue> inputs);  }
@Test(expected=NoSuchFunctionException.class) public void noSuchOverload() { new Initializer().init(); registry.getScalarsResolver().get("foo", Arrays.asList(prepVal(TINT))); }
@Test(expected=WrongExpressionArityException.class) public void knownOverloadTooFewParams() { new Initializer().overloads(MUL_INTS).init(); registry.getScalarsResolver().get(MUL_NAME, prepVals(TINT)); }
@Test(expected=WrongExpressionArityException.class) public void knownOverloadTooManyParams() { new Initializer().overloads(MUL_INTS).init(); registry.getScalarsResolver().get(MUL_NAME, prepVals(TINT, TINT, TINT)); }
@Test public void onePosAndRemainingWithPickingSet() { final String NAME = "coalesce"; TestGetBase coalesce = new TestGetBase(NAME, TVARCHAR); coalesce.builder().pickingVararg(null, 0); new Initializer().overloads(coalesce).init(); try { OverloadResolver.OverloadResult result = registry.getScalarsResolver().get(NAME, prepVals()); fail("WrongArity expected but got: " + result); } catch(WrongExpressionArityException e) { } checkResolved(NAME + "(INT)", coalesce, NAME, prepVals(TINT)); new Initializer().overloads(coalesce).casts(C_INT_BIGINT).types(TDATE).init(); checkResolved(NAME+"(null,INT,BIGINT)", coalesce, NAME, prepVals(null, TINT, TBIGINT)); try { checkResolved(NAME+"(null,DATE,INT)", coalesce, NAME, prepVals(null, TDATE, TINT)); fail("expected overload exception"); } catch (NoSuchCastException e) { } }