org.mockito
public class AdditionalMatchers extends Object
Matchers
for general info about matchers.
AdditionalMatchers provides rarely used matchers, kept only for somewhat compatibility with EasyMock.
Use additional matchers very judiciously because they may impact readability of a test.
It is recommended to use matchers from Matchers
and keep stubbing and verification simple.
Example of using logical and(), not(), or() matchers:
//anything but not "ejb"
mock.someMethod(not(eq("ejb")));
//not "ejb" and not "michael jackson"
mock.someMethod(and(not(eq("ejb")), not(eq("michael jackson"))));
//1 or 10
mock.someMethod(or(eq(1), eq(10)));
Scroll down to see all methods - full list of matchers.Constructor and Description |
---|
AdditionalMatchers() |
Modifier and Type | Method and Description |
---|---|
static boolean |
and(boolean first,
boolean second)
boolean argument that matches both given matchers.
|
static byte |
and(byte first,
byte second)
byte argument that matches both given argument matchers.
|
static char |
and(char first,
char second)
char argument that matches both given argument matchers.
|
static double |
and(double first,
double second)
double argument that matches both given argument matchers.
|
static float |
and(float first,
float second)
float argument that matches both given argument matchers.
|
static int |
and(int first,
int second)
int argument that matches both given argument matchers.
|
static long |
and(long first,
long second)
long argument that matches both given argument matchers.
|
static short |
and(short first,
short second)
short argument that matches both given argument matchers.
|
static <T> T |
and(T first,
T second)
Object argument that matches both given argument matchers.
|
static boolean[] |
aryEq(boolean[] value)
boolean array argument that is equal to the given array, i.e.
|
static byte[] |
aryEq(byte[] value)
byte array argument that is equal to the given array, i.e.
|
static char[] |
aryEq(char[] value)
char array argument that is equal to the given array, i.e.
|
static double[] |
aryEq(double[] value)
double array argument that is equal to the given array, i.e.
|
static float[] |
aryEq(float[] value)
float array argument that is equal to the given array, i.e.
|
static int[] |
aryEq(int[] value)
int array argument that is equal to the given array, i.e.
|
static long[] |
aryEq(long[] value)
long array argument that is equal to the given array, i.e.
|
static short[] |
aryEq(short[] value)
short array argument that is equal to the given array, i.e.
|
static <T> T[] |
aryEq(T[] value)
Object array argument that is equal to the given array, i.e.
|
static <T extends Comparable<T>> |
cmpEq(T value)
comparable argument equals to the given value according to their
compareTo method.
|
static double |
eq(double value,
double delta)
double argument that has an absolute difference to the given value that
is less than the given delta details.
|
static float |
eq(float value,
float delta)
float argument that has an absolute difference to the given value that is
less than the given delta details.
|
static String |
find(String regex)
String argument that contains a substring that matches the given regular
expression.
|
static byte |
geq(byte value)
byte argument greater than or equal to the given value.
|
static double |
geq(double value)
double argument greater than or equal to the given value.
|
static float |
geq(float value)
float argument greater than or equal to the given value.
|
static int |
geq(int value)
int argument greater than or equal to the given value.
|
static long |
geq(long value)
long argument greater than or equal to the given value.
|
static short |
geq(short value)
short argument greater than or equal to the given value.
|
static <T extends Comparable<T>> |
geq(T value)
argument greater than or equal the given value.
|
static byte |
gt(byte value)
byte argument greater than the given value.
|
static double |
gt(double value)
double argument greater than the given value.
|
static float |
gt(float value)
float argument greater than the given value.
|
static int |
gt(int value)
int argument greater than the given value.
|
static long |
gt(long value)
long argument greater than the given value.
|
static short |
gt(short value)
short argument greater than the given value.
|
static <T extends Comparable<T>> |
gt(T value)
comparable argument greater than the given value.
|
static byte |
leq(byte value)
byte argument less than or equal to the given value.
|
static double |
leq(double value)
double argument less than or equal to the given value.
|
static float |
leq(float value)
float argument less than or equal to the given value.
|
static int |
leq(int value)
int argument less than or equal to the given value.
|
static long |
leq(long value)
long argument less than or equal to the given value.
|
static short |
leq(short value)
short argument less than or equal to the given value.
|
static <T extends Comparable<T>> |
leq(T value)
comparable argument less than or equal the given value details.
|
static byte |
lt(byte value)
byte argument less than the given value.
|
static double |
lt(double value)
double argument less than the given value.
|
static float |
lt(float value)
float argument less than the given value.
|
static int |
lt(int value)
int argument less than the given value.
|
static long |
lt(long value)
long argument less than the given value.
|
static short |
lt(short value)
short argument less than the given value.
|
static <T extends Comparable<T>> |
lt(T value)
comparable argument less than the given value.
|
static boolean |
not(boolean first)
boolean argument that does not match the given argument matcher.
|
static byte |
not(byte first)
byte argument that does not match the given argument matcher.
|
static char |
not(char first)
char argument that does not match the given argument matcher.
|
static double |
not(double first)
double argument that does not match the given argument matcher.
|
static float |
not(float first)
float argument that does not match the given argument matcher.
|
static int |
not(int first)
int argument that does not match the given argument matcher.
|
static long |
not(long first)
long argument that does not match the given argument matcher.
|
static short |
not(short first)
short argument that does not match the given argument matcher.
|
static <T> T |
not(T first)
Object argument that does not match the given argument matcher.
|
static boolean |
or(boolean first,
boolean second)
boolean argument that matches any of the given argument matchers.
|
static byte |
or(byte first,
byte second)
byte argument that matches any of the given argument matchers.
|
static char |
or(char first,
char second)
char argument that matches any of the given argument matchers.
|
static double |
or(double first,
double second)
double argument that matches any of the given argument matchers.
|
static float |
or(float first,
float second)
float argument that matches any of the given argument matchers.
|
static int |
or(int first,
int second)
int argument that matches any of the given argument matchers.
|
static long |
or(long first,
long second)
long argument that matches any of the given argument matchers.
|
static short |
or(short first,
short second)
short argument that matches any of the given argument matchers.
|
static <T> T |
or(T first,
T second)
Object argument that matches any of the given argument matchers.
|
public static <T extends Comparable<T>> T geq(T value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.null
.public static byte geq(byte value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static double geq(double value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static float geq(float value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static int geq(int value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static long geq(long value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static short geq(short value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static <T extends Comparable<T>> T leq(T value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.null
.public static byte leq(byte value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static double leq(double value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static float leq(float value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static int leq(int value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static long leq(long value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static short leq(short value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static <T extends Comparable<T>> T gt(T value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.null
.public static byte gt(byte value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static double gt(double value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static float gt(float value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static int gt(int value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static long gt(long value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static short gt(short value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static <T extends Comparable<T>> T lt(T value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.null
.public static byte lt(byte value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static double lt(double value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static float lt(float value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static int lt(int value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static long lt(long value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static short lt(short value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.0
.public static <T extends Comparable<T>> T cmpEq(T value)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.null
.public static String find(String regex)
regex
- the regular expression.null
.public static <T> T[] aryEq(T[] value)
See examples in javadoc for AdditionalMatchers
class
T
- the type of the array, it is passed through to prevent casts.value
- the given array.null
.public static short[] aryEq(short[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static long[] aryEq(long[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static int[] aryEq(int[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static float[] aryEq(float[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static double[] aryEq(double[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static char[] aryEq(char[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static byte[] aryEq(byte[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static boolean[] aryEq(boolean[] value)
See examples in javadoc for AdditionalMatchers
class
value
- the given array.null
.public static boolean and(boolean first, boolean second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.false
.public static byte and(byte first, byte second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static char and(char first, char second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static double and(double first, double second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static float and(float first, float second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static int and(int first, int second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static long and(long first, long second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static short and(short first, short second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static <T> T and(T first, T second)
See examples in javadoc for AdditionalMatchers
class
T
- the type of the object, it is passed through to prevent casts.first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.null
.public static boolean or(boolean first, boolean second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.false
.public static <T> T or(T first, T second)
See examples in javadoc for AdditionalMatchers
class
T
- the type of the object, it is passed through to prevent casts.first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.null
.public static short or(short first, short second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static long or(long first, long second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static int or(int first, int second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static float or(float first, float second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static double or(double first, double second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static char or(char first, char second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static byte or(byte first, byte second)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the first argument matcher.second
- placeholder for the second argument matcher.0
.public static <T> T not(T first)
See examples in javadoc for AdditionalMatchers
class
T
- the type of the object, it is passed through to prevent casts.first
- placeholder for the argument matcher.null
.public static short not(short first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static int not(int first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static long not(long first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static float not(float first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static double not(double first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static char not(char first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static boolean not(boolean first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.false
.public static byte not(byte first)
See examples in javadoc for AdditionalMatchers
class
first
- placeholder for the argument matcher.0
.public static double eq(double value, double delta)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.delta
- the given delta.0
.public static float eq(float value, float delta)
See examples in javadoc for AdditionalMatchers
class
value
- the given value.delta
- the given delta.0
.