jface.mockobject
Class Expectation

java.lang.Object
  |
  +--jface.mockobject.Expectation

public class Expectation
extends java.lang.Object

The Expectation object encapsulates all information expected as behaviour of a mock object. It contains the name of the mock method, the parameters, the possible return value and Throwable.

Version:
$Id: Expectation.java,v 1.4 2004/01/07 22:43:41 powerpete Exp $
Author:
Moritz Petersen

Constructor Summary
Expectation(java.lang.String methodName)
          Creates a new Expectation object for the mock method with the given name.
Expectation(java.lang.String methodName, boolean methodNameTolerant, boolean parametersTolerant)
          Creates a new Expectation object for the mock method with the given name.
 
Method Summary
 java.lang.String getMethodName()
          Returns the name of the expected mock method.
 java.lang.Object[] getParameters()
          Returns the expected parameters of the mock method.
 java.lang.Object getReturnValue()
          Returns the expected return value.
 java.lang.Throwable getThrowable()
          Returns the expected Throwable.
 boolean isMethodNameTolerant()
          Returns true if the next methods are skipped, until the method defined by this Expectation is reached.
 boolean isParametersTolerant()
          Returns true if the next parameters are ignored.
 jface.mockobject.Expectation parameter(java.lang.Object parameter)
          Appends a paramter to the list of expected parameters.
 jface.mockobject.Expectation parameters(java.lang.Object[] parameters)
          Appends a number of parameters to the list of expected parameters.
 jface.mockobject.Expectation returnValue(java.lang.Object returnValue)
          Sets the expected return value.
 void setMethodNameTolerant(boolean methodNameTolerant)
          Set to true if the next methods should be skipped, until the method defined by this Expectation is reached.
 void setParametersTolerant(boolean parametersTolerant)
          Set to true if the next parameter values should be ingored.
 jface.mockobject.Expectation throwable(java.lang.Throwable throwable)
          Sets the expected Throwable.
 java.lang.String toString()
          Returns the String representaiton of this Expectation instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expectation

public Expectation(java.lang.String methodName)
Creates a new Expectation object for the mock method with the given name.

Parameters:
methodName - The name of the mock method.

Expectation

public Expectation(java.lang.String methodName,
                   boolean methodNameTolerant,
                   boolean parametersTolerant)
Creates a new Expectation object for the mock method with the given name. It is possible to make it ignore the method calls until this method is reached. Set methodNameTolerat to true. If the method parameters should be ignored, too, set parametersTolerant to true.

Parameters:
methodName - The name of the method.
methodNameTolerant - If true, all methods are ignored until the given method is reached.
parametersTolerant - If true, all method parameters are ignored.
Method Detail

getMethodName

public java.lang.String getMethodName()
Returns the name of the expected mock method.

Returns:
The name of the expected mock method.

getParameters

public java.lang.Object[] getParameters()
Returns the expected parameters of the mock method.

Returns:
The expected parameters of the mock method.

getReturnValue

public java.lang.Object getReturnValue()
Returns the expected return value.

Returns:
The expected return value.

getThrowable

public java.lang.Throwable getThrowable()
Returns the expected Throwable. If not null, this Throwable will be thrown by the mock method.

Returns:
the expected Throwable.

parameter

public jface.mockobject.Expectation parameter(java.lang.Object parameter)
Appends a paramter to the list of expected parameters.

Parameters:
parameter - An additional expected parameter.
Returns:
This object itself.

parameters

public jface.mockobject.Expectation parameters(java.lang.Object[] parameters)
Appends a number of parameters to the list of expected parameters.

Parameters:
parameters - Each element of the array will be added as a single expected parameter.
Returns:
This object itself.

returnValue

public jface.mockobject.Expectation returnValue(java.lang.Object returnValue)
Sets the expected return value.

Parameters:
returnValue - The expected return value.
Returns:
This object itself.

throwable

public jface.mockobject.Expectation throwable(java.lang.Throwable throwable)
Sets the expected Throwable.

Parameters:
throwable - The expected Throwable.
Returns:
This object itself.

toString

public java.lang.String toString()
Returns the String representaiton of this Expectation instance.

Overrides:
toString in class java.lang.Object

isMethodNameTolerant

public boolean isMethodNameTolerant()
Returns true if the next methods are skipped, until the method defined by this Expectation is reached.

Returns:
Returns true if the next methods ares skipped.

setMethodNameTolerant

public void setMethodNameTolerant(boolean methodNameTolerant)
Set to true if the next methods should be skipped, until the method defined by this Expectation is reached.

Parameters:
methodNameTolerant - If true, the next methods are skipped, until the method defined by this Expectation is reached.

isParametersTolerant

public boolean isParametersTolerant()
Returns true if the next parameters are ignored.

Returns:
Returns true if the next parameters are ignored.

setParametersTolerant

public void setParametersTolerant(boolean parametersTolerant)
Set to true if the next parameter values should be ingored.

Parameters:
parametersTolerant - If true, the next parameter values will be ignored.


Copyright © 2003-2004 jface.org. All Rights Reserved.