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 WithClausewithSyntactic 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 voidaddParameterMatcher(org.hamcrest.Matcher<?> matcher)MethodClauseallowing(org.hamcrest.Matcher<?> mockObjectMatcher)<T> Tallowing(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()ReceiverClauseatLeast(int count)ReceiverClauseatMost(int count)ReceiverClausebetween(int minCount, int maxCount)voidbuildExpectations(Action defaultAction, ExpectationCollector collector)protected InvocationExpectationBuildercurrentBuilder()static ActiondoAll(Action... actions)static <T> org.hamcrest.Matcher<T>equal(T value)ReceiverClauseexactly(int count)MethodClauseignoring(org.hamcrest.Matcher<?> mockObjectMatcher)<T> Tignoring(T mockObject)voidinSequence(Sequence sequence)voidinSequences(Sequence... sequences)<T> Tnever(T mockObject)static ActiononConsecutiveCalls(Action... actions)<T> Tone(T mockObject)Deprecated.UseoneOfinstead.<T> ToneOf(T mockObject)static ActionreturnEnumeration(Collection<?> collection)static <T> ActionreturnEnumeration(T... items)static ActionreturnIterator(Collection<?> collection)static <T> ActionreturnIterator(T... items)static ActionreturnValue(Object result)static <T> org.hamcrest.Matcher<T>same(T value)voidthen(State state)static ActionthrowException(Throwable throwable)voidwhen(StatePredicate predicate)voidwill(Action action)booleanwith(boolean value)bytewith(byte value)charwith(char value)doublewith(double value)floatwith(float value)intwith(int value)longwith(long value)shortwith(short value)<T> Twith(org.hamcrest.Matcher<T> matcher)For Matchers with primitive types use the with field, for example:<T> Twith(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:
buildExpectationsin interfaceExpectationBuilder
-
currentBuilder
protected InvocationExpectationBuilder currentBuilder()
-
exactly
public ReceiverClause exactly(int count)
- Specified by:
exactlyin interfaceCardinalityClause
-
oneOf
public <T> T oneOf(T mockObject)
- Specified by:
oneOfin interfaceCardinalityClause
-
one
public <T> T one(T mockObject)
Deprecated.UseoneOfinstead.- Specified by:
onein interfaceCardinalityClause
-
atLeast
public ReceiverClause atLeast(int count)
- Specified by:
atLeastin interfaceCardinalityClause
-
between
public ReceiverClause between(int minCount, int maxCount)
- Specified by:
betweenin interfaceCardinalityClause
-
atMost
public ReceiverClause atMost(int count)
- Specified by:
atMostin interfaceCardinalityClause
-
allowing
public MethodClause allowing(org.hamcrest.Matcher<?> mockObjectMatcher)
- Specified by:
allowingin interfaceCardinalityClause
-
allowing
public <T> T allowing(T mockObject)
- Specified by:
allowingin interfaceCardinalityClause
-
ignoring
public <T> T ignoring(T mockObject)
- Specified by:
ignoringin interfaceCardinalityClause
-
ignoring
public MethodClause ignoring(org.hamcrest.Matcher<?> mockObjectMatcher)
- Specified by:
ignoringin interfaceCardinalityClause
-
never
public <T> T never(T mockObject)
- Specified by:
neverin 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:
within 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:
willin 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)
-
-