Package org.jmock
Class AbstractExpectations
java.lang.Object
org.jmock.AbstractExpectations
- All Implemented Interfaces:
ExpectationBuilder
,ActionClause
,ArgumentConstraintPhrases
,CardinalityClause
- Direct Known Subclasses:
Expectations
public abstract class AbstractExpectations
extends Object
implements ExpectationBuilder, CardinalityClause, ArgumentConstraintPhrases, ActionClause
Provides most of the syntax of jMock's "domain-specific language" API.
The methods of this class don't make any sense on their own, so the
Javadoc is rather sparse. Consult the documentation on the jMock
website for information on how to use this API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<InvocationExpectationBuilder> private InvocationExpectationBuilder
protected final WithClause
Syntactic sugar for specifying arguments that are matchers for primitive types or are untyped matchers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.hamcrest.Matcher
<Object> Deprecated.protected void
addParameterMatcher
(org.hamcrest.Matcher<?> matcher) allowing
(org.hamcrest.Matcher<?> mockObjectMatcher) <T> T
allowing
(T mockObject) static org.hamcrest.Matcher
<Object> Deprecated.useaNonNull(java.lang.Class<T>)
orany(java.lang.Class<T>)
until type inference actually works in a future version of Javastatic <T> org.hamcrest.Matcher
<T> static <T> org.hamcrest.Matcher
<T> static <T> org.hamcrest.Matcher
<T> static <T> org.hamcrest.Matcher
<T> anything()
atLeast
(int count) atMost
(int count) between
(int minCount, int maxCount) void
buildExpectations
(Action defaultAction, ExpectationCollector collector) private void
protected InvocationExpectationBuilder
static Action
static <T> org.hamcrest.Matcher
<T> equal
(T value) exactly
(int count) ignoring
(org.hamcrest.Matcher<?> mockObjectMatcher) <T> T
ignoring
(T mockObject) private void
initialiseExpectationCapture
(Cardinality cardinality) void
inSequence
(Sequence sequence) void
inSequences
(Sequence... sequences) <T> T
never
(T mockObject) static Action
onConsecutiveCalls
(Action... actions) <T> T
one
(T mockObject) Deprecated.UseoneOf
instead.<T> T
oneOf
(T mockObject) static Action
returnEnumeration
(Collection<?> collection) static <T> Action
returnEnumeration
(T... items) static Action
returnIterator
(Collection<?> collection) static <T> Action
returnIterator
(T... items) static Action
returnValue
(Object result) static <T> org.hamcrest.Matcher
<T> same
(T value) void
static Action
throwException
(Throwable throwable) void
when
(StatePredicate predicate) void
boolean
with
(boolean value) byte
with
(byte value) char
with
(char value) double
with
(double value) float
with
(float value) int
with
(int value) long
with
(long value) short
with
(short value) <T> T
with
(org.hamcrest.Matcher<T> matcher) For Matchers with primitive types use the with field, for example:<T> T
with
(T value)
-
Field Details
-
builders
-
currentBuilder
-
with
Syntactic sugar for specifying arguments that are matchers for primitive types or are untyped matchers.
-
-
Constructor Details
-
AbstractExpectations
public AbstractExpectations()
-
-
Method Details
-
initialiseExpectationCapture
-
buildExpectations
- Specified by:
buildExpectations
in interfaceExpectationBuilder
-
currentBuilder
-
checkLastExpectationWasFullySpecified
private void checkLastExpectationWasFullySpecified() -
exactly
- Specified by:
exactly
in interfaceCardinalityClause
-
oneOf
public <T> T oneOf(T mockObject) - Specified by:
oneOf
in interfaceCardinalityClause
-
one
public <T> T one(T mockObject) Deprecated.UseoneOf
instead.- Specified by:
one
in interfaceCardinalityClause
-
atLeast
- Specified by:
atLeast
in interfaceCardinalityClause
-
between
- Specified by:
between
in interfaceCardinalityClause
-
atMost
- Specified by:
atMost
in interfaceCardinalityClause
-
allowing
- Specified by:
allowing
in interfaceCardinalityClause
-
allowing
public <T> T allowing(T mockObject) - Specified by:
allowing
in interfaceCardinalityClause
-
ignoring
public <T> T ignoring(T mockObject) - Specified by:
ignoring
in interfaceCardinalityClause
-
ignoring
- Specified by:
ignoring
in interfaceCardinalityClause
-
never
public <T> T never(T mockObject) - Specified by:
never
in interfaceCardinalityClause
-
addParameterMatcher
protected void addParameterMatcher(org.hamcrest.Matcher<?> matcher) -
with
public <T> T with(org.hamcrest.Matcher<T> matcher) For Matchers with primitive types use the with field, for example:with.intIs(equalTo(34));
For untyped matchers use:with.<T>is(equalTo(anObject));
- Specified by:
with
in interfaceArgumentConstraintPhrases
-
with
public boolean with(boolean value) -
with
public byte with(byte value) -
with
public short with(short value) -
with
public char with(char value) -
with
public int with(int value) -
with
public long with(long value) -
with
public float with(float value) -
with
public double with(double value) -
with
public <T> T with(T value) -
will
- Specified by:
will
in interfaceActionClause
-
equal
public static <T> org.hamcrest.Matcher<T> equal(T value) -
same
public static <T> org.hamcrest.Matcher<T> same(T value) -
any
-
anything
public static <T> org.hamcrest.Matcher<T> anything() -
a
Deprecated.useaNonNull(java.lang.Class<T>)
orany(java.lang.Class<T>)
until type inference actually works in a future version of Java- Parameters:
type
- Class to match. Do not use for native parameters.- Returns:
- an IsInstanceOf matcher
-
an
Deprecated.useaNonNull(java.lang.Class<T>)
orany(java.lang.Class<T>)
until type inference actually works in a future version of Java- Parameters:
type
- Class to match. Do not use for native parameters.- Returns:
- an IsInstanceOf matcher
-
aNull
-
aNonNull
-
returnValue
-
throwException
-
returnIterator
-
returnIterator
-
returnEnumeration
-
returnEnumeration
-
doAll
-
onConsecutiveCalls
-
when
-
then
-
inSequence
-
inSequences
-
aNonNull(java.lang.Class<T>)
orany(java.lang.Class<T>)
until type inference actually works in a future version of Java