Skip to content

Commit 4cd9af6

Browse files
committed
More more more codecov coverage improvements
1 parent ea81c28 commit 4cd9af6

File tree

7 files changed

+14
-37
lines changed

7 files changed

+14
-37
lines changed

src/main/java/io/api/etherscan/core/impl/BasicProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.api.etherscan.core.impl;
22

33
import com.google.gson.Gson;
4-
import io.api.etherscan.error.NoResponseException;
4+
import io.api.etherscan.error.EtherScanException;
55
import io.api.etherscan.error.ParseException;
66
import io.api.etherscan.executor.IHttpExecutor;
77
import io.api.etherscan.manager.IQueueManager;
@@ -51,7 +51,7 @@ String getRequest(final String urlParameters) {
5151
final String url = baseUrl + module + urlParameters;
5252
final String result = executor.get(url);
5353
if (BasicUtils.isEmpty(result))
54-
throw new NoResponseException("Server returned null value for GET request at URL - " + url);
54+
throw new EtherScanException("Server returned null value for GET request at URL - " + url);
5555

5656
return result;
5757
}

src/main/java/io/api/etherscan/core/impl/ProxyApiProvider.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ public Optional<String> txSendRaw(final String hexEncodedTx) throws ApiException
145145
throw new EtherScanException("Error occurred with code " + response.getError().getCode()
146146
+ " with message " + response.getError().getMessage());
147147

148-
return (BasicUtils.isEmpty(response.getResult()))
149-
? Optional.empty()
150-
: Optional.of(response.getResult());
148+
return Optional.ofNullable(response.getResult());
151149
}
152150

153151
@NotNull
@@ -169,9 +167,7 @@ public Optional<String> call(final String address, final String data) throws Api
169167

170168
final String urlParams = ACT_CALL_PARAM + TO_PARAM + address + DATA_PARAM + data + TAG_LAST_PARAM;
171169
final StringProxyTO response = getRequest(urlParams, StringProxyTO.class);
172-
return (BasicUtils.isEmpty(response.getResult()))
173-
? Optional.empty()
174-
: Optional.of(response.getResult());
170+
return Optional.ofNullable (response.getResult());
175171
}
176172

177173
@NotNull
@@ -181,9 +177,7 @@ public Optional<String> code(final String address) throws ApiException {
181177

182178
final String urlParams = ACT_CODE_PARAM + ADDRESS_PARAM + address + TAG_LAST_PARAM;
183179
final StringProxyTO response = getRequest(urlParams, StringProxyTO.class);
184-
return (BasicUtils.isEmpty(response.getResult()))
185-
? Optional.empty()
186-
: Optional.of(response.getResult());
180+
return Optional.ofNullable(response.getResult());
187181
}
188182

189183
@NotNull

src/main/java/io/api/etherscan/error/NoResponseException.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/test/java/io/api/etherscan/EtherScanApiTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void validKey() {
3434

3535
@Test(expected = ApiKeyException.class)
3636
public void emptyKey() {
37-
new EtherScanApi("", network);
37+
new EtherScanApi("");
3838
}
3939

4040
@Test(expected = ApiKeyException.class)

src/test/java/io/api/etherscan/account/AccountBalanceListTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ public void invalidParamWithError() {
7171
addresses.add("0x9327cb34984c3992ec1EA0eAE98Ccf80A74f95B9");
7272
addresses.add("C9F32CE1127e44C51cbD182D6364F3D707Fd0d47");
7373

74+
api.account().balances(addresses);
75+
}
76+
77+
@Test
78+
public void emptyParamList() {
79+
List<String> addresses = new ArrayList<>();
7480
List<Balance> balances = api.account().balances(addresses);
81+
assertNotNull(balances);
82+
assertTrue(balances.isEmpty());
7583
}
7684

7785
@Test

src/test/java/io/api/etherscan/account/AccountTokenBalanceTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.junit.runners.Parameterized;
1212
import org.junit.runners.Parameterized.Parameters;
1313

14-
import java.math.BigInteger;
1514
import java.util.Arrays;
1615
import java.util.Collection;
1716

@@ -93,10 +92,6 @@ public void correct() {
9392
assertNotEquals(0, balance.getWei());
9493
assertNotNull(balance.toString());
9594

96-
TokenBalance balance1 = new TokenBalance("", BigInteger.ONE, "");
97-
assertNotEquals(balance, balance1);
98-
assertNotEquals(balance.hashCode(), balance1.hashCode());
99-
10095
TokenBalance balance2 = new TokenBalance("125161", balance.getWei(), balance.getContract());
10196
assertNotEquals(balance, balance2);
10297
assertNotEquals(balance.hashCode(), balance2.hashCode());

src/test/java/io/api/util/UtilTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.google.gson.Gson;
44
import io.api.etherscan.error.EtherScanException;
5-
import io.api.etherscan.error.NoResponseException;
65
import io.api.etherscan.error.ParseException;
76
import io.api.etherscan.model.utility.StringResponseTO;
87
import org.junit.Assert;
@@ -101,9 +100,4 @@ public void isResponseNullThrows() {
101100
public void isThrowParseException() {
102101
throw new ParseException("Test", null);
103102
}
104-
105-
@Test(expected = NoResponseException.class)
106-
public void isThrowNoResponseException() {
107-
throw new NoResponseException("Test");
108-
}
109103
}

0 commit comments

Comments
 (0)