/**
  * Checks whether the given method was called with the arguments given in expectedParamValues.
  *
  * @param name method name
  * @param expectedParamValues parameter values
  * @return true if the method was called with these parameters, false otherwise
  */
 public boolean wasMethodCalled(String name, Object... expectedParamValues) {
   MethodInvocation expected = new MethodInvocation(name, expectedParamValues);
   for (MethodInvocation invocation : invocations) {
     if (invocation.equals(expected)) {
       return true;
     }
   }
   return false;
 }
    /**
     * Checks whether the given methods were called in the given order.
     *
     * @param methodInvocations methods that should have been called
     * @return true if the method with the given parameters was called, false otherwise
     */
    public boolean wereMethodsCalledInOrder(MethodInvocation... methodInvocations) {
      if (methodInvocations == null || methodInvocations.length == 0) return true;

      int i = 0;
      for (MethodInvocation invocation : invocations) {
        if (invocation.equals(methodInvocations[i])) {
          i++;
          if (i >= methodInvocations.length) return true;
        }
      }
      return false;
    }
 /**
  * Checks whether the given method was called - allows distinguishing between overloads by
  * specifying the parameter types.
  *
  * @param name method name
  * @param paramTypes method parameters
  * @return true if the method with the given parameters was called, false otherwise
  */
 public boolean wasMethodCalled(String name, Class<?>... paramTypes) {
   for (MethodInvocation invocation : invocations) {
     if (invocation.method.equals(name) && invocation.paramTypesMatch(paramTypes)) return true;
   }
   return false;
 }