java.lang.Object
com.mockobjects.ReturnValue
- public class ReturnValue
- extends java.lang.Object
The ReturnValue class allows a value to be setup which will then be returned upon a specific
method call. If value.getValue() is called before value.setValue(value)
the ReturnValue will raise an error warning that this value has not been set. If the required
return value is null the return value can be set like this
value.setValue(null) in this case calling value.getValue()
will return null.
The advantage of this is provide better information to the user of a mock when
interacting with third party code which may expect certain values to have been set.
e.g.
private final ReturnValue value = new ReturnValue("value");
public void setupValue(Integer value){
value.setValue(value);
}
public Integer getValue(){
return (Integer)value.getValue();
}
- Version:
- $Revision: 1.4 $
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
name
private final java.lang.String name
value
private java.lang.Object value
ReturnValue
public ReturnValue(java.lang.String name)
getValue
public java.lang.Object getValue()
setValue
public void setValue(java.lang.Object value)
setValue
public void setValue(boolean value)
getBooleanValue
public boolean getBooleanValue()
getIntValue
public int getIntValue()
setValue
public void setValue(int value)
setValue
public void setValue(long value)
getLongValue
public long getLongValue()