How to use reportMatcher method of org.easymock.EasyMock class

Best Easymock code snippet using org.easymock.EasyMock.reportMatcher

Source:EasyMock.java Github

copy

Full Screen

...210 *211 * @return <code>false</code>.212 */213 public static boolean anyBoolean() {214 reportMatcher(Any.ANY);215 return false;216 }217218 /**219 * Expects any byte argument. For details, see the EasyMock documentation.220 *221 * @return <code>0</code>.222 */223 public static byte anyByte() {224 reportMatcher(Any.ANY);225 return 0;226 }227228 /**229 * Expects any char argument. For details, see the EasyMock documentation.230 *231 * @return <code>0</code>.232 */233 public static char anyChar() {234 reportMatcher(Any.ANY);235 return 0;236 }237238 /**239 * Expects any int argument. For details, see the EasyMock documentation.240 *241 * @return <code>0</code>.242 */243 public static int anyInt() {244 reportMatcher(Any.ANY);245 return 0;246 }247248 /**249 * Expects any long argument. For details, see the EasyMock documentation.250 *251 * @return <code>0</code>.252 */253 public static long anyLong() {254 reportMatcher(Any.ANY);255 return 0;256 }257258 /**259 * Expects any float argument. For details, see the EasyMock documentation.260 *261 * @return <code>0</code>.262 */263 public static float anyFloat() {264 reportMatcher(Any.ANY);265 return 0;266 }267268 /**269 * Expects any double argument. For details, see the EasyMock documentation.270 *271 * @return <code>0</code>.272 */273 public static double anyDouble() {274 reportMatcher(Any.ANY);275 return 0;276 }277278 /**279 * Expects any short argument. For details, see the EasyMock documentation.280 *281 * @return <code>0</code>.282 */283 public static short anyShort() {284 reportMatcher(Any.ANY);285 return 0;286 }287288 /**289 * Expects any Object argument. For details, see the EasyMock documentation.290 *291 * @param <T> type of the method argument to match292 * @return <code>null</code>.293 */294 public static <T> T anyObject() {295 reportMatcher(Any.ANY);296 return null;297 }298299 /**300 * Expects a comparable argument greater than or equal the given value. For details, see301 * the EasyMock documentation.302 *303 * @param <T> type of the method argument to match304 * @param value305 * the given value.306 * @return <code>null</code>.307 */308 public static <T extends Comparable<T>> T geq(Comparable<T> value) {309 reportMatcher(new GreaterOrEqual<T>(value));310 return null;311 }312313 /**314 * Expects a byte argument greater than or equal to the given value. For315 * details, see the EasyMock documentation.316 *317 * @param value318 * the given value.319 * @return <code>0</code>.320 */321 public static byte geq(byte value) {322 reportMatcher(new GreaterOrEqual<Byte>(value));323 return 0;324 }325326 /**327 * Expects a double argument greater than or equal to the given value. For328 * details, see the EasyMock documentation.329 *330 * @param value331 * the given value.332 * @return <code>0</code>.333 */334 public static double geq(double value) {335 reportMatcher(new GreaterOrEqual<Double>(value));336 return 0;337 }338339 /**340 * Expects a float argument greater than or equal to the given value. For341 * details, see the EasyMock documentation.342 *343 * @param value344 * the given value.345 * @return <code>0</code>.346 */347 public static float geq(float value) {348 reportMatcher(new GreaterOrEqual<Float>(value));349 return 0;350 }351352 /**353 * Expects an int argument greater than or equal to the given value. For354 * details, see the EasyMock documentation.355 *356 * @param value357 * the given value.358 * @return <code>0</code>.359 */360 public static int geq(int value) {361 reportMatcher(new GreaterOrEqual<Integer>(value));362 return 0;363 }364365 /**366 * Expects a long argument greater than or equal to the given value. For367 * details, see the EasyMock documentation.368 *369 * @param value370 * the given value.371 * @return <code>0</code>.372 */373 public static long geq(long value) {374 reportMatcher(new GreaterOrEqual<Long>(value));375 return 0;376 }377378 /**379 * Expects a short argument greater than or equal to the given value. For380 * details, see the EasyMock documentation.381 *382 * @param value383 * the given value.384 * @return <code>0</code>.385 */386 public static short geq(short value) {387 reportMatcher(new GreaterOrEqual<Short>(value));388 return 0;389 }390391 /**392 * Expects a comparable argument less than or equal the given value. For details, see393 * the EasyMock documentation.394 *395 * @param <T> type of the method argument to match396 * @param value397 * the given value.398 * @return <code>null</code>.399 */400 public static <T extends Comparable<T>> T leq(Comparable<T> value) {401 reportMatcher(new LessOrEqual<T>(value));402 return null;403 }404405 /**406 * Expects a byte argument less than or equal to the given value. For407 * details, see the EasyMock documentation.408 *409 * @param value410 * the given value.411 * @return <code>0</code>.412 */413 public static byte leq(byte value) {414 reportMatcher(new LessOrEqual<Byte>(value));415 return 0;416 }417418 /**419 * Expects a double argument less than or equal to the given value. For420 * details, see the EasyMock documentation.421 *422 * @param value423 * the given value.424 * @return <code>0</code>.425 */426 public static double leq(double value) {427 reportMatcher(new LessOrEqual<Double>(value));428 return 0;429 }430431 /**432 * Expects a float argument less than or equal to the given value. For433 * details, see the EasyMock documentation.434 *435 * @param value436 * the given value.437 * @return <code>0</code>.438 */439 public static float leq(float value) {440 reportMatcher(new LessOrEqual<Float>(value));441 return 0;442 }443444 /**445 * Expects an int argument less than or equal to the given value. For446 * details, see the EasyMock documentation.447 *448 * @param value449 * the given value.450 * @return <code>0</code>.451 */452 public static int leq(int value) {453 reportMatcher(new LessOrEqual<Integer>(value));454 return 0;455 }456457 /**458 * Expects a long argument less than or equal to the given value. For459 * details, see the EasyMock documentation.460 *461 * @param value462 * the given value.463 * @return <code>0</code>.464 */465 public static long leq(long value) {466 reportMatcher(new LessOrEqual<Long>(value));467 return 0;468 }469470 /**471 * Expects a short argument less than or equal to the given value. For472 * details, see the EasyMock documentation.473 *474 * @param value475 * the given value.476 * @return <code>0</code>.477 */478 public static short leq(short value) {479 reportMatcher(new LessOrEqual<Short>(value));480 return 0;481 }482483 /**484 * Expects a comparable argument greater than the given value. For details, see485 * the EasyMock documentation.486 *487 * @param <T> type of the method argument to match488 * @param value489 * the given value.490 * @return <code>null</code>.491 */492 public static <T extends Comparable<T>> T gt(Comparable<T> value) {493 reportMatcher(new GreaterThan<T>(value));494 return null;495 }496497 /**498 * Expects a byte argument greater than the given value. For details, see499 * the EasyMock documentation.500 *501 * @param value502 * the given value.503 * @return <code>0</code>.504 */505 public static byte gt(byte value) {506 reportMatcher(new GreaterThan<Byte>(value));507 return 0;508 }509510 /**511 * Expects a double argument greater than the given value. For details, see512 * the EasyMock documentation.513 *514 * @param value515 * the given value.516 * @return <code>0</code>.517 */518 public static double gt(double value) {519 reportMatcher(new GreaterThan<Double>(value));520 return 0;521 }522523 /**524 * Expects a float argument greater than the given value. For details, see525 * the EasyMock documentation.526 *527 * @param value528 * the given value.529 * @return <code>0</code>.530 */531 public static float gt(float value) {532 reportMatcher(new GreaterThan<Float>(value));533 return 0;534 }535536 /**537 * Expects an int argument greater than the given value. For details, see538 * the EasyMock documentation.539 *540 * @param value541 * the given value.542 * @return <code>0</code>.543 */544 public static int gt(int value) {545 reportMatcher(new GreaterThan<Integer>(value));546 return 0;547 }548549 /**550 * Expects a long argument greater than the given value. For details, see551 * the EasyMock documentation.552 *553 * @param value554 * the given value.555 * @return <code>0</code>.556 */557 public static long gt(long value) {558 reportMatcher(new GreaterThan<Long>(value));559 return 0;560 }561562 /**563 * Expects a short argument greater than the given value. For details, see564 * the EasyMock documentation.565 *566 * @param value567 * the given value.568 * @return <code>0</code>.569 */570 public static short gt(short value) {571 reportMatcher(new GreaterThan<Short>(value));572 return 0;573 }574575 /**576 * Expects a comparable argument less than the given value. For details, see577 * the EasyMock documentation.578 *579 * @param <T> type of the method argument to match580 * @param value581 * the given value.582 * @return <code>null</code>.583 */584 public static <T extends Comparable<T>> T lt(Comparable<T> value) {585 reportMatcher(new LessThan<T>(value));586 return null;587 }588589 /**590 * Expects a byte argument less than the given value. For details, see the591 * EasyMock documentation.592 *593 * @param value594 * the given value.595 * @return <code>0</code>.596 */597 public static byte lt(byte value) {598 reportMatcher(new LessThan<Byte>(value));599 return 0;600 }601602 /**603 * Expects a double argument less than the given value. For details, see the604 * EasyMock documentation.605 *606 * @param value607 * the given value.608 * @return <code>0</code>.609 */610 public static double lt(double value) {611 reportMatcher(new LessThan<Double>(value));612 return 0;613 }614615 /**616 * Expects a float argument less than the given value. For details, see the617 * EasyMock documentation.618 *619 * @param value620 * the given value.621 * @return <code>0</code>.622 */623 public static float lt(float value) {624 reportMatcher(new LessThan<Float>(value));625 return 0;626 }627628 /**629 * Expects an int argument less than the given value. For details, see the630 * EasyMock documentation.631 *632 * @param value633 * the given value.634 * @return <code>0</code>.635 */636 public static int lt(int value) {637 reportMatcher(new LessThan<Integer>(value));638 return 0;639 }640641 /**642 * Expects a long argument less than the given value. For details, see the643 * EasyMock documentation.644 *645 * @param value646 * the given value.647 * @return <code>0</code>.648 */649 public static long lt(long value) {650 reportMatcher(new LessThan<Long>(value));651 return 0;652 }653654 /**655 * Expects a short argument less than the given value. For details, see the656 * EasyMock documentation.657 *658 * @param value659 * the given value.660 * @return <code>0</code>.661 */662 public static short lt(short value) {663 reportMatcher(new LessThan<Short>(value));664 return 0;665 }666667 /**668 * Expects an object implementing the given class. For details, see the669 * EasyMock documentation.670 *671 * @param <T>672 * the accepted type.673 * @param clazz674 * the class of the accepted type.675 * @return <code>null</code>.676 */677 public static <T> T isA(Class<T> clazz) {678 reportMatcher(new InstanceOf(clazz));679 return null;680 }681682 /**683 * Expects a string that contains the given substring. For details, see the684 * EasyMock documentation.685 *686 * @param substring687 * the substring.688 * @return <code>null</code>.689 */690 public static String contains(String substring) {691 reportMatcher(new Contains(substring));692 return null;693 }694695 /**696 * Expects a boolean that matches both given expectations.697 *698 * @param first699 * placeholder for the first expectation.700 * @param second701 * placeholder for the second expectation.702 * @return <code>false</code>.703 */704 public static boolean and(boolean first, boolean second) {705 LastControl.reportAnd(2);706 return false;707 }708709 /**710 * Expects a byte that matches both given expectations.711 *712 * @param first713 * placeholder for the first expectation.714 * @param second715 * placeholder for the second expectation.716 * @return <code>0</code>.717 */718 public static byte and(byte first, byte second) {719 LastControl.reportAnd(2);720 return 0;721 }722723 /**724 * Expects a char that matches both given expectations.725 *726 * @param first727 * placeholder for the first expectation.728 * @param second729 * placeholder for the second expectation.730 * @return <code>0</code>.731 */732 public static char and(char first, char second) {733 LastControl.reportAnd(2);734 return 0;735 }736737 /**738 * Expects a double that matches both given expectations.739 *740 * @param first741 * placeholder for the first expectation.742 * @param second743 * placeholder for the second expectation.744 * @return <code>0</code>.745 */746 public static double and(double first, double second) {747 LastControl.reportAnd(2);748 return 0;749 }750751 /**752 * Expects a float that matches both given expectations.753 *754 * @param first755 * placeholder for the first expectation.756 * @param second757 * placeholder for the second expectation.758 * @return <code>0</code>.759 */760 public static float and(float first, float second) {761 LastControl.reportAnd(2);762 return 0;763 }764765 /**766 * Expects an int that matches both given expectations.767 *768 * @param first769 * placeholder for the first expectation.770 * @param second771 * placeholder for the second expectation.772 * @return <code>0</code>.773 */774 public static int and(int first, int second) {775 LastControl.reportAnd(2);776 return 0;777 }778779 /**780 * Expects a long that matches both given expectations.781 *782 * @param first783 * placeholder for the first expectation.784 * @param second785 * placeholder for the second expectation.786 * @return <code>0</code>.787 */788 public static long and(long first, long second) {789 LastControl.reportAnd(2);790 return 0;791 }792793 /**794 * Expects a short that matches both given expectations.795 *796 * @param first797 * placeholder for the first expectation.798 * @param second799 * placeholder for the second expectation.800 * @return <code>0</code>.801 */802 public static short and(short first, short second) {803 LastControl.reportAnd(2);804 return 0;805 }806807 /**808 * Expects an Object that matches both given expectations.809 *810 * @param <T>811 * the type of the object, it is passed through to prevent casts.812 * @param first813 * placeholder for the first expectation.814 * @param second815 * placeholder for the second expectation.816 * @return <code>null</code>.817 */818 public static <T> T and(T first, T second) {819 LastControl.reportAnd(2);820 return null;821 }822823 /**824 * Expects a boolean that matches one of the given expectations.825 *826 * @param first827 * placeholder for the first expectation.828 * @param second829 * placeholder for the second expectation.830 * @return <code>false</code>.831 */832 public static boolean or(boolean first, boolean second) {833 LastControl.reportOr(2);834 return false;835 }836837 /**838 * Expects a byte that matches one of the given expectations.839 *840 * @param first841 * placeholder for the first expectation.842 * @param second843 * placeholder for the second expectation.844 * @return <code>0</code>.845 */846 public static byte or(byte first, byte second) {847 LastControl.reportOr(2);848 return 0;849 }850851 /**852 * Expects a char that matches one of the given expectations.853 *854 * @param first855 * placeholder for the first expectation.856 * @param second857 * placeholder for the second expectation.858 * @return <code>0</code>.859 */860 public static char or(char first, char second) {861 LastControl.reportOr(2);862 return 0;863 }864865 /**866 * Expects a double that matches one of the given expectations.867 *868 * @param first869 * placeholder for the first expectation.870 * @param second871 * placeholder for the second expectation.872 * @return <code>0</code>.873 */874 public static double or(double first, double second) {875 LastControl.reportOr(2);876 return 0;877 }878879 /**880 * Expects a float that matches one of the given expectations.881 *882 * @param first883 * placeholder for the first expectation.884 * @param second885 * placeholder for the second expectation.886 * @return <code>0</code>.887 */888 public static float or(float first, float second) {889 LastControl.reportOr(2);890 return 0;891 }892893 /**894 * Expects an int that matches one of the given expectations.895 *896 * @param first897 * placeholder for the first expectation.898 * @param second899 * placeholder for the second expectation.900 * @return <code>0</code>.901 */902 public static int or(int first, int second) {903 LastControl.reportOr(2);904 return first;905 }906907 /**908 * Expects a long that matches one of the given expectations.909 *910 * @param first911 * placeholder for the first expectation.912 * @param second913 * placeholder for the second expectation.914 * @return <code>0</code>.915 */916 public static long or(long first, long second) {917 LastControl.reportOr(2);918 return 0;919 }920921 /**922 * Expects a short that matches one of the given expectations.923 *924 * @param first925 * placeholder for the first expectation.926 * @param second927 * placeholder for the second expectation.928 * @return <code>0</code>.929 */930 public static short or(short first, short second) {931 LastControl.reportOr(2);932 return 0;933 }934935 /**936 * Expects an Object that matches one of the given expectations.937 *938 * @param <T>939 * the type of the object, it is passed through to prevent casts.940 * @param first941 * placeholder for the first expectation.942 * @param second943 * placeholder for the second expectation.944 * @return <code>null</code>.945 */946 public static <T> T or(T first, T second) {947 LastControl.reportOr(2);948 return null;949 }950951 /**952 * Expects a boolean that does not match the given expectation.953 *954 * @param first955 * placeholder for the expectation.956 * @return <code>false</code>.957 */958 public static boolean not(boolean first) {959 LastControl.reportNot();960 return false;961 }962963 /**964 * Expects a byte that does not match the given expectation.965 *966 * @param first967 * placeholder for the expectation.968 * @return <code>0</code>.969 */970 public static byte not(byte first) {971 LastControl.reportNot();972 return 0;973 }974975 /**976 * Expects a char that does not match the given expectation.977 *978 * @param first979 * placeholder for the expectation.980 * @return <code>0</code>.981 */982 public static char not(char first) {983 LastControl.reportNot();984 return 0;985 }986987 /**988 * Expects a double that does not match the given expectation.989 *990 * @param first991 * placeholder for the expectation.992 * @return <code>0</code>.993 */994 public static double not(double first) {995 LastControl.reportNot();996 return 0;997 }998999 /**1000 * Expects a float that does not match the given expectation.1001 *1002 * @param first1003 * placeholder for the expectation.1004 * @return <code>0</code>.1005 */1006 public static float not(float first) {1007 LastControl.reportNot();1008 return first;1009 }10101011 /**1012 * Expects an int that does not match the given expectation.1013 *1014 * @param first1015 * placeholder for the expectation.1016 * @return <code>0</code>.1017 */1018 public static int not(int first) {1019 LastControl.reportNot();1020 return 0;1021 }10221023 /**1024 * Expects a long that does not match the given expectation.1025 *1026 * @param first1027 * placeholder for the expectation.1028 * @return <code>0</code>.1029 */1030 public static long not(long first) {1031 LastControl.reportNot();1032 return 0;1033 }10341035 /**1036 * Expects a short that does not match the given expectation.1037 *1038 * @param first1039 * placeholder for the expectation.1040 * @return <code>0</code>.1041 */1042 public static short not(short first) {1043 LastControl.reportNot();1044 return 0;1045 }10461047 /**1048 * Expects an Object that does not match the given expectation.1049 *1050 * @param <T>1051 * the type of the object, it is passed through to prevent casts.1052 * @param first1053 * placeholder for the expectation.1054 * @return <code>null</code>.1055 */1056 public static <T> T not(T first) {1057 LastControl.reportNot();1058 return null;1059 }10601061 /**1062 * Expects a boolean that is equal to the given value.1063 *1064 * @param value1065 * the given value.1066 * @return <code>0</code>.1067 */1068 public static boolean eq(boolean value) {1069 reportMatcher(new Equals(value));1070 return false;1071 }10721073 /**1074 * Expects a byte that is equal to the given value.1075 *1076 * @param value1077 * the given value.1078 * @return <code>0</code>.1079 */1080 public static byte eq(byte value) {1081 reportMatcher(new Equals(value));1082 return 0;1083 }10841085 /**1086 * Expects a char that is equal to the given value.1087 *1088 * @param value1089 * the given value.1090 * @return <code>0</code>.1091 */1092 public static char eq(char value) {1093 reportMatcher(new Equals(value));1094 return 0;1095 }10961097 /**1098 * Expects a double that is equal to the given value.1099 *1100 * @param value1101 * the given value.1102 * @return <code>0</code>.1103 */1104 public static double eq(double value) {1105 reportMatcher(new Equals(value));1106 return 0;1107 }11081109 /**1110 * Expects a float that is equal to the given value.1111 *1112 * @param value1113 * the given value.1114 * @return <code>0</code>.1115 */1116 public static float eq(float value) {1117 reportMatcher(new Equals(value));1118 return 0;1119 }11201121 /**1122 * Expects an int that is equal to the given value.1123 *1124 * @param value1125 * the given value.1126 * @return <code>0</code>.1127 */1128 public static int eq(int value) {1129 reportMatcher(new Equals(value));1130 return 0;1131 }11321133 /**1134 * Expects a long that is equal to the given value.1135 *1136 * @param value1137 * the given value.1138 * @return <code>0</code>.1139 */1140 public static long eq(long value) {1141 reportMatcher(new Equals(value));1142 return 0;1143 }11441145 /**1146 * Expects a short that is equal to the given value.1147 *1148 * @param value1149 * the given value.1150 * @return <code>0</code>.1151 */1152 public static short eq(short value) {1153 reportMatcher(new Equals(value));1154 return 0;1155 }11561157 /**1158 * Expects an Object that is equal to the given value.1159 *1160 * @param <T> type of the method argument to match1161 * @param value1162 * the given value.1163 * @return <code>null</code>.1164 */1165 public static <T> T eq(T value) {1166 reportMatcher(new Equals(value));1167 return null;1168 }11691170 /**1171 * Expects a boolean array that is equal to the given array, i.e. it has to1172 * have the same length, and each element has to be equal.1173 *1174 * @param value1175 * the given arry.1176 * @return <code>null</code>.1177 */1178 public static boolean[] aryEq(boolean[] value) {1179 reportMatcher(new ArrayEquals(value));1180 return null;1181 }11821183 /**1184 * Expects a byte array that is equal to the given array, i.e. it has to1185 * have the same length, and each element has to be equal.1186 *1187 * @param value1188 * the given arry.1189 * @return <code>null</code>.1190 */1191 public static byte[] aryEq(byte[] value) {1192 reportMatcher(new ArrayEquals(value));1193 return null;1194 }11951196 /**1197 * Expects a char array that is equal to the given array, i.e. it has to1198 * have the same length, and each element has to be equal.1199 *1200 * @param value1201 * the given arry.1202 * @return <code>null</code>.1203 */1204 public static char[] aryEq(char[] value) {1205 reportMatcher(new ArrayEquals(value));1206 return null;1207 }12081209 /**1210 * Expects a double array that is equal to the given array, i.e. it has to1211 * have the same length, and each element has to be equal.1212 *1213 * @param value1214 * the given arry.1215 * @return <code>null</code>.1216 */1217 public static double[] aryEq(double[] value) {1218 reportMatcher(new ArrayEquals(value));1219 return null;1220 }12211222 /**1223 * Expects a float array that is equal to the given array, i.e. it has to1224 * have the same length, and each element has to be equal.1225 *1226 * @param value1227 * the given arry.1228 * @return <code>null</code>.1229 */1230 public static float[] aryEq(float[] value) {1231 reportMatcher(new ArrayEquals(value));1232 return null;1233 }12341235 /**1236 * Expects an int array that is equal to the given array, i.e. it has to1237 * have the same length, and each element has to be equal.1238 *1239 * @param value1240 * the given arry.1241 * @return <code>null</code>.1242 */1243 public static int[] aryEq(int[] value) {1244 reportMatcher(new ArrayEquals(value));1245 return null;1246 }12471248 /**1249 * Expects a long array that is equal to the given array, i.e. it has to1250 * have the same length, and each element has to be equal.1251 *1252 * @param value1253 * the given arry.1254 * @return <code>null</code>.1255 */1256 public static long[] aryEq(long[] value) {1257 reportMatcher(new ArrayEquals(value));1258 return null;1259 }12601261 /**1262 * Expects a short array that is equal to the given array, i.e. it has to1263 * have the same length, and each element has to be equal.1264 *1265 * @param value1266 * the given arry.1267 * @return <code>null</code>.1268 */1269 public static short[] aryEq(short[] value) {1270 reportMatcher(new ArrayEquals(value));1271 return null;1272 }12731274 /**1275 * Expects an Object array that is equal to the given array, i.e. it has to1276 * have the same type, length, and each element has to be equal.1277 *1278 * @param <T>1279 * the type of the array, it is passed through to prevent casts.1280 * @param value1281 * the given arry.1282 * @return <code>null</code>.1283 */1284 public static <T> T[] aryEq(T[] value) {1285 reportMatcher(new ArrayEquals(value));1286 return null;1287 }12881289 /**1290 * Expects null.1291 *1292 * @param <T> type of the method argument to match1293 * @return <code>null</code>.1294 */1295 public static <T> T isNull() {1296 reportMatcher(Null.NULL);1297 return null;1298 }12991300 /**1301 * Expects not null.1302 *1303 * @param <T> type of the method argument to match1304 * @return <code>null</code>.1305 */1306 public static <T> T notNull() {1307 reportMatcher(NotNull.NOT_NULL);1308 return null;1309 }13101311 /**1312 * Expects a string that contains a substring that matches the given regular1313 * expression. For details, see the EasyMock documentation.1314 *1315 * @param regex1316 * the regular expression.1317 * @return <code>null</code>.1318 */1319 public static String find(String regex) {1320 reportMatcher(new Find(regex));1321 return null;1322 }13231324 /**1325 * Expects a string that matches the given regular expression. For details,1326 * see the EasyMock documentation.1327 *1328 * @param regex1329 * the regular expression.1330 * @return <code>null</code>.1331 */1332 public static String matches(String regex) {1333 reportMatcher(new Matches(regex));1334 return null;1335 }13361337 /**1338 * Expects a string that starts with the given prefix. For details, see the1339 * EasyMock documentation.1340 *1341 * @param prefix1342 * the prefix.1343 * @return <code>null</code>.1344 */1345 public static String startsWith(String prefix) {1346 reportMatcher(new StartsWith(prefix));1347 return null;1348 }13491350 /**1351 * Expects a string that ends with the given suffix. For details, see the1352 * EasyMock documentation.1353 *1354 * @param suffix1355 * the suffix.1356 * @return <code>null</code>.1357 */1358 public static String endsWith(String suffix) {1359 reportMatcher(new EndsWith(suffix));1360 return null;1361 }13621363 /**1364 * Expects a double that has an absolute difference to the given value that1365 * is less than the given delta. For details, see the EasyMock1366 * documentation.1367 *1368 * @param value1369 * the given value.1370 * @param delta1371 * the given delta.1372 * @return <code>0</code>.1373 */1374 public static double eq(double value, double delta) {1375 reportMatcher(new EqualsWithDelta(value, delta));1376 return 0;1377 }13781379 /**1380 * Expects a float that has an absolute difference to the given value that1381 * is less than the given delta. For details, see the EasyMock1382 * documentation.1383 *1384 * @param value1385 * the given value.1386 * @param delta1387 * the given delta.1388 * @return <code>0</code>.1389 */1390 public static float eq(float value, float delta) {1391 reportMatcher(new EqualsWithDelta(value, delta));1392 return 0;1393 }13941395 /**1396 * Expects an Object that is the same as the given value. For details, see1397 * the EasyMock documentation.1398 *1399 * @param <T>1400 * the type of the object, it is passed through to prevent casts.1401 * @param value1402 * the given value.1403 * @return <code>null</code>.1404 */1405 public static <T> T same(T value) {1406 reportMatcher(new Same(value));1407 return null;1408 }14091410 /**1411 * Expects a comparable argument equals to the given value according to their1412 * compareTo method. For details, see the EasMock documentation.1413 *1414 * @param <T> type of the method argument to match1415 * @param value1416 * the given value.1417 * @return <code>null</code>.1418 */1419 public static <T extends Comparable<T>> T cmpEq(Comparable<T> value) {1420 reportMatcher(new CompareEqual<T>(value));1421 return null;1422 }14231424 /**1425 * Expects an argument that will be compared using the provided comparator.1426 * The following comparison will take place:1427 * <p>1428 * <code>comparator.compare(actual, expected) operator 0</code>1429 * </p>1430 * For details, see the EasyMock documentation.1431 *1432 * @param <T> type of the method argument to match1433 * @param value the given value.1434 * @param comparator Comparator used to compare the actual with expected value.1435 * @param operator The comparison operator.1436 * @return <code>null</code>1437 */1438 public static <T> T cmp(T value, Comparator<? super T> comparator, LogicalOperator operator) {1439 reportMatcher(new Compare<T>(value, comparator, operator));1440 return null;1441 }144214431444 /**1445 * Expects a byte that is equal to the given value.1446 *1447 * @param value1448 * the given value.1449 * @return <code>0</code>.1450 */145114521453 /**1454 * Expect any object but captures it for later use.1455 *1456 * @param <T> Type of the captured object1457 * @param captured Where the parameter is captured1458 * @return <code>null</code>1459 */1460 public static <T> T capture(Capture<T> captured) {1461 reportMatcher(new Captures<T>(captured));1462 return null;1463 }14641465 /******************************************************1466 * ANDROID CHANGE - comment out to fix compile error1467 * name clash: capture(org.easymock.Capture<java.lang.Long>) and1468 * <T>capture(org.easymock.Capture<T>) have the same erasure1469 */1470 /**1471 * Expect any int but captures it for later use.1472 *1473 * @param captured Where the parameter is captured1474 * @return <code>0</code>1475 */1476// public static int capture(Capture<Integer> captured) {1477// reportMatcher(new Captures<Integer>(captured));1478// return 0;1479// }14801481 /**1482 * Expect any long but captures it for later use.1483 *1484 * @param captured Where the parameter is captured1485 * @return <code>0</code>1486 */1487// public static long capture(Capture<Long> captured) {1488// reportMatcher(new Captures<Long>(captured));1489// return 0;1490// }14911492 /**1493 * Expect any float but captures it for later use.1494 *1495 * @param captured Where the parameter is captured1496 * @return <code>0</code>1497 */1498// public static float capture(Capture<Float> captured) {1499// reportMatcher(new Captures<Float>(captured));1500// return 0;1501// }15021503 /**1504 * Expect any double but captures it for later use.1505 *1506 * @param captured Where the parameter is captured1507 * @return <code>0</code>1508 */1509// public static double capture(Capture<Double> captured) {1510// reportMatcher(new Captures<Double>(captured));1511// return 0;1512// }15131514 /**1515 * Expect any byte but captures it for later use.1516 *1517 * @param captured Where the parameter is captured1518 * @return <code>0</code>1519 */1520// public static byte capture(Capture<Byte> captured) {1521// reportMatcher(new Captures<Byte>(captured));1522// return 0;1523// }15241525 /**1526 * Expect any char but captures it for later use.1527 *1528 * @param captured Where the parameter is captured1529 * @return <code>0</code>1530 */1531// public static char capture(Capture<Character> captured) {1532// reportMatcher(new Captures<Character>(captured));1533// return 0;1534// }15351536 /********** END ANDROID CHANGE **********/15371538 /**1539 * Switches the given mock objects (more exactly: the controls of the mock1540 * objects) to replay mode. For details, see the EasyMock documentation.1541 *1542 * @param mocks1543 * the mock objects.1544 */1545 public static void replay(Object... mocks) {1546 for (Object mock : mocks) {1547 getControl(mock).replay();1548 }1549 }15501551 /**1552 * Resets the given mock objects (more exactly: the controls of the mock1553 * objects). For details, see the EasyMock documentation.1554 *1555 * @param mocks1556 * the mock objects.1557 */1558 public static void reset(Object... mocks) {1559 for (Object mock : mocks) {1560 getControl(mock).reset();1561 }1562 }15631564 /**1565 * Resets the given mock objects (more exactly: the controls of the mock1566 * objects) and turn them to a mock with nice behavior. For details, see1567 * the EasyMock documentation.1568 *1569 * @param mocks1570 * the mock objects1571 */1572 public static void resetToNice(Object... mocks) {1573 for (Object mock : mocks) {1574 getControl(mock).resetToNice();1575 }1576 }15771578 /**1579 * Resets the given mock objects (more exactly: the controls of the mock1580 * objects) and turn them to a mock with default behavior. For details, see1581 * the EasyMock documentation.1582 *1583 * @param mocks1584 * the mock objects1585 */1586 public static void resetToDefault(Object... mocks) {1587 for (Object mock : mocks) {1588 getControl(mock).resetToDefault();1589 }1590 }15911592 /**1593 * Resets the given mock objects (more exactly: the controls of the mock1594 * objects) and turn them to a mock with strict behavior. For details, see1595 * the EasyMock documentation.1596 *1597 * @param mocks1598 * the mock objects1599 */1600 public static void resetToStrict(Object... mocks) {1601 for (Object mock : mocks) {1602 getControl(mock).resetToStrict();1603 }1604 }16051606 /**1607 * Verifies the given mock objects (more exactly: the controls of the mock1608 * objects).1609 *1610 * @param mocks1611 * the mock objects.1612 */1613 public static void verify(Object... mocks) {1614 for (Object mock : mocks) {1615 getControl(mock).verify();1616 }1617 }16181619 /**1620 * Switches order checking of the given mock object (more exactly: the1621 * control of the mock object) the on and off. For details, see the EasyMock1622 * documentation.1623 *1624 * @param mock1625 * the mock object.1626 * @param state1627 * <code>true</code> switches order checking on,1628 * <code>false</code> switches it off.1629 */1630 public static void checkOrder(Object mock, boolean state) {1631 getControl(mock).checkOrder(state);1632 }16331634 /**1635 * Reports an argument matcher. This method is needed to define own argument1636 * matchers. For details, see the EasyMock documentation.1637 *1638 * @param matcher1639 */1640 public static void reportMatcher(IArgumentMatcher matcher) {1641 LastControl.reportMatcher(matcher);1642 }16431644 private static MocksControl getControl(Object mock) {1645 return ((ObjectMethodsFilter) Proxy1646 .getInvocationHandler(mock)).getDelegate().getControl();1647 }16481649 /**1650 * Returns the arguments of the current mock method call, if inside an1651 * <code>IAnswer</code> callback - be careful here, reordering parameters of1652 * method changes the semantics of your tests.1653 *1654 * @return the arguments of the current mock method call.1655 * @throws IllegalStateException ...

