private void invokeSubstitute(Object... arguments) throws Exception { try { invocationControl.getSubstitute().performSubstitutionLogic(arguments); } catch (MockitoAssertionError e) { InvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } }
private void invokeSubstitute(Object... arguments) throws Exception { try { invocationControl.getSubstitute().performSubstitutionLogic(arguments); } catch (MockitoAssertionError e) { InvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } }
@Override public Object invoke(Class<?> type, Object[] args, Class<?>[] sig) throws Exception { Constructor<?> constructor = WhiteboxImpl.getConstructor(type, sig); if (constructor.isVarArgs()) { Object varArgs = args[args.length - 1]; final int varArgsLength = Array.getLength(varArgs); Object[] oldArgs = args; args = new Object[args.length + varArgsLength - 1]; System.arraycopy(oldArgs, 0, args, 0, oldArgs.length - 1); for (int i = oldArgs.length - 1, j=0; i < args.length; i++, j++) { args[i] = Array.get(varArgs, j); } } try { return substitute.performSubstitutionLogic(args); } catch (MockitoAssertionError e) { InvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } // Won't happen return null; }
@Override public Object invoke(Class<?> type, Object[] args, Class<?>[] sig) throws Exception { Constructor<?> constructor = WhiteboxImpl.getConstructor(type, sig); if (constructor.isVarArgs()) { Object varArgs = args[args.length - 1]; final int varArgsLength = Array.getLength(varArgs); Object[] oldArgs = args; args = new Object[args.length + varArgsLength - 1]; System.arraycopy(oldArgs, 0, args, 0, oldArgs.length - 1); for (int i = oldArgs.length - 1, j=0; i < args.length; i++, j++) { args[i] = Array.get(varArgs, j); } } try { return substitute.performSubstitutionLogic(args); } catch (MockitoAssertionError e) { InvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } // Won't happen return null; }