org.mockito
Class AdditionalMatchers

java.lang.Object
  extended by org.mockito.AdditionalMatchers

public class AdditionalMatchers
extends java.lang.Object

See 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 Summary
AdditionalMatchers()
           
 
Method Summary
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 java.lang.Comparable<T>>
T
cmpEq(java.lang.Comparable<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 java.lang.String find(java.lang.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
<T extends java.lang.Comparable<T>>
T
geq(java.lang.Comparable<T> value)
          argument greater than or equal 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 byte gt(byte value)
          byte argument greater than the given value.
static
<T extends java.lang.Comparable<T>>
T
gt(java.lang.Comparable<T> value)
          comparable 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 byte leq(byte value)
          byte argument less than or equal to the given value.
static
<T extends java.lang.Comparable<T>>
T
leq(java.lang.Comparable<T> value)
          comparable argument less than or equal the given value details.
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 byte lt(byte value)
          byte argument less than the given value.
static
<T extends java.lang.Comparable<T>>
T
lt(java.lang.Comparable<T> value)
          comparable 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdditionalMatchers

public AdditionalMatchers()
Method Detail

geq

public static <T extends java.lang.Comparable<T>> T geq(java.lang.Comparable<T> value)
argument greater than or equal the given value.

See examples in javadoc for AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

Parameters:
value - the given value.
Returns:
0.

leq

public static <T extends java.lang.Comparable<T>> T leq(java.lang.Comparable<T> value)
comparable argument less than or equal the given value details.

See examples in javadoc for AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

Parameters:
value - the given value.
Returns:
0.

gt

public static <T extends java.lang.Comparable<T>> T gt(java.lang.Comparable<T> value)
comparable argument greater than the given value.

See examples in javadoc for AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

Parameters:
value - the given value.
Returns:
0.

lt

public static <T extends java.lang.Comparable<T>> T lt(java.lang.Comparable<T> value)
comparable argument less than the given value.

See examples in javadoc for AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

Parameters:
value - the given value.
Returns:
0.

cmpEq

public static <T extends java.lang.Comparable<T>> T cmpEq(java.lang.Comparable<T> value)
comparable argument equals to the given value according to their compareTo method.

See examples in javadoc for AdditionalMatchers class

Parameters:
value - the given value.
Returns:
null.

find

public static java.lang.String find(java.lang.String regex)
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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

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 AdditionalMatchers class

Parameters:
value - the given value.
delta - the given delta.
Returns:
0.