3
3
import io .api .etherscan .core .impl .EtherScanApi ;
4
4
import io .api .etherscan .error .InvalidAddressException ;
5
5
import io .api .etherscan .model .Balance ;
6
+ import io .api .etherscan .model .EthNetwork ;
6
7
import org .junit .Assert ;
7
8
import org .junit .Test ;
9
+ import org .junit .runner .RunWith ;
10
+ import org .junit .runners .Parameterized ;
11
+ import org .junit .runners .Parameterized .Parameters ;
12
+
13
+ import java .util .Arrays ;
14
+ import java .util .Collection ;
8
15
9
16
/**
10
17
* ! NO DESCRIPTION !
11
18
*
12
19
* @author GoodforGod
13
20
* @since 03.11.2018
14
21
*/
22
+ @ RunWith (Parameterized .class )
15
23
public class AccountBalanceTest extends Assert {
16
24
17
- private final EtherScanApi api = new EtherScanApi ();
25
+ private EtherScanApi api ;
26
+ private String addressCorrect ;
27
+ private String addressInvalid ;
28
+ private String addressNoResponse ;
29
+
30
+ public AccountBalanceTest (EtherScanApi api , String addressCorrect , String addressInvalid , String addressNoResponse ) {
31
+ this .api = api ;
32
+ this .addressCorrect = addressCorrect ;
33
+ this .addressInvalid = addressInvalid ;
34
+ this .addressNoResponse = addressNoResponse ;
35
+ }
36
+
37
+ @ Parameters
38
+ public static Collection data () {
39
+ return Arrays .asList (new Object [][]{
40
+ {
41
+ new EtherScanApi (),
42
+ "0x8d4426f94e42f721C7116E81d6688cd935cB3b4F" ,
43
+ "8d4426f94e42f721C7116E81d6688cd935cB3b4F" ,
44
+ "0x1d4426f94e42f721C7116E81d6688cd935cB3b4F"
45
+ },
46
+ {
47
+ new EtherScanApi (EthNetwork .ROPSTEN ),
48
+ "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" ,
49
+ "xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" ,
50
+ "0x1dbd2b932c763ba5b1b7ae3b362eac3e8d40121a"
51
+ },
52
+ {
53
+ new EtherScanApi (EthNetwork .RINKEBY ),
54
+ "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" ,
55
+ "xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a" ,
56
+ "0x1dbd2b932c763ba5b1b7ae3b362eac3e8d40121a"
57
+ },
58
+ {
59
+ new EtherScanApi (EthNetwork .KOVAN ),
60
+ "0xB9F36EE9df7E2A24B61b1738F4127BFDe8bA1A87" ,
61
+ "xB9F36EE9df7E2A24B61b1738F4127BFDe8bA1A87" ,
62
+ "0xB1F36EE9df7E2A24B61b1738F4127BFDe8bA1A87"
63
+ },
64
+ });
65
+ }
18
66
19
67
@ Test
20
68
public void correct () {
21
- Balance balance = api .account ().balance ("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F" );
69
+ Balance balance = api .account ().balance (addressCorrect );
22
70
assertNotNull (balance );
23
71
assertNotNull (balance .getWei ());
24
72
assertNotNull (balance .getMwei ());
@@ -31,12 +79,12 @@ public void correct() {
31
79
32
80
@ Test (expected = InvalidAddressException .class )
33
81
public void invalidParamWithError () {
34
- Balance balance = api .account ().balance ("8d4426f94e42f721C7116E81d6688cd935cB3b4F" );
82
+ Balance balance = api .account ().balance (addressInvalid );
35
83
}
36
84
37
85
@ Test
38
86
public void correctParamWithEmptyExpectedResult () {
39
- Balance balance = api .account ().balance ("0x8d4426f94e42f722C7116E81d6688cd935cB3b4F" );
87
+ Balance balance = api .account ().balance (addressNoResponse );
40
88
assertNotNull (balance );
41
89
assertNotNull (balance .getWei ());
42
90
assertNotNull (balance .getAddress ());
0 commit comments