public abstract class AbstractExpectations extends Object implements ExpectationBuilder, CardinalityClause, ArgumentConstraintPhrases, ActionClause
| Modifier and Type | Field and Description |
|---|---|
protected WithClause |
with
Syntactic sugar for specifying arguments that are matchers for primitive types
or are untyped matchers.
|
| Constructor and Description |
|---|
AbstractExpectations() |
| Modifier and Type | Method and Description |
|---|---|
static org.hamcrest.Matcher<Object> |
a(Class<?> type)
Deprecated.
use
aNonNull(java.lang.Class<T>) or any(java.lang.Class<T>) until type inference actually works in a future version of Java |
protected 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.
use
aNonNull(java.lang.Class<T>) or any(java.lang.Class<T>) until type inference actually works in a future version of Java |
static <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.
Use
oneOf 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) |
<T> T |
with(org.hamcrest.Matcher<T> matcher)
For Matchers with primitive types use the with field, for example:
|
short |
with(short value) |
<T> T |
with(T value) |
protected final WithClause with
public void buildExpectations(Action defaultAction, ExpectationCollector collector)
buildExpectations in interface ExpectationBuilderprotected InvocationExpectationBuilder currentBuilder()
public ReceiverClause exactly(int count)
exactly in interface CardinalityClausepublic <T> T oneOf(T mockObject)
oneOf in interface CardinalityClausepublic <T> T one(T mockObject)
oneOf instead.one in interface CardinalityClausepublic ReceiverClause atLeast(int count)
atLeast in interface CardinalityClausepublic ReceiverClause between(int minCount, int maxCount)
between in interface CardinalityClausepublic ReceiverClause atMost(int count)
atMost in interface CardinalityClausepublic MethodClause allowing(org.hamcrest.Matcher<?> mockObjectMatcher)
allowing in interface CardinalityClausepublic <T> T allowing(T mockObject)
allowing in interface CardinalityClausepublic <T> T ignoring(T mockObject)
ignoring in interface CardinalityClausepublic MethodClause ignoring(org.hamcrest.Matcher<?> mockObjectMatcher)
ignoring in interface CardinalityClausepublic <T> T never(T mockObject)
never in interface CardinalityClauseprotected void addParameterMatcher(org.hamcrest.Matcher<?> matcher)
public <T> T with(org.hamcrest.Matcher<T> matcher)
with.intIs(equalTo(34));For untyped matchers use:
with.<T>is(equalTo(anObject));
with in interface ArgumentConstraintPhrasespublic boolean with(boolean value)
public byte with(byte value)
public short with(short value)
public char with(char value)
public int with(int value)
public long with(long value)
public float with(float value)
public double with(double value)
public <T> T with(T value)
public void will(Action action)
will in interface ActionClausepublic static <T> org.hamcrest.Matcher<T> equal(T value)
public static <T> org.hamcrest.Matcher<T> same(T value)
public static <T> org.hamcrest.Matcher<T> any(Class<T> type)
public static <T> org.hamcrest.Matcher<T> anything()
@Deprecated public static org.hamcrest.Matcher<Object> a(Class<?> type)
aNonNull(java.lang.Class<T>) or any(java.lang.Class<T>) until type inference actually works in a future version of Javatype - Class to match. Do not use for native parameters.@Deprecated public static org.hamcrest.Matcher<Object> an(Class<?> type)
aNonNull(java.lang.Class<T>) or any(java.lang.Class<T>) until type inference actually works in a future version of Javatype - Class to match. Do not use for native parameters.public static <T> org.hamcrest.Matcher<T> aNull(Class<T> type)
public static <T> org.hamcrest.Matcher<T> aNonNull(Class<T> type)
public static Action returnIterator(Collection<?> collection)
public static <T> Action returnIterator(T... items)
public static Action returnEnumeration(Collection<?> collection)
public static <T> Action returnEnumeration(T... items)
public void when(StatePredicate predicate)
public void then(State state)
public void inSequence(Sequence sequence)
public void inSequences(Sequence... sequences)
Copyright © 2003–2022 jMock. All rights reserved.