Top Description Methods
org.easymock

public Interface IExpectationSetters<T>

Known Direct Implementers
org.easymock.internal.MocksControl
Type Parameters
<T>
type of what should be returned by this expected call

Allows setting expectations for an associated expected invocation. Implementations of this interface are returned by EasyMock#expect(Object), and by EasyMock#expectLastCall().
Author
OFFIS, Tammo Freese

Method Summary

Modifier and TypeMethod and Description
public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
andAnswer
(IAnswer<? extends T>
the object used to answer the invocation.
answer
)

Sets an object that will be used to calculate the answer for the expected invocation (either return a value, or throw an exception).

public IExpectationSetters<T>

Returns:

the value returned by the delegated call.
andDelegateTo
(Object
the object the call is delegated to.
delegateTo
)

Sets an object implementing the same interface as the mock.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
andReturn
(T
the value to return.
value
)

Sets a return value that will be returned for the expected invocation.

public void
andStubAnswer(IAnswer<? extends T>
the object used to answer the invocation.
answer
)

Sets a stub object that will be used to calculate the answer for the expected invocation (either return a value, or throw an exception).

public void
andStubDelegateTo(Object
the object the call is delegated to.
delegateTo
)

Sets a stub object implementing the same interface as the mock.

public void
andStubReturn(T
the value to return.
value
)

Sets a stub return value that will be returned for the expected invocation.

public void
andStubThrow(Throwable
the throwable to throw.
throwable
)

Sets a stub throwable that will be thrown for the expected invocation.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
andThrow
(Throwable
the throwable to throw.
throwable
)

Sets a throwable that will be thrown for the expected invocation.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
andVoid
()

Records a call but returns nothing.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
anyTimes
()

Expect the last invocation any times.

public void
asStub()

Sets stub behavior for the expected invocation (this is needed for void methods).

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
atLeastOnce
()

Expect the last invocation at least once.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
once
()

Expect the last invocation once.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
times
(int
the number of invocations expected
count
)

Expect the last invocation count times.

public IExpectationSetters<T>

Returns:

this object to allow method call chaining.
times
(int
the minimum number of invocations expected.
min
,
int
the maximum number of invocations expected.
max
)

Expect the last invocation between min and max times.

Method Detail

andAnswerback to summary
public IExpectationSetters<T> andAnswer(IAnswer<? extends T> answer)

Sets an object that will be used to calculate the answer for the expected invocation (either return a value, or throw an exception).

Parameters
answer:IAnswer<? extends T>

the object used to answer the invocation.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

andDelegateToback to summary
public IExpectationSetters<T> andDelegateTo(Object delegateTo)

Sets an object implementing the same interface as the mock. The expected method call will be delegated to it with the actual arguments. The answer returned by this call will then be the answer returned by the mock (either return a value, or throw an exception).

Parameters
delegateTo:Object

the object the call is delegated to.

Returns:IExpectationSetters<T>

the value returned by the delegated call.

andReturnback to summary
public IExpectationSetters<T> andReturn(T value)

Sets a return value that will be returned for the expected invocation.

Parameters
value:T

the value to return.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

andStubAnswerback to summary
public void andStubAnswer(IAnswer<? extends T> answer)

Sets a stub object that will be used to calculate the answer for the expected invocation (either return a value, or throw an exception).

Parameters
answer:IAnswer<? extends T>

the object used to answer the invocation.

andStubDelegateToback to summary
public void andStubDelegateTo(Object delegateTo)

Sets a stub object implementing the same interface as the mock. The expected method call will be delegated to it with the actual arguments. The answer returned by this call will then be the answer returned by the mock (either return a value, or throw an exception).

Parameters
delegateTo:Object

the object the call is delegated to.

andStubReturnback to summary
public void andStubReturn(T value)

Sets a stub return value that will be returned for the expected invocation.

Parameters
value:T

the value to return.

andStubThrowback to summary
public void andStubThrow(Throwable throwable)

Sets a stub throwable that will be thrown for the expected invocation.

Parameters
throwable:Throwable

the throwable to throw.

andThrowback to summary
public IExpectationSetters<T> andThrow(Throwable throwable)

Sets a throwable that will be thrown for the expected invocation.

Parameters
throwable:Throwable

the throwable to throw.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

andVoidback to summary
public IExpectationSetters<T> andVoid()

Records a call but returns nothing. Used to chain calls on void methods expectLastCall().andThrow(e).andVoid()

Returns:IExpectationSetters<T>

this object to allow method call chaining.

anyTimesback to summary
public IExpectationSetters<T> anyTimes()

Expect the last invocation any times.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

asStubback to summary
public void asStub()

Sets stub behavior for the expected invocation (this is needed for void methods).

atLeastOnceback to summary
public IExpectationSetters<T> atLeastOnce()

Expect the last invocation at least once.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

onceback to summary
public IExpectationSetters<T> once()

Expect the last invocation once. This is default in EasyMock.

Returns:IExpectationSetters<T>

this object to allow method call chaining.

timesback to summary
public IExpectationSetters<T> times(int count)

Expect the last invocation count times.

Parameters
count:int

the number of invocations expected

Returns:IExpectationSetters<T>

this object to allow method call chaining.

timesback to summary
public IExpectationSetters<T> times(int min, int max)

Expect the last invocation between min and max times.

Parameters
min:int

the minimum number of invocations expected.

max:int

the maximum number of invocations expected.

Returns:IExpectationSetters<T>

this object to allow method call chaining.