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 ExpectationBuilder
protected InvocationExpectationBuilder currentBuilder()
public ReceiverClause exactly(int count)
exactly
in interface CardinalityClause
public <T> T oneOf(T mockObject)
oneOf
in interface CardinalityClause
public <T> T one(T mockObject)
oneOf
instead.one
in interface CardinalityClause
public ReceiverClause atLeast(int count)
atLeast
in interface CardinalityClause
public ReceiverClause between(int minCount, int maxCount)
between
in interface CardinalityClause
public ReceiverClause atMost(int count)
atMost
in interface CardinalityClause
public MethodClause allowing(org.hamcrest.Matcher<?> mockObjectMatcher)
allowing
in interface CardinalityClause
public <T> T allowing(T mockObject)
allowing
in interface CardinalityClause
public <T> T ignoring(T mockObject)
ignoring
in interface CardinalityClause
public MethodClause ignoring(org.hamcrest.Matcher<?> mockObjectMatcher)
ignoring
in interface CardinalityClause
public <T> T never(T mockObject)
never
in interface CardinalityClause
protected 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 ArgumentConstraintPhrases
public 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 ActionClause
public 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–2018 jMock. All rights reserved.