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 InvocationExpectationBuilderprotected final WithClauseSyntactic 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 voidaddParameterMatcher(org.hamcrest.Matcher<?> matcher) allowing(org.hamcrest.Matcher<?> mockObjectMatcher) <T> Tallowing(T mockObject) static org.hamcrest.Matcher<Object> Deprecated.useaNonNull(Class)orany(Class)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) voidbuildExpectations(Action defaultAction, ExpectationCollector collector) private voidprotected InvocationExpectationBuilderstatic Actionstatic <T> org.hamcrest.Matcher<T> equal(T value) exactly(int count) ignoring(org.hamcrest.Matcher<?> mockObjectMatcher) <T> Tignoring(T mockObject) private voidinitialiseExpectationCapture(Cardinality cardinality) 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) voidstatic ActionthrowException(Throwable throwable) voidwhen(StatePredicate predicate) voidbooleanwith(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 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:
buildExpectationsin interfaceExpectationBuilder
-
currentBuilder
-
checkLastExpectationWasFullySpecified
private void checkLastExpectationWasFullySpecified() -
exactly
- 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
- Specified by:
atLeastin interfaceCardinalityClause
-
between
- Specified by:
betweenin interfaceCardinalityClause
-
atMost
- Specified by:
atMostin interfaceCardinalityClause
-
allowing
- 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
- 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
- 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
-
anything
public static <T> org.hamcrest.Matcher<T> anything() -
a
Deprecated.useaNonNull(Class)orany(Class)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(Class)orany(Class)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(Class)orany(Class)until type inference actually works in a future version of Java