/** * Finds and returns any constructor. If the constructor couldn't be * found this method delegates to {@link #throwExceptionWhenMultipleConstructorMatchesFound(java.lang.reflect.Constructor[])}. * * @param type The type where the constructor should be located. * @return The found constructor. * @throws TooManyConstructorsFoundException if too many constructors was found. */ public static Constructor<?> findConstructorOrThrowException(Class<?> type) { final Constructor<?>[] declaredConstructors = filterPowerMockConstructor(type.getDeclaredConstructors()); if (declaredConstructors.length > 1) { throwExceptionWhenMultipleConstructorMatchesFound(declaredConstructors); } return declaredConstructors[0]; }
/** * Finds and returns a certain constructor. If the constructor couldn't be * found this method delegates to * * @param type * The type where the constructor should be located. * @return The found constructor. * {@link Whitebox#throwExceptionIfConstructorWasNotFound(Class, Object...) * . */ public static Constructor<?> findConstructorOrThrowException(Class<?> type) { final Constructor<?>[] declaredConstructors = filterPowerMockConstructor(type.getDeclaredConstructors()); if (declaredConstructors.length > 1) { throwExceptionWhenMultipleConstructorMatchesFound(declaredConstructors); } return declaredConstructors[0]; }
Constructor<?>[] constructors = filterPowerMockConstructor(unmockedType.getDeclaredConstructors()); Constructor<?> potentialConstructor = null; for (Constructor<?> constructor : constructors) {