Best Easymock code snippet using org.easymock.internal.LastControl.reportMatcher
Source:EasyMock.java  
...173     * 174     * @return <code>false</code>.175     */176    public static boolean anyBoolean() {177        reportMatcher(Any.ANY);178        return false;179    }180181    /**182     * Expects any byte argument. For details, see the EasyMock documentation.183     * 184     * @return <code>0</code>.185     */186    public static byte anyByte() {187        reportMatcher(Any.ANY);188        return 0;189    }190191    /**192     * Expects any char argument. For details, see the EasyMock documentation.193     * 194     * @return <code>0</code>.195     */196    public static char anyChar() {197        reportMatcher(Any.ANY);198        return 0;199    }200201    /**202     * Expects any int argument. For details, see the EasyMock documentation.203     * 204     * @return <code>0</code>.205     */206    public static int anyInt() {207        reportMatcher(Any.ANY);208        return 0;209    }210211    /**212     * Expects any long argument. For details, see the EasyMock documentation.213     * 214     * @return <code>0</code>.215     */216    public static long anyLong() {217        reportMatcher(Any.ANY);218        return 0;219    }220221    /**222     * Expects any float argument. For details, see the EasyMock documentation.223     * 224     * @return <code>0</code>.225     */226    public static float anyFloat() {227        reportMatcher(Any.ANY);228        return 0;229    }230231    /**232     * Expects any double argument. For details, see the EasyMock documentation.233     * 234     * @return <code>0</code>.235     */236    public static double anyDouble() {237        reportMatcher(Any.ANY);238        return 0;239    }240241    /**242     * Expects any short argument. For details, see the EasyMock documentation.243     * 244     * @return <code>0</code>.245     */246    public static short anyShort() {247        reportMatcher(Any.ANY);248        return 0;249    }250251    /**252     * Expects any Object argument. For details, see the EasyMock documentation.253     * 254     * @return <code>null</code>.255     */256    public static Object anyObject() {257        reportMatcher(Any.ANY);258        return null;259    }260261    /**262     * Expects a comparable argument greater than or equal the given value. For details, see the EasyMock documentation.263     * 264     * @param value the given value.265     * @return <code>null</code>.266     */267    public static <T extends Comparable<T>> T geq(Comparable<T> value) {268        reportMatcher(new GreaterOrEqual<T>(value));269        return null;270    }271272    /**273     * Expects a byte argument greater than or equal to the given value. For details, see the EasyMock documentation.274     * 275     * @param value the given value.276     * @return <code>0</code>.277     */278    public static byte geq(byte value) {279        reportMatcher(new GreaterOrEqual<Byte>(value));280        return 0;281    }282283    /**284     * Expects a double argument greater than or equal to the given value. For details, see the EasyMock documentation.285     * 286     * @param value the given value.287     * @return <code>0</code>.288     */289    public static double geq(double value) {290        reportMatcher(new GreaterOrEqual<Double>(value));291        return 0;292    }293294    /**295     * Expects a float argument greater than or equal to the given value. For details, see the EasyMock documentation.296     * 297     * @param value the given value.298     * @return <code>0</code>.299     */300    public static float geq(float value) {301        reportMatcher(new GreaterOrEqual<Float>(value));302        return 0;303    }304305    /**306     * Expects an int argument greater than or equal to the given value. For details, see the EasyMock documentation.307     * 308     * @param value the given value.309     * @return <code>0</code>.310     */311    public static int geq(int value) {312        reportMatcher(new GreaterOrEqual<Integer>(value));313        return 0;314    }315316    /**317     * Expects a long argument greater than or equal to the given value. For details, see the EasyMock documentation.318     * 319     * @param value the given value.320     * @return <code>0</code>.321     */322    public static long geq(long value) {323        reportMatcher(new GreaterOrEqual<Long>(value));324        return 0;325    }326327    /**328     * Expects a short argument greater than or equal to the given value. For details, see the EasyMock documentation.329     * 330     * @param value the given value.331     * @return <code>0</code>.332     */333    public static short geq(short value) {334        reportMatcher(new GreaterOrEqual<Short>(value));335        return 0;336    }337338    /**339     * Expects a comparable argument less than or equal the given value. For details, see the EasyMock documentation.340     * 341     * @param value the given value.342     * @return <code>null</code>.343     */344    public static <T extends Comparable<T>> T leq(Comparable<T> value) {345        reportMatcher(new LessOrEqual<T>(value));346        return null;347    }348349    /**350     * Expects a byte argument less than or equal to the given value. For details, see the EasyMock documentation.351     * 352     * @param value the given value.353     * @return <code>0</code>.354     */355    public static byte leq(byte value) {356        reportMatcher(new LessOrEqual<Byte>(value));357        return 0;358    }359360    /**361     * Expects a double argument less than or equal to the given value. For details, see the EasyMock documentation.362     * 363     * @param value the given value.364     * @return <code>0</code>.365     */366    public static double leq(double value) {367        reportMatcher(new LessOrEqual<Double>(value));368        return 0;369    }370371    /**372     * Expects a float argument less than or equal to the given value. For details, see the EasyMock documentation.373     * 374     * @param value the given value.375     * @return <code>0</code>.376     */377    public static float leq(float value) {378        reportMatcher(new LessOrEqual<Float>(value));379        return 0;380    }381382    /**383     * Expects an int argument less than or equal to the given value. For details, see the EasyMock documentation.384     * 385     * @param value the given value.386     * @return <code>0</code>.387     */388    public static int leq(int value) {389        reportMatcher(new LessOrEqual<Integer>(value));390        return 0;391    }392393    /**394     * Expects a long argument less than or equal to the given value. For details, see the EasyMock documentation.395     * 396     * @param value the given value.397     * @return <code>0</code>.398     */399    public static long leq(long value) {400        reportMatcher(new LessOrEqual<Long>(value));401        return 0;402    }403404    /**405     * Expects a short argument less than or equal to the given value. For details, see the EasyMock documentation.406     * 407     * @param value the given value.408     * @return <code>0</code>.409     */410    public static short leq(short value) {411        reportMatcher(new LessOrEqual<Short>(value));412        return 0;413    }414415    /**416     * Expects a comparable argument greater than the given value. For details, see the EasyMock documentation.417     * 418     * @param value the given value.419     * @return <code>null</code>.420     */421    public static <T extends Comparable<T>> T gt(Comparable<T> value) {422        reportMatcher(new GreaterThan<T>(value));423        return null;424    }425426    /**427     * Expects a byte argument greater than the given value. For details, see the EasyMock documentation.428     * 429     * @param value the given value.430     * @return <code>0</code>.431     */432    public static byte gt(byte value) {433        reportMatcher(new GreaterThan<Byte>(value));434        return 0;435    }436437    /**438     * Expects a double argument greater than the given value. For details, see the EasyMock documentation.439     * 440     * @param value the given value.441     * @return <code>0</code>.442     */443    public static double gt(double value) {444        reportMatcher(new GreaterThan<Double>(value));445        return 0;446    }447448    /**449     * Expects a float argument greater than the given value. For details, see the EasyMock documentation.450     * 451     * @param value the given value.452     * @return <code>0</code>.453     */454    public static float gt(float value) {455        reportMatcher(new GreaterThan<Float>(value));456        return 0;457    }458459    /**460     * Expects an int argument greater than the given value. For details, see the EasyMock documentation.461     * 462     * @param value the given value.463     * @return <code>0</code>.464     */465    public static int gt(int value) {466        reportMatcher(new GreaterThan<Integer>(value));467        return 0;468    }469470    /**471     * Expects a long argument greater than the given value. For details, see the EasyMock documentation.472     * 473     * @param value the given value.474     * @return <code>0</code>.475     */476    public static long gt(long value) {477        reportMatcher(new GreaterThan<Long>(value));478        return 0;479    }480481    /**482     * Expects a short argument greater than the given value. For details, see the EasyMock documentation.483     * 484     * @param value the given value.485     * @return <code>0</code>.486     */487    public static short gt(short value) {488        reportMatcher(new GreaterThan<Short>(value));489        return 0;490    }491492    /**493     * Expects a comparable argument less than the given value. For details, see the EasyMock documentation.494     * 495     * @param value the given value.496     * @return <code>null</code>.497     */498    public static <T extends Comparable<T>> T lt(Comparable<T> value) {499        reportMatcher(new LessThan<T>(value));500        return null;501    }502503    /**504     * Expects a byte argument less than the given value. For details, see the EasyMock documentation.505     * 506     * @param value the given value.507     * @return <code>0</code>.508     */509    public static byte lt(byte value) {510        reportMatcher(new LessThan<Byte>(value));511        return 0;512    }513514    /**515     * Expects a double argument less than the given value. For details, see the EasyMock documentation.516     * 517     * @param value the given value.518     * @return <code>0</code>.519     */520    public static double lt(double value) {521        reportMatcher(new LessThan<Double>(value));522        return 0;523    }524525    /**526     * Expects a float argument less than the given value. For details, see the EasyMock documentation.527     * 528     * @param value the given value.529     * @return <code>0</code>.530     */531    public static float lt(float value) {532        reportMatcher(new LessThan<Float>(value));533        return 0;534    }535536    /**537     * Expects an int argument less than the given value. For details, see the EasyMock documentation.538     * 539     * @param value the given value.540     * @return <code>0</code>.541     */542    public static int lt(int value) {543        reportMatcher(new LessThan<Integer>(value));544        return 0;545    }546547    /**548     * Expects a long argument less than the given value. For details, see the EasyMock documentation.549     * 550     * @param value the given value.551     * @return <code>0</code>.552     */553    public static long lt(long value) {554        reportMatcher(new LessThan<Long>(value));555        return 0;556    }557558    /**559     * Expects a short argument less than the given value. For details, see the EasyMock documentation.560     * 561     * @param value the given value.562     * @return <code>0</code>.563     */564    public static short lt(short value) {565        reportMatcher(new LessThan<Short>(value));566        return 0;567    }568569    /**570     * Expects an object implementing the given class. For details, see the EasyMock documentation.571     * 572     * @param <T> the accepted type.573     * @param clazz the class of the accepted type.574     * @return <code>null</code>.575     */576    public static <T> T isA(Class<T> clazz) {577        reportMatcher(new InstanceOf(clazz));578        return null;579    }580581    /**582     * Expects a string that contains the given substring. For details, see the EasyMock documentation.583     * 584     * @param substring the substring.585     * @return <code>null</code>.586     */587    public static String contains(String substring) {588        reportMatcher(new Contains(substring));589        return null;590    }591592    /**593     * Expects a boolean that matches both given expectations.594     * 595     * @param first placeholder for the first expectation.596     * @param second placeholder for the second expectation.597     * @return <code>false</code>.598     */599    public static boolean and(boolean first, boolean second) {600        LastControl.reportAnd(2);601        return false;602    }603604    /**605     * Expects a byte that matches both given expectations.606     * 607     * @param first placeholder for the first expectation.608     * @param second placeholder for the second expectation.609     * @return <code>0</code>.610     */611    public static byte and(byte first, byte second) {612        LastControl.reportAnd(2);613        return 0;614    }615616    /**617     * Expects a char that matches both given expectations.618     * 619     * @param first placeholder for the first expectation.620     * @param second placeholder for the second expectation.621     * @return <code>0</code>.622     */623    public static char and(char first, char second) {624        LastControl.reportAnd(2);625        return 0;626    }627628    /**629     * Expects a double that matches both given expectations.630     * 631     * @param first placeholder for the first expectation.632     * @param second placeholder for the second expectation.633     * @return <code>0</code>.634     */635    public static double and(double first, double second) {636        LastControl.reportAnd(2);637        return 0;638    }639640    /**641     * Expects a float that matches both given expectations.642     * 643     * @param first placeholder for the first expectation.644     * @param second placeholder for the second expectation.645     * @return <code>0</code>.646     */647    public static float and(float first, float second) {648        LastControl.reportAnd(2);649        return 0;650    }651652    /**653     * Expects an int that matches both given expectations.654     * 655     * @param first placeholder for the first expectation.656     * @param second placeholder for the second expectation.657     * @return <code>0</code>.658     */659    public static int and(int first, int second) {660        LastControl.reportAnd(2);661        return 0;662    }663664    /**665     * Expects a long that matches both given expectations.666     * 667     * @param first placeholder for the first expectation.668     * @param second placeholder for the second expectation.669     * @return <code>0</code>.670     */671    public static long and(long first, long second) {672        LastControl.reportAnd(2);673        return 0;674    }675676    /**677     * Expects a short that matches both given expectations.678     * 679     * @param first placeholder for the first expectation.680     * @param second placeholder for the second expectation.681     * @return <code>0</code>.682     */683    public static short and(short first, short second) {684        LastControl.reportAnd(2);685        return 0;686    }687688    /**689     * Expects an Object that matches both given expectations.690     * 691     * @param <T> the type of the object, it is passed through to prevent casts.692     * @param first placeholder for the first expectation.693     * @param second placeholder for the second expectation.694     * @return <code>null</code>.695     */696    public static <T> T and(T first, T second) {697        LastControl.reportAnd(2);698        return null;699    }700701    /**702     * Expects a boolean that matches one of the given expectations.703     * 704     * @param first placeholder for the first expectation.705     * @param second placeholder for the second expectation.706     * @return <code>false</code>.707     */708    public static boolean or(boolean first, boolean second) {709        LastControl.reportOr(2);710        return false;711    }712713    /**714     * Expects a byte that matches one of the given expectations.715     * 716     * @param first placeholder for the first expectation.717     * @param second placeholder for the second expectation.718     * @return <code>0</code>.719     */720    public static byte or(byte first, byte second) {721        LastControl.reportOr(2);722        return 0;723    }724725    /**726     * Expects a char that matches one of the given expectations.727     * 728     * @param first placeholder for the first expectation.729     * @param second placeholder for the second expectation.730     * @return <code>0</code>.731     */732    public static char or(char first, char second) {733        LastControl.reportOr(2);734        return 0;735    }736737    /**738     * Expects a double that matches one of the given expectations.739     * 740     * @param first placeholder for the first expectation.741     * @param second placeholder for the second expectation.742     * @return <code>0</code>.743     */744    public static double or(double first, double second) {745        LastControl.reportOr(2);746        return 0;747    }748749    /**750     * Expects a float that matches one of the given expectations.751     * 752     * @param first placeholder for the first expectation.753     * @param second placeholder for the second expectation.754     * @return <code>0</code>.755     */756    public static float or(float first, float second) {757        LastControl.reportOr(2);758        return 0;759    }760761    /**762     * Expects an int that matches one of the given expectations.763     * 764     * @param first placeholder for the first expectation.765     * @param second placeholder for the second expectation.766     * @return <code>0</code>.767     */768    public static int or(int first, int second) {769        LastControl.reportOr(2);770        return first;771    }772773    /**774     * Expects a long that matches one of the given expectations.775     * 776     * @param first placeholder for the first expectation.777     * @param second placeholder for the second expectation.778     * @return <code>0</code>.779     */780    public static long or(long first, long second) {781        LastControl.reportOr(2);782        return 0;783    }784785    /**786     * Expects a short that matches one of the given expectations.787     * 788     * @param first placeholder for the first expectation.789     * @param second placeholder for the second expectation.790     * @return <code>0</code>.791     */792    public static short or(short first, short second) {793        LastControl.reportOr(2);794        return 0;795    }796797    /**798     * Expects an Object that matches one of the given expectations.799     * 800     * @param <T> the type of the object, it is passed through to prevent casts.801     * @param first placeholder for the first expectation.802     * @param second placeholder for the second expectation.803     * @return <code>null</code>.804     */805    public static <T> T or(T first, T second) {806        LastControl.reportOr(2);807        return null;808    }809810    /**811     * Expects a boolean that does not match the given expectation.812     * 813     * @param first placeholder for the expectation.814     * @return <code>false</code>.815     */816    public static boolean not(boolean first) {817        LastControl.reportNot();818        return false;819    }820821    /**822     * Expects a byte that does not match the given expectation.823     * 824     * @param first placeholder for the expectation.825     * @return <code>0</code>.826     */827    public static byte not(byte first) {828        LastControl.reportNot();829        return 0;830    }831832    /**833     * Expects a char that does not match the given expectation.834     * 835     * @param first placeholder for the expectation.836     * @return <code>0</code>.837     */838    public static char not(char first) {839        LastControl.reportNot();840        return 0;841    }842843    /**844     * Expects a double that does not match the given expectation.845     * 846     * @param first placeholder for the expectation.847     * @return <code>0</code>.848     */849    public static double not(double first) {850        LastControl.reportNot();851        return 0;852    }853854    /**855     * Expects a float that does not match the given expectation.856     * 857     * @param first placeholder for the expectation.858     * @return <code>0</code>.859     */860    public static float not(float first) {861        LastControl.reportNot();862        return first;863    }864865    /**866     * Expects an int that does not match the given expectation.867     * 868     * @param first placeholder for the expectation.869     * @return <code>0</code>.870     */871    public static int not(int first) {872        LastControl.reportNot();873        return 0;874    }875876    /**877     * Expects a long that does not match the given expectation.878     * 879     * @param first placeholder for the expectation.880     * @return <code>0</code>.881     */882    public static long not(long first) {883        LastControl.reportNot();884        return 0;885    }886887    /**888     * Expects a short that does not match the given expectation.889     * 890     * @param first placeholder for the expectation.891     * @return <code>0</code>.892     */893    public static short not(short first) {894        LastControl.reportNot();895        return 0;896    }897898    /**899     * Expects an Object that does not match the given expectation.900     * 901     * @param <T> the type of the object, it is passed through to prevent casts.902     * @param first placeholder for the expectation.903     * @return <code>null</code>.904     */905    public static <T> T not(T first) {906        LastControl.reportNot();907        return null;908    }909910    /**911     * Expects a boolean that is equal to the given value.912     * 913     * @param value the given value.914     * @return <code>0</code>.915     */916    public static boolean eq(boolean value) {917        reportMatcher(new Equals(value));918        return false;919    }920921    /**922     * Expects a byte that is equal to the given value.923     * 924     * @param value the given value.925     * @return <code>0</code>.926     */927    public static byte eq(byte value) {928        reportMatcher(new Equals(value));929        return 0;930    }931932    /**933     * Expects a char that is equal to the given value.934     * 935     * @param value the given value.936     * @return <code>0</code>.937     */938    public static char eq(char value) {939        reportMatcher(new Equals(value));940        return 0;941    }942943    /**944     * Expects a double that is equal to the given value.945     * 946     * @param value the given value.947     * @return <code>0</code>.948     */949    public static double eq(double value) {950        reportMatcher(new Equals(value));951        return 0;952    }953954    /**955     * Expects a float that is equal to the given value.956     * 957     * @param value the given value.958     * @return <code>0</code>.959     */960    public static float eq(float value) {961        reportMatcher(new Equals(value));962        return 0;963    }964965    /**966     * Expects an int that is equal to the given value.967     * 968     * @param value the given value.969     * @return <code>0</code>.970     */971    public static int eq(int value) {972        reportMatcher(new Equals(value));973        return 0;974    }975976    /**977     * Expects a long that is equal to the given value.978     * 979     * @param value the given value.980     * @return <code>0</code>.981     */982    public static long eq(long value) {983        reportMatcher(new Equals(value));984        return 0;985    }986987    /**988     * Expects a short that is equal to the given value.989     * 990     * @param value the given value.991     * @return <code>0</code>.992     */993    public static short eq(short value) {994        reportMatcher(new Equals(value));995        return 0;996    }997998    /**999     * Expects an Object that is equal to the given value.1000     * 1001     * @param value the given value.1002     * @return <code>null</code>.1003     */1004    public static <T> T eq(T value) {1005        reportMatcher(new Equals(value));1006        return null;1007    }10081009    /**1010     * Expects a boolean array that is equal to the given array, i.e. it has to have the same length, and each element1011     * has to be equal.1012     * 1013     * @param value the given arry.1014     * @return <code>null</code>.1015     */1016    public static boolean[] aryEq(boolean[] value) {1017        reportMatcher(new ArrayEquals(value));1018        return null;1019    }10201021    /**1022     * Expects a byte array that is equal to the given array, i.e. it has to have the same length, and each element has1023     * to be equal.1024     * 1025     * @param value the given arry.1026     * @return <code>null</code>.1027     */1028    public static byte[] aryEq(byte[] value) {1029        reportMatcher(new ArrayEquals(value));1030        return null;1031    }10321033    /**1034     * Expects a char array that is equal to the given array, i.e. it has to have the same length, and each element has1035     * to be equal.1036     * 1037     * @param value the given arry.1038     * @return <code>null</code>.1039     */1040    public static char[] aryEq(char[] value) {1041        reportMatcher(new ArrayEquals(value));1042        return null;1043    }10441045    /**1046     * Expects a double array that is equal to the given array, i.e. it has to have the same length, and each element1047     * has to be equal.1048     * 1049     * @param value the given arry.1050     * @return <code>null</code>.1051     */1052    public static double[] aryEq(double[] value) {1053        reportMatcher(new ArrayEquals(value));1054        return null;1055    }10561057    /**1058     * Expects a float array that is equal to the given array, i.e. it has to have the same length, and each element has1059     * to be equal.1060     * 1061     * @param value the given arry.1062     * @return <code>null</code>.1063     */1064    public static float[] aryEq(float[] value) {1065        reportMatcher(new ArrayEquals(value));1066        return null;1067    }10681069    /**1070     * Expects an int array that is equal to the given array, i.e. it has to have the same length, and each element has1071     * to be equal.1072     * 1073     * @param value the given arry.1074     * @return <code>null</code>.1075     */1076    public static int[] aryEq(int[] value) {1077        reportMatcher(new ArrayEquals(value));1078        return null;1079    }10801081    /**1082     * Expects a long array that is equal to the given array, i.e. it has to have the same length, and each element has1083     * to be equal.1084     * 1085     * @param value the given arry.1086     * @return <code>null</code>.1087     */1088    public static long[] aryEq(long[] value) {1089        reportMatcher(new ArrayEquals(value));1090        return null;1091    }10921093    /**1094     * Expects a short array that is equal to the given array, i.e. it has to have the same length, and each element has1095     * to be equal.1096     * 1097     * @param value the given arry.1098     * @return <code>null</code>.1099     */1100    public static short[] aryEq(short[] value) {1101        reportMatcher(new ArrayEquals(value));1102        return null;1103    }11041105    /**1106     * Expects an Object array that is equal to the given array, i.e. it has to have the same type, length, and each1107     * element has to be equal.1108     * 1109     * @param <T> the type of the array, it is passed through to prevent casts.1110     * @param value the given arry.1111     * @return <code>null</code>.1112     */1113    public static <T> T[] aryEq(T[] value) {1114        reportMatcher(new ArrayEquals(value));1115        return null;1116    }11171118    /**1119     * Expects null.1120     * 1121     * @return <code>null</code>.1122     */1123    public static Object isNull() {1124        reportMatcher(Null.NULL);1125        return null;1126    }11271128    /**1129     * Expects not null.1130     * 1131     * @return <code>null</code>.1132     */1133    public static Object notNull() {1134        reportMatcher(NotNull.NOT_NULL);1135        return null;1136    }11371138    /**1139     * Expects a string that contains a substring that matches the given regular expression. For details, see the1140     * EasyMock documentation.1141     * 1142     * @param regex the regular expression.1143     * @return <code>null</code>.1144     */1145    public static String find(String regex) {1146        reportMatcher(new Find(regex));1147        return null;1148    }11491150    /**1151     * Expects a string that matches the given regular expression. For details, see the EasyMock documentation.1152     * 1153     * @param regex the regular expression.1154     * @return <code>null</code>.1155     */1156    public static String matches(String regex) {1157        reportMatcher(new Matches(regex));1158        return null;1159    }11601161    /**1162     * Expects a string that starts with the given prefix. For details, see the EasyMock documentation.1163     * 1164     * @param prefix the prefix.1165     * @return <code>null</code>.1166     */1167    public static String startsWith(String prefix) {1168        reportMatcher(new StartsWith(prefix));1169        return null;1170    }11711172    /**1173     * Expects a string that ends with the given suffix. For details, see the EasyMock documentation.1174     * 1175     * @param suffix the suffix.1176     * @return <code>null</code>.1177     */1178    public static String endsWith(String suffix) {1179        reportMatcher(new EndsWith(suffix));1180        return null;1181    }11821183    /**1184     * Expects a double that has an absolute difference to the given value that is less than the given delta. For1185     * details, see the EasyMock documentation.1186     * 1187     * @param value the given value.1188     * @param delta the given delta.1189     * @return <code>0</code>.1190     */1191    public static double eq(double value, double delta) {1192        reportMatcher(new EqualsWithDelta(value, delta));1193        return 0;1194    }11951196    /**1197     * Expects a float that has an absolute difference to the given value that is less than the given delta. For1198     * details, see the EasyMock documentation.1199     * 1200     * @param value the given value.1201     * @param delta the given delta.1202     * @return <code>0</code>.1203     */1204    public static float eq(float value, float delta) {1205        reportMatcher(new EqualsWithDelta(value, delta));1206        return 0;1207    }12081209    /**1210     * Expects an Object that is the same as the given value. For details, see the EasyMock documentation.1211     * 1212     * @param <T> the type of the object, it is passed through to prevent casts.1213     * @param value the given value.1214     * @return <code>null</code>.1215     */1216    public static <T> T same(T value) {1217        reportMatcher(new Same(value));1218        return null;1219    }12201221    /**1222     * Switches the given mock objects (more exactly: the controls of the mock objects) to replay mode. For details, see1223     * the EasyMock documentation.1224     * 1225     * @param mocks the mock objects.1226     */1227    public static void replay(Object... mocks) {1228        for (Object mock : mocks) {1229            getControl(mock).replay();1230        }1231    }12321233    /**1234     * Resets the given mock objects (more exactly: the controls of the mock objects). For details, see the EasyMock1235     * documentation.1236     * 1237     * @param mocks the mock objects.1238     */1239    public static void reset(Object... mocks) {1240        for (Object mock : mocks) {1241            getControl(mock).reset();1242        }1243    }12441245    /**1246     * Verifies the given mock objects (more exactly: the controls of the mock objects).1247     * 1248     * @param mocks the mock objects.1249     */1250    public static void verify(Object... mocks) {1251        for (Object mock : mocks) {1252            getControl(mock).verify();1253        }1254    }12551256    /**1257     * Switches order checking of the given mock object (more exactly: the control of the mock object) the on and off.1258     * For details, see the EasyMock documentation.1259     * 1260     * @param mock the mock object.1261     * @param state <code>true</code> switches order checking on, <code>false</code> switches it off.1262     */1263    public static void checkOrder(Object mock, boolean state) {1264        getControl(mock).checkOrder(state);1265    }12661267    /**1268     * Reports an argument matcher. This method is needed to define own argument matchers. For details, see the EasyMock1269     * documentation.1270     * 1271     * @param matcher1272     */1273    public static void reportMatcher(IArgumentMatcher matcher) {1274        LastControl.reportMatcher(matcher);1275    }12761277    private static MocksControl getControl(Object mock) {1278        return ((ObjectMethodsFilter) Proxy.getInvocationHandler(mock)).getDelegate().getControl();1279    }12801281    /**1282     * Returns the arguments of the current mock method call, if inside an <code>IAnswer</code> callback - be careful1283     * here, reordering parameters of method changes the semantics of your tests.1284     * 1285     * @return the arguments of the current mock method call.1286     * @throws IllegalStateException if called outside of <code>IAnswer</code> callbacks.1287     */1288    public static Object[] getCurrentArguments() {1289        Object[] result = LastControl.getCurrentArguments();1290        if (result == null) {1291            throw new IllegalStateException("current arguments are only available when executing callback methods");1292        }1293        return result;1294    }12951296    /**1297     * Expects a comparable argument equals to the given value according to their compareTo method. For details, see the1298     * EasyMock documentation.1299     * 1300     * @param value the given value.1301     * @return <code>null</code>.1302     */1303    public static <T extends Comparable<T>> T cmpEq(Comparable<T> value) {1304        reportMatcher(new CompareEqual<T>(value));1305        return null;1306    }13071308    /**1309     * Expects an argument that will be compared using the provided comparator. The following comparison will take1310     * place:1311     * <p>1312     * <code>comparator.compare(actual, expected) operator 0</code>1313     * </p>1314     * For details, see the EasyMock documentation.1315     * 1316     * @param value the given value.1317     * @param comparator Comparator used to compare the actual with expected value.1318     * @param operator The comparison operator.1319     * @return <code>null</code>1320     */1321    public static <T> T cmp(T value, Comparator<T> comparator, LogicalOperator operator) {1322        reportMatcher(new Compare<T>(value, comparator, operator));1323        return null;1324    }1325}
...reportMatcher
Using AI Code Generation
1import org.easymock.EasyMock;2import org.easymock.IAnswer;3import org.easymock.internal.LastControl;4import org.junit.Test;5import java.util.Arrays;6import static org.easymock.EasyMock.*;7public class CustomMatcherTest {8    public void testCustomMatcher() {9        ICustomMatcher mock = createMock(ICustomMatcher.class);10        mock.method1(isA(String.class));11        expectLastCall().andAnswer(new IAnswer() {12            public Object answer() throws Throwable {13                LastControl control = (LastControl) EasyMock.getCurrentArguments()[0];14                control.reportMatcher(new CustomMatcher());15                return null;16            }17        });18        replay(mock);19        mock.method1("Hello");20        verify(mock);21    }22    public class CustomMatcher implements org.easymock.IArgumentMatcher {23        public boolean matches(Object argument) {24            return argument.toString().equals("Hello");25        }26        public void appendTo(StringBuffer buffer) {27            buffer.append("Custom Matcher");28        }29    }30    public interface ICustomMatcher {31        void method1(String str);32    }33}reportMatcher
Using AI Code Generation
1import org.easymock.EasyMock2import org.easymock.EasyMock.*3import org.easymock.internal.LastControl4import org.junit.Before5import org.junit.Test6class LastControlTest {7    fun setUp() {8        mock = createMock(Mock::class.java)9        lastControl = getLastControl(mock)10    }11    fun test() {12        mock.doSomething("test")13        expectLastCall().andAnswer { lastControl.reportMatcher(ArgumentMatcher()) }14        replay(mock)15        mock.doSomething("test")16    }17}18interface Mock {19    fun doSomething(arg: String)20}21class ArgumentMatcher : org.easymock.IArgumentMatcher {22    override fun matches(actual: Any?): Boolean {23    }24    override fun appendTo(buffer: StringBuffer?) {25        buffer?.append("test")26    }27}Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