Full Screen

Full Screen

reportMatcher

Using AI Code Generation

copy

Full Screen

1EasyMock.reportMatcher(new IArgumentMatcher() {2 public boolean matches(Object argument) {3 return argument instanceof java.util.Date;4 }5 public void appendTo(StringBuffer buffer) {6 buffer.append("any Date");7 }8});9EasyMock.reportMatcher(new IArgumentMatcher() {10 private final Date date;11 public boolean matches(Object argument) {12 return argument instanceof java.util.Date && ((Date)argument).after(date);13 }14 public void appendTo(StringBuffer buffer) {15 buffer.append("any Date after ").append(date);16 }17});18EasyMock.reportMatcher(new IArgumentMatcher() {19 private final Date date;20 public boolean matches(Object argument) {21 return argument instanceof java.util.Date && ((Date)argument).before(date);22 }23 public void appendTo(StringBuffer buffer) {24 buffer.append("any Date before ").append(date);25 }26});27EasyMock.reportMatcher(new IArgumentMatcher() {28 private final Date date1;29 private final Date date2;30 public boolean matches(Object argument) {31 return argument instanceof java.util.Date && ((Date)argument).after(date1) && ((Date)argument).before(date2);32 }33 public void appendTo(StringBuffer buffer) {34 buffer.append("any Date between ").append(date1).append(" and ").append(date2);35 }36});37EasyMock.reportMatcher(new IArgumentMatcher() {38 private final Date date1;39 private final Date date2;40 public boolean matches(Object argument) {41 return argument instanceof java.util.Date && ((Date)argument).after(date1) && ((Date)argument).before(date2);42 }

Full Screen

Full Screen

reportMatcher

Using AI Code Generation

copy

Full Screen

1import static org.easymock.EasyMock.*;2public class EasyMockArgumentMatcherExample {3 public static void main(String[] args) {4 MathApplication mathApplication = createMock(MathApplication.class);5 expect(mathApplication.add(10.0,20.0)).andReturn(30.00);6 mathApplication.add(reportMatcher(new IArgumentMatcher() {7 public boolean matches(Object argument) {8 if(argument instanceof Double){9 Double doubleValue = (Double) argument;10 if(doubleValue > 0){11 return true;12 }13 }14 return false;15 }16 public void appendTo(StringBuffer buffer) {17 buffer.append("add method argument should be of type Double and greater than 0");18 }19 }),reportMatcher(new IArgumentMatcher() {20 public boolean matches(Object argument) {21 if(argument instanceof Double){22 Double doubleValue = (Double) argument;23 if(doubleValue > 0){24 return true;25 }26 }27 return false;28 }29 public void appendTo(StringBuffer buffer) {30 buffer.append("add method argument should be of type Double and greater than 0");31 }32 })).andReturn(30.00);33 replay(mathApplication);34 assertEquals(mathApplication.add(10.0,20.0),30.0,0);35 assertEquals(mathApplication.add(10.0,20.0),30.0,0);36 verify(mathApplication);37 }38}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful