Lines Matching refs:constructor

19  * Initialize a field with type instance if a default constructor can be found.

38 * This constructor fail fast if the field type cannot be handled.
52 * This constructor fail fast if the field type cannot be handled.
128 * to be given to a constructor given the argument types.
142 * @return The argument instances to be given to the constructor, should not be null.
152 * Constructor instantiating strategy for no-arg constructor.
155 * If a no-arg constructor can be found then the instance is created using
156 * this constructor.
175 Constructor<?> constructor = null;
177 constructor = field.getType().getDeclaredConstructor();
178 changer.enableAccess(constructor);
181 Object newFieldInstance = constructor.newInstance(noArg);
186 throw new MockitoException("the type '" + field.getType().getSimpleName() + "' has no default constructor", e);
188 throw new MockitoException("the default constructor of type '" + field.getType().getSimpleName() + "' has raised an exception (see the stack trace for cause): " + e.getTargetException().toString(), e);
194 if(constructor != null) {
195 changer.safelyDisableAccess(constructor);
205 * Choose the constructor with the highest number of parameters, then
233 Constructor<?> constructor = null;
235 constructor = biggestConstructor(field.getType());
236 changer.enableAccess(constructor);
238 final Object[] args = argResolver.resolveTypeInstances(constructor.getParameterTypes());
239 Object newFieldInstance = constructor.newInstance(args);
244 throw new MockitoException("internal error : argResolver provided incorrect types for constructor " + constructor + " of type " + field.getType().getSimpleName(), e);
246 throw new MockitoException("the constructor of type '" + field.getType().getSimpleName() + "' has raised an exception (see the stack trace for cause): " + e.getTargetException().toString(), e);
252 if(constructor != null) {
253 changer.safelyDisableAccess(constructor);
258 private void checkParameterized(Constructor<?> constructor, Field field) {
259 if(constructor.getParameterTypes().length == 0) {
260 throw new MockitoException("the field " + field.getName() + " of type " + field.getType() + " has no parameterized constructor");
268 Constructor<?> constructor = constructors.get(0);
269 checkParameterized(constructor, field);
270 return constructor;