ArgumentMatchers 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 ArgumentMatchers 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.-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanand(boolean first, boolean second) boolean argument that matches both given matchers.static byteand(byte first, byte second) byte argument that matches both given argument matchers.static charand(char first, char second) char argument that matches both given argument matchers.static doubleand(double first, double second) double argument that matches both given argument matchers.static floatand(float first, float second) float argument that matches both given argument matchers.static intand(int first, int second) int argument that matches both given argument matchers.static longand(long first, long second) long argument that matches both given argument matchers.static shortand(short first, short second) short argument that matches both given argument matchers.static <T> Tand(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>>
TcmpEq(T value) comparable argument equals to the given value according to their compareTo method.static doubleeq(double value, double delta) double argument that has an absolute difference to the given value that is less than the given delta details.static floateq(float value, float delta) float argument that has an absolute difference to the given value that is less than the given delta details.static StringString argument that contains a substring that matches the given regular expression.static bytegeq(byte value) byte argument greater than or equal to the given value.static doublegeq(double value) double argument greater than or equal to the given value.static floatgeq(float value) float argument greater than or equal to the given value.static intgeq(int value) int argument greater than or equal to the given value.static longgeq(long value) long argument greater than or equal to the given value.static shortgeq(short value) short argument greater than or equal to the given value.static <T extends Comparable<T>>
Tgeq(T value) argument greater than or equal the given value.static bytegt(byte value) byte argument greater than the given value.static doublegt(double value) double argument greater than the given value.static floatgt(float value) float argument greater than the given value.static intgt(int value) int argument greater than the given value.static longgt(long value) long argument greater than the given value.static shortgt(short value) short argument greater than the given value.static <T extends Comparable<T>>
Tgt(T value) comparable argument greater than the given value.static byteleq(byte value) byte argument less than or equal to the given value.static doubleleq(double value) double argument less than or equal to the given value.static floatleq(float value) float argument less than or equal to the given value.static intleq(int value) int argument less than or equal to the given value.static longleq(long value) long argument less than or equal to the given value.static shortleq(short value) short argument less than or equal to the given value.static <T extends Comparable<T>>
Tleq(T value) comparable argument less than or equal the given value details.static bytelt(byte value) byte argument less than the given value.static doublelt(double value) double argument less than the given value.static floatlt(float value) float argument less than the given value.static intlt(int value) int argument less than the given value.static longlt(long value) long argument less than the given value.static shortlt(short value) short argument less than the given value.static <T extends Comparable<T>>
Tlt(T value) comparable argument less than the given value.static booleannot(boolean first) boolean argument that does not match the given argument matcher.static bytenot(byte first) byte argument that does not match the given argument matcher.static charnot(char first) char argument that does not match the given argument matcher.static doublenot(double first) double argument that does not match the given argument matcher.static floatnot(float first) float argument that does not match the given argument matcher.static intnot(int first) int argument that does not match the given argument matcher.static longnot(long first) long argument that does not match the given argument matcher.static shortnot(short first) short argument that does not match the given argument matcher.static <T> Tnot(T first) Object argument that does not match the given argument matcher.static booleanor(boolean first, boolean second) boolean argument that matches any of the given argument matchers.static byteor(byte first, byte second) byte argument that matches any of the given argument matchers.static charor(char first, char second) char argument that matches any of the given argument matchers.static doubleor(double first, double second) double argument that matches any of the given argument matchers.static floator(float first, float second) float argument that matches any of the given argument matchers.static intor(int first, int second) int argument that matches any of the given argument matchers.static longor(long first, long second) long argument that matches any of the given argument matchers.static shortor(short first, short second) short argument that matches any of the given argument matchers.static <T> Tor(T first, T second) Object argument that matches any of the given argument matchers.
-
Method Details
-
geq
argument greater than or equal the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
null.
-
geq
public static byte geq(byte value) byte argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
geq
public static double geq(double value) double argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
geq
public static float geq(float value) float argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
geq
public static int geq(int value) int argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
geq
public static long geq(long value) long argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
geq
public static short geq(short value) short argument greater than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
comparable argument less than or equal the given value details.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
null.
-
leq
public static byte leq(byte value) byte argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
public static double leq(double value) double argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
public static float leq(float value) float argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
public static int leq(int value) int argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
public static long leq(long value) long argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
leq
public static short leq(short value) short argument less than or equal to the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
comparable argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
null.
-
gt
public static byte gt(byte value) byte argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
public static double gt(double value) double argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
public static float gt(float value) float argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
public static int gt(int value) int argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
public static long gt(long value) long argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
gt
public static short gt(short value) short argument greater than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
comparable argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
null.
-
lt
public static byte lt(byte value) byte argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
public static double lt(double value) double argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
public static float lt(float value) float argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
public static int lt(int value) int argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
public static long lt(long value) long argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
lt
public static short lt(short value) short argument less than the given value.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
0.
-
cmpEq
comparable argument equals to the given value according to their compareTo method.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.- Returns:
null.
-
find
String argument that contains a substring that matches the given regular expression.- Parameters:
regex- the regular expression.- Returns:
null.
-
aryEq
public static <T> T[] aryEq(T[] value) Object array argument that is equal to the given array, i.e. it has to have the same type, length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Type Parameters:
T- the type of the array, it is passed through to prevent casts.- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static short[] aryEq(short[] value) short array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static long[] aryEq(long[] value) long array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static int[] aryEq(int[] value) int array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static float[] aryEq(float[] value) float array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static double[] aryEq(double[] value) double array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static char[] aryEq(char[] value) char array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static byte[] aryEq(byte[] value) byte array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
aryEq
public static boolean[] aryEq(boolean[] value) boolean array argument that is equal to the given array, i.e. it has to have the same length, and each element has to be equal.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given array.- Returns:
null.
-
and
public static boolean and(boolean first, boolean second) boolean argument that matches both given matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
false.
-
and
public static byte and(byte first, byte second) byte argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static char and(char first, char second) char argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static double and(double first, double second) double argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static float and(float first, float second) float argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static int and(int first, int second) int argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static long and(long first, long second) long argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static short and(short first, short second) short argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
and
public static <T> T and(T first, T second) Object argument that matches both given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Type Parameters:
T- the type of the object, it is passed through to prevent casts.- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
null.
-
or
public static boolean or(boolean first, boolean second) boolean argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
false.
-
or
public static <T> T or(T first, T second) Object argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Type Parameters:
T- the type of the object, it is passed through to prevent casts.- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
null.
-
or
public static short or(short first, short second) short argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static long or(long first, long second) long argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static int or(int first, int second) int argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static float or(float first, float second) float argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static double or(double first, double second) double argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static char or(char first, char second) char argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
or
public static byte or(byte first, byte second) byte argument that matches any of the given argument matchers.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the first argument matcher.second- placeholder for the second argument matcher.- Returns:
0.
-
not
public static <T> T not(T first) Object argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Type Parameters:
T- the type of the object, it is passed through to prevent casts.- Parameters:
first- placeholder for the argument matcher.- Returns:
null.
-
not
public static short not(short first) short argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static int not(int first) int argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static long not(long first) long argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static float not(float first) float argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static double not(double first) double argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static char not(char first) char argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
not
public static boolean not(boolean first) boolean argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
false.
-
not
public static byte not(byte first) byte argument that does not match the given argument matcher.See examples in javadoc for
AdditionalMatchersclass- Parameters:
first- placeholder for the argument matcher.- Returns:
0.
-
eq
public 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.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.delta- the given delta.- Returns:
0.
-
eq
public 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.See examples in javadoc for
AdditionalMatchersclass- Parameters:
value- the given value.delta- the given delta.- Returns:
0.
-