Skip to content

Commit e6bee19

Browse files
committed
[2.0.0]
BasicProvider simplified StatisticPriceApiTests assert fixed
1 parent b05bd8a commit e6bee19

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

Diff for: src/main/java/io/goodforgod/api/etherscan/BasicProvider.java

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.goodforgod.api.etherscan;
22

3-
import io.goodforgod.api.etherscan.error.EtherScanException;
43
import io.goodforgod.api.etherscan.error.EtherScanParseException;
54
import io.goodforgod.api.etherscan.error.EtherScanRateLimitException;
65
import io.goodforgod.api.etherscan.error.EtherScanResponseException;
@@ -9,7 +8,6 @@
98
import io.goodforgod.api.etherscan.model.response.StringResponseTO;
109
import java.net.URI;
1110
import java.nio.charset.StandardCharsets;
12-
import java.util.Map;
1311

1412
/**
1513
* Base provider for API Implementations
@@ -64,36 +62,14 @@ <T> T convert(byte[] json, Class<T> tClass) {
6462
}
6563

6664
final String jsonAsString = new String(json, StandardCharsets.UTF_8);
67-
try {
68-
final Map<String, Object> map = converter.fromJson(json, Map.class);
69-
final Object result = map.get("result");
70-
if (result instanceof String && ((String) result).startsWith(MAX_RATE_LIMIT_REACHED))
71-
throw new EtherScanRateLimitException(((String) result));
72-
73-
throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString);
74-
} catch (EtherScanException ex) {
75-
throw ex;
76-
} catch (Exception ex) {
77-
throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString);
78-
}
65+
throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString);
7966
}
8067
}
8168

8269
byte[] getRequest(String urlParameters) {
8370
queue.takeTurn();
8471
final URI uri = URI.create(baseUrl + module + urlParameters);
85-
final byte[] result = executor.get(uri);
86-
if (result.length == 0) {
87-
final StringResponseTO emptyResponse = StringResponseTO.builder()
88-
.withStatus("0")
89-
.withMessage("Server returned null value for GET request at URL - " + uri)
90-
.withResult("")
91-
.build();
92-
93-
throw new EtherScanResponseException(emptyResponse, "Server returned null value for GET request at URL - " + uri);
94-
}
95-
96-
return result;
72+
return executor.get(uri);
9773
}
9874

9975
byte[] postRequest(String urlParameters, String dataToPost) {

Diff for: src/test/java/io/goodforgod/api/etherscan/statistic/StatisticPriceApiTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ void correct() {
1616
assertNotNull(price);
1717
assertNotNull(price.btcTimestamp());
1818
assertNotNull(price.usdTimestamp());
19-
assertNotEquals(0.0, price.inBtc());
20-
assertNotEquals(0.0, price.inUsd());
19+
assertNotEquals(0.0, price.inBtc().doubleValue());
20+
assertNotEquals(0.0, price.inUsd().doubleValue());
2121
assertNotNull(price.toString());
2222

2323
Price empty = Price.builder().build();

0 commit comments

Comments
 (0)