* @param enclosingType the type to which the constructor belongs
* @return the GWT constructor
*/
private JConstructor adaptConstructor(final Constructor<?> realConstructor,
JClassType enclosingType) {
final JConstructor constructor = createMock(JConstructor.class);
addCommonAbstractMethodBehaviour(realConstructor, constructor,
enclosingType);
addAnnotationBehaviour(realConstructor, constructor);
// Parameters
when(constructor.getParameters()).thenAnswer(
new Answer<JParameter[]>() {
@Override
public JParameter[] answer(InvocationOnMock invocation) throws Throwable {
return adaptParameters(realConstructor.getParameterTypes(),
realConstructor.getParameterAnnotations(), constructor);
}
});
// Thrown exceptions
when(constructor.getThrows()).thenAnswer(
new Answer<JClassType[]>() {
@Override
public JClassType[] answer(InvocationOnMock invocation) throws Throwable {
Class<?>[] realThrows = realConstructor.getExceptionTypes();
JClassType[] gwtThrows = new JClassType[realThrows.length];