forked from GoodforGod/java-etherscan-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtilTests.java
More file actions
103 lines (86 loc) · 2.57 KB
/
Copy pathUtilTests.java
File metadata and controls
103 lines (86 loc) · 2.57 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package io.api.util;
import com.google.gson.Gson;
import io.api.etherscan.error.EtherScanException;
import io.api.etherscan.error.ParseException;
import io.api.etherscan.model.utility.StringResponseTO;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static io.api.etherscan.util.BasicUtils.*;
/**
* ! NO DESCRIPTION !
*
* @author GoodforGod
* @since 13.11.2018
*/
public class UtilTests extends Assert {
@Test(expected = EtherScanException.class)
public void responseValidateEmpty() {
String response = "{\"status\":\"0\",\"message\":\"No ether\",\"result\":\"status\"}";
StringResponseTO responseTO = new Gson().fromJson(response, StringResponseTO.class);
validateTxResponse(responseTO);
}
@Test
public void partitionEmpty() {
ArrayList<String> list = new ArrayList<>();
List<List<String>> lists = partition(list, 12);
assertTrue(lists.isEmpty());
}
@Test
public void partitionNullParam() {
List<List<String>> lists = partition(null, 12);
assertTrue(lists.isEmpty());
}
@Test
public void isBlankNull() {
boolean result = isBlank(null);
assertTrue(result);
}
@Test
public void isEmptyCollectionNull() {
List<String> list = null;
boolean result = isEmpty(list);
assertTrue(result);
}
@Test
public void isEmptyCollectionEmpty() {
ArrayList<Object> list = new ArrayList<>();
boolean result = isEmpty(list);
assertTrue(result);
}
@Test
public void isNotAddressNull() {
boolean result = isNotAddress("");
assertTrue(result);
}
@Test
public void isNotHexNull() {
boolean result = isNotHex("");
assertTrue(result);
}
@Test
public void isNotAddressInvalid() {
boolean result = isNotAddress("125125");
assertTrue(result);
}
@Test
public void isNotHexInvalid() {
boolean result = isNotHex("1215%");
assertTrue(result);
}
@Test(expected = EtherScanException.class)
public void isResponseStatusInvalidThrows() {
StringResponseTO responseTO = new StringResponseTO();
validateTxResponse(responseTO);
}
@Test(expected = EtherScanException.class)
public void isResponseNullThrows() {
StringResponseTO responseTO = null;
validateTxResponse(responseTO);
}
@Test(expected = ParseException.class)
public void isThrowParseException() {
throw new ParseException("Test", null);
}
}