-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMethod.java
More file actions
42 lines (34 loc) · 994 Bytes
/
Method.java
File metadata and controls
42 lines (34 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package io.github.walterinsh;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
/**
* Util class for showing unit testing
*
* Created by Walter on 11/1/15.
*/
public class Method {
public static int returnsOne() {
return 1;
}
public static int shouldHaveReturnedOne() {
return 2;
}
public static boolean returnsTrue() {
return true;
}
public static Object returnsNull() {
return null;
}
public static void onlyAcceptPositiveNum(int param) {
if(param == 0){
throw new IllegalArgumentException("0 is not acceptable");
}else if(param <0) {
throw new IllegalArgumentException("negative num is not acceptable");
}
}
public static void onlyAcceptNumberString(String str) {
if (!NumberUtils.isNumber(str)) {
throw new IllegalArgumentException("only number strings are acceptable");
}
}
}