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.- Author:
- nat
-
-
Field Summary
Fields Modifier and Type Field Description protected WithClause
with
Syntactic sugar for specifying arguments that are matchers for primitive types or are untyped matchers.
-
Constructor Summary
Constructors Constructor Description AbstractExpectations()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.hamcrest.Matcher<Object>
a(Class<?> type)
Deprecated.useaNonNull(java.lang.Class<T>)
orany(java.lang.Class<T>)
until type inference actually works in a future version of Javaprotected void
addParameterMatcher(org.hamcrest.Matcher<?> matcher)
MethodClause
allowing(org.hamcrest.Matcher<?> mockObjectMatcher)
<T> T
allowing(T mockObject)
static org.hamcrest.Matcher<Object>
an(Class<?> type)
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>
aNonNull(Class<T> type)
static <T> org.hamcrest.Matcher<T>
aNull(Class<T> type)
static <T> org.hamcrest.Matcher<T>
any(Class<T> type)
static <T> org.hamcrest.Matcher<T>
anything()
ReceiverClause
atLeast(int count)
ReceiverClause
atMost(int count)
ReceiverClause
between(int minCount, int maxCount)
void
buildExpectations(Action defaultAction, ExpectationCollector collector)
protected InvocationExpectationBuilder
currentBuilder()
static Action
doAll(Action... actions)
static <T> org.hamcrest.Matcher<T>
equal(T value)
ReceiverClause
exactly(int count)
MethodClause
ignoring(org.hamcrest.Matcher<?> mockObjectMatcher)
<T> T
ignoring(T mockObject)
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
then(State state)
static Action
throwException(Throwable throwable)
void
when(StatePredicate predicate)
void
will(Action action)
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 Detail
-
with
protected final WithClause with
Syntactic sugar for specifying arguments that are matchers for primitive types or are untyped matchers.
-
-
Method Detail
-
buildExpectations
public void buildExpectations(Action defaultAction, ExpectationCollector collector)
- Specified by:
buildExpectations
in interfaceExpectationBuilder
-
currentBuilder
protected InvocationExpectationBuilder currentBuilder()
-
exactly
public ReceiverClause exactly(int count)
- 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
public ReceiverClause atLeast(int count)
- Specified by:
atLeast
in interfaceCardinalityClause
-
between
public ReceiverClause between(int minCount, int maxCount)
- Specified by:
between
in interfaceCardinalityClause
-
atMost
public ReceiverClause atMost(int count)
- Specified by:
atMost
in interfaceCardinalityClause
-
allowing
public MethodClause allowing(org.hamcrest.Matcher<?> mockObjectMatcher)
- 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
public MethodClause ignoring(org.hamcrest.Matcher<?> mockObjectMatcher)
- 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
public void will(Action action)
- 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
public static <T> org.hamcrest.Matcher<T> any(Class<T> type)
-
anything
public static <T> org.hamcrest.Matcher<T> anything()
-
a
@Deprecated public static org.hamcrest.Matcher<Object> a(Class<?> type)
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 public static org.hamcrest.Matcher<Object> an(Class<?> type)
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
public static <T> org.hamcrest.Matcher<T> aNull(Class<T> type)
-
aNonNull
public static <T> org.hamcrest.Matcher<T> aNonNull(Class<T> type)
-
returnIterator
public static Action returnIterator(Collection<?> collection)
-
returnIterator
public static <T> Action returnIterator(T... items)
-
returnEnumeration
public static Action returnEnumeration(Collection<?> collection)
-
returnEnumeration
public static <T> Action returnEnumeration(T... items)
-
when
public void when(StatePredicate predicate)
-
then
public void then(State state)
-
inSequence
public void inSequence(Sequence sequence)
-
inSequences
public void inSequences(Sequence... sequences)
-
-