org.virtualmock.call
Class RecordedCall

java.lang.Object
  extended byorg.virtualmock.call.Call
      extended byorg.virtualmock.call.RecordedCall

public class RecordedCall
extends Call

Represents a method invocation of a recorded mock call. This is a subclass of Call which only contains information which is specific to recorded calls.

Version:
$Revision: 1.32 $
Author:
Chad Woolley

Constructor Summary
RecordedCall(Signature signature)
          Creates a new RecordedCall object.
RecordedCall(Signature signature, java.lang.Object[] argValues)
          Creates a new RecordedCall object.
RecordedCall(Signature signature, java.lang.Object[] argValues, java.lang.Object returnValue)
          Creates a new RecordedCall object which has a return value.
RecordedCall(Signature signature, java.lang.Object[] argValues, java.lang.Throwable throwable)
          Creates a new RecordedCall object which throws an exception.
 
Method Summary
 ArgMatcher[] getArgMatchers()
          Gets the ArgMatchers that are defined for this call (if any).
 int getInvocationCount()
          Returns the number of times incrementInvocationCount() has been called on this Call.
 boolean hasMatchingArgs(Call call)
           Performs matching of all arguments on this Call to the specified Call, based on the ArgMatchers that are defined for this call.
 boolean hasUnlimitedInvocations()
          Return true if this call has unlimited invocations set.
 void incrementInvocationCount()
          Increments the internal invocation count for this call by one.
 boolean isInvocable()
          Indicates if this call is invocable.
 boolean isInvoked()
          Returns true if invocation count is greater than zero.
 boolean matches(Call call)
          Returns true if hasMatchingSignature() and hasMatchingArgs() both return true.
 void setArgMatchers(ArgMatcher[] argMatchers)
          Sets the ArgMatchers that are defined for this call.
 void setUnlimitedInvocations(boolean unlimitedInvocations)
          Set that this call can be invoked an unlimited number of times.
 
Methods inherited from class org.virtualmock.call.Call
getArgTypes, getArgValues, getCallId, getClassName, getMethodName, getReturnType, getReturnValue, getSignature, getSignatureSequence, getThrowable, hasArguments, hasMatchingSignature, hasMatchingSignature, hasReturnValue, isReturnTypePrimitive, setReturnValue, setSignatureSequence, setThrowable, toString, validateArguments, validateReturnValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecordedCall

public RecordedCall(Signature signature,
                    java.lang.Object[] argValues)
Creates a new RecordedCall object.

Parameters:
signature - the unique identifier for the call
argValues - an array representing the values of the arguments passed to (or expected by) the call.

RecordedCall

public RecordedCall(Signature signature)
Creates a new RecordedCall object.

Parameters:
signature - the unique identifier for the call

RecordedCall

public RecordedCall(Signature signature,
                    java.lang.Object[] argValues,
                    java.lang.Object returnValue)
Creates a new RecordedCall object which has a return value.

Parameters:
signature - the method signature for the call
argValues - an array representing the values of the arguments passed to (or expected by) the call.
returnValue - the value the call will return

RecordedCall

public RecordedCall(Signature signature,
                    java.lang.Object[] argValues,
                    java.lang.Throwable throwable)
Creates a new RecordedCall object which throws an exception.

Parameters:
signature - the method signature for the call
argValues - an array representing the values of the arguments passed to (or expected by) the call.
throwable - the exception the call will throw
Method Detail

setArgMatchers

public void setArgMatchers(ArgMatcher[] argMatchers)
Sets the ArgMatchers that are defined for this call.

Parameters:
argMatchers - the array of ArgMatchers to use for this call
Throws:
java.lang.IllegalArgumentException - if the number of ArgTypes does not match the number of ArgMatchers

getArgMatchers

public ArgMatcher[] getArgMatchers()
Gets the ArgMatchers that are defined for this call (if any).

Returns:
the array of ArgMatchers that are defined for this call, or null if none have been defined.

isInvocable

public boolean isInvocable()
Indicates if this call is invocable. A call is invocable if has not yet been invoked, or if unlimited invocation is set.

Returns:
true if this call is invocable

getInvocationCount

public int getInvocationCount()
Returns the number of times incrementInvocationCount() has been called on this Call.

Returns:
the number of times incrementInvocationCount() has been called on this Call.

isInvoked

public boolean isInvoked()
Returns true if invocation count is greater than zero.

Returns:
true if invocation count is greater than zero.

setUnlimitedInvocations

public void setUnlimitedInvocations(boolean unlimitedInvocations)
Set that this call can be invoked an unlimited number of times.

Parameters:
unlimitedInvocations - boolean flag.

hasMatchingArgs

public boolean hasMatchingArgs(Call call)

Performs matching of all arguments on this Call to the specified Call, based on the ArgMatchers that are defined for this call. For ArgMatchers where the order is relevant (such as GreaterThanMatcher), it is important to know that the Call is matched TO the Call. In other words, Call GreaterThan Call is checked to see if the match is true.

Note that all matching is done based on position. This means that that all arguments and matchers must be in the same corresponding order on this Call, the Call which was passed, and the ArgMatchers for this Call.

Parameters:
call - The Call which will be matched to this Call
Returns:
true if the this Call matches the Call, or false if it does not
Throws:
java.lang.IllegalArgumentException - if the signatures of the calls do not match

hasUnlimitedInvocations

public boolean hasUnlimitedInvocations()
Return true if this call has unlimited invocations set.

Returns:
true if this call has unlimited invocations set.

incrementInvocationCount

public void incrementInvocationCount()
Increments the internal invocation count for this call by one.


matches

public boolean matches(Call call)
Returns true if hasMatchingSignature() and hasMatchingArgs() both return true.

Parameters:
call - Call to match against
Returns:
true if hasMatchingSignature() and hasMatchingArgs() both return true.


Copyright © 2003-2005 Virtual Mock. All Rights Reserved.