public static Object invoke ( Class < ? > returnType , String className , String methodName ) { // If we have an explicit implementation for this method, invoke it if ( STUB_METHODS . containsKey ( new ClassAndMethod ( className , methodName ) ) ) { return STUB_METHODS . get ( new ClassAndMethod ( className , methodName ) ) . invoke ( ) ; } // Otherwise return an appropriate basic type if ( returnType == String . class ) { return "" ; } else if ( returnType == Boolean . class ) { return false ; } else if ( returnType == Byte . class ) { return ( byte ) 0 ; } else if ( returnType == Character . class ) { return ( char ) 0 ; } else if ( returnType == Double . class ) { return ( double ) 0 ; } else if ( returnType == Integer . class ) { return ( int ) 0 ; } else if ( returnType == Float . class ) { return ( float ) 0 ; } else if ( returnType == Long . class ) { return ( long ) 0 ; } else if ( returnType == Short . class ) { return ( short ) 0 ; } else { return Mockito . mock ( returnType , new ReturnsCustomMocks ( ) ) ; } }
Invokes the stubbed behavior of the given method .