Skip to content

Commit 8773528

Browse files
authored
Merge pull request #221 from mwarzybok-sumoheavy/feature/updateDependencies
Feature/update dependencies
2 parents fb1a21f + addfb38 commit 8773528

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+431
-327
lines changed

pom.xml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.bitpay</groupId>
88
<artifactId>bitpay_sdk</artifactId>
9-
<version>8.6.2</version>
9+
<version>9.0.0-beta1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>BitPay</name>
@@ -141,7 +141,7 @@
141141
<dependency>
142142
<groupId>org.bitcoinj</groupId>
143143
<artifactId>bitcoinj-core</artifactId>
144-
<version>0.16-beta1</version>
144+
<version>0.16.2</version>
145145
<scope>compile</scope>
146146
</dependency>
147147
<dependency>
@@ -162,69 +162,69 @@
162162
<dependency>
163163
<groupId>org.apache.httpcomponents</groupId>
164164
<artifactId>fluent-hc</artifactId>
165-
<version>4.5.13</version>
165+
<version>4.5.14</version>
166166
</dependency>
167167
<dependency>
168-
<groupId>org.apache.httpcomponents</groupId>
169-
<artifactId>httpclient</artifactId>
170-
<version>4.5.13</version>
168+
<groupId>org.apache.httpcomponents.client5</groupId>
169+
<artifactId>httpclient5</artifactId>
170+
<version>5.2.1</version>
171171
</dependency>
172172
<dependency>
173173
<groupId>org.apache.httpcomponents</groupId>
174174
<artifactId>httpclient-cache</artifactId>
175-
<version>4.5.13</version>
175+
<version>4.5.14</version>
176176
</dependency>
177177
<dependency>
178-
<groupId>org.apache.httpcomponents</groupId>
179-
<artifactId>httpcore</artifactId>
180-
<version>4.4.14</version>
178+
<groupId>org.apache.httpcomponents.core5</groupId>
179+
<artifactId>httpcore5</artifactId>
180+
<version>5.2.1</version>
181181
</dependency>
182182
<dependency>
183183
<groupId>org.apache.httpcomponents</groupId>
184184
<artifactId>httpmime</artifactId>
185-
<version>4.5.13</version>
185+
<version>4.5.14</version>
186186
</dependency>
187187
<dependency>
188188
<groupId>com.fasterxml.jackson.core</groupId>
189189
<artifactId>jackson-annotations</artifactId>
190-
<version>2.13.0</version>
190+
<version>2.14.2</version>
191191
</dependency>
192192
<dependency>
193193
<groupId>com.fasterxml.jackson.core</groupId>
194194
<artifactId>jackson-core</artifactId>
195-
<version>2.13.0</version>
195+
<version>2.14.2</version>
196196
</dependency>
197197
<dependency>
198198
<groupId>com.fasterxml.jackson.core</groupId>
199199
<artifactId>jackson-databind</artifactId>
200-
<version>2.14.0</version>
200+
<version>2.14.2</version>
201201
</dependency>
202202
<dependency>
203203
<groupId>org.slf4j</groupId>
204204
<artifactId>slf4j-api</artifactId>
205-
<version>2.0.0-alpha5</version>
205+
<version>2.0.6</version>
206206
</dependency>
207207
<dependency>
208208
<groupId>org.slf4j</groupId>
209209
<artifactId>slf4j-simple</artifactId>
210-
<version>2.0.0-alpha5</version>
210+
<version>2.0.6</version>
211211
</dependency>
212212
<dependency>
213213
<groupId>org.junit.jupiter</groupId>
214214
<artifactId>junit-jupiter-engine</artifactId>
215-
<version>5.7.2</version>
215+
<version>5.9.2</version>
216216
<scope>test</scope>
217217
</dependency>
218218
<dependency>
219219
<groupId>org.mockito</groupId>
220220
<artifactId>mockito-core</artifactId>
221-
<version>4.8.0</version>
221+
<version>4.11.0</version>
222222
<scope>test</scope>
223223
</dependency>
224224
<dependency>
225225
<groupId>org.mockito</groupId>
226226
<artifactId>mockito-junit-jupiter</artifactId>
227-
<version>4.8.0</version>
227+
<version>4.11.0</version>
228228
<scope>test</scope>
229229
</dependency>
230230
<dependency>

src/main/java/com/bitpay/sdk/Client.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757
import com.bitpay.sdk.model.Rate.Rates;
5858
import com.bitpay.sdk.model.Settlement.Settlement;
5959
import com.bitpay.sdk.model.Wallet.Wallet;
60-
import com.bitpay.sdk.util.AccessTokens;
6160
import com.bitpay.sdk.util.GuidGenerator;
61+
import com.bitpay.sdk.util.JsonMapperFactory;
6262
import com.bitpay.sdk.util.KeyUtils;
63+
import com.bitpay.sdk.util.TokenContainer;
6364
import com.fasterxml.jackson.core.JsonProcessingException;
6465
import com.fasterxml.jackson.databind.JsonNode;
65-
import com.fasterxml.jackson.databind.ObjectMapper;
66+
import com.fasterxml.jackson.databind.json.JsonMapper;
6667
import java.io.File;
6768
import java.net.URISyntaxException;
6869
import java.nio.file.Files;
@@ -83,7 +84,7 @@ public class Client {
8384

8485
private GuidGenerator guidGenerator;
8586
private BitPayClient bitPayClient;
86-
private AccessTokens accessTokens;
87+
private TokenContainer accessTokens;
8788

8889
/**
8990
* Return the identity of this client (i.e. the public key).
@@ -108,7 +109,7 @@ public Client(PosToken token) throws BitPayException {
108109
* @throws BitPayException the bit pay exception
109110
*/
110111
public Client(PosToken token, Environment environment) throws BitPayException {
111-
this.accessTokens = new AccessTokens();
112+
this.accessTokens = new TokenContainer();
112113
this.accessTokens.addPos(token.value());
113114
this.bitPayClient = new BitPayClient(
114115
getHttpClient(null, null),
@@ -132,7 +133,7 @@ public Client(PosToken token, Environment environment) throws BitPayException {
132133
public Client(
133134
Environment environment,
134135
PrivateKey privateKey,
135-
AccessTokens accessTokens,
136+
TokenContainer accessTokens,
136137
HttpHost proxyDetails,
137138
CredentialsProvider proxyCredentials
138139
) throws BitPayException {
@@ -164,7 +165,7 @@ public Client(
164165
public Client(ConfigFilePath configFilePath, HttpHost proxy, CredentialsProvider proxyCredentials) throws BitPayException {
165166
try {
166167
Config config = this.buildConfigFromFile(configFilePath);
167-
this.accessTokens = new AccessTokens(config);
168+
this.accessTokens = new TokenContainer(config);
168169
ECKey ecKey = this.getEcKey(config);
169170
if (Objects.isNull(ecKey)) {
170171
throw new BitPayException(null, "Missing ECKey");
@@ -201,7 +202,7 @@ public Client(ConfigFilePath configFilePath, HttpHost proxy, CredentialsProvider
201202
public Client(
202203
BitPayClient bitPayClient,
203204
String identity,
204-
AccessTokens accessTokens,
205+
TokenContainer accessTokens,
205206
GuidGenerator GuidGenerator
206207
) {
207208
this.bitPayClient = bitPayClient;
@@ -229,7 +230,7 @@ public static Client createPosClient(PosToken token) throws BitPayException {
229230
* @return the client
230231
* @throws BitPayException the bit pay exception
231232
*/
232-
public static Client createClient(PrivateKey privateKey, AccessTokens tokens) throws BitPayException {
233+
public static Client createClient(PrivateKey privateKey, TokenContainer tokens) throws BitPayException {
233234
return new Client(Environment.PROD, privateKey, tokens, null, null);
234235
}
235236

@@ -1246,12 +1247,11 @@ protected String getBaseUrl(Environment environment) {
12461247
protected Config buildConfigFromFile(ConfigFilePath configFilePath) throws BitPayException {
12471248
try {
12481249
byte[] jsonData = Files.readAllBytes(Paths.get(configFilePath.value()));
1249-
//create ObjectMapper instance
1250-
ObjectMapper mapper = new ObjectMapper();
1250+
JsonMapper mapper = JsonMapperFactory.create();
12511251
//read JSON like DOM Parser
12521252
JsonNode rootNode = mapper.readTree(jsonData);
12531253
JsonNode bitPayConfiguration = rootNode.path("BitPayConfiguration");
1254-
return new ObjectMapper().readValue(bitPayConfiguration.toString(), Config.class);
1254+
return mapper.readValue(bitPayConfiguration.toString(), Config.class);
12551255
} catch (JsonProcessingException e) {
12561256
throw new BitPayException(null, "failed to read configuration file : " + e.getMessage());
12571257
} catch (Exception e) {

src/main/java/com/bitpay/sdk/Config.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/*
2+
* Copyright (c) 2019 BitPay
3+
*/
14
package com.bitpay.sdk;
25

36
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -29,7 +32,7 @@ public class Config {
2932
/**
3033
* BitPay Plugin Info Version.
3134
*/
32-
public static final String BITPAY_PLUGIN_INFO = "BitPay_Java_Client_v8.5.2208";
35+
public static final String BITPAY_PLUGIN_INFO = "BitPay_Java_Client_v9.0.0-beta1";
3336
/**
3437
* BitPay Api Frame.
3538
*/
@@ -118,7 +121,7 @@ public ObjectNode getApiTokens() {
118121
apiTokens = (ObjectNode) envConfig.get(API_TOKENS_KEY);
119122
if (Objects.isNull(apiTokens)) {
120123
apiTokens = (ObjectNode) JsonNodeFactory.instance.objectNode();
121-
envConfig.put(API_TOKENS_KEY, apiTokens);
124+
envConfig.putIfAbsent(API_TOKENS_KEY, apiTokens);
122125
}
123126

124127
return apiTokens;

src/main/java/com/bitpay/sdk/client/AuthorizationClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.bitpay.sdk.exceptions.BitPayException;
88
import com.bitpay.sdk.model.Facade;
99
import com.bitpay.sdk.model.Token;
10-
import com.bitpay.sdk.util.AccessTokens;
10+
import com.bitpay.sdk.util.TokenContainer;
1111
import com.bitpay.sdk.util.JsonMapperFactory;
1212
import com.bitpay.sdk.util.GuidGenerator;
1313
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -24,7 +24,7 @@ public class AuthorizationClient {
2424

2525
private final BitPayClient bitPayClient;
2626
private final GuidGenerator guidGenerator;
27-
private final AccessTokens accessToken;
27+
private final TokenContainer accessToken;
2828
private final String identity;
2929

3030
/**
@@ -38,7 +38,7 @@ public class AuthorizationClient {
3838
public AuthorizationClient(
3939
BitPayClient bitPayClient,
4040
GuidGenerator guidGenerator,
41-
AccessTokens accessToken,
41+
TokenContainer accessToken,
4242
String identity
4343
) {
4444
this.bitPayClient = bitPayClient;

src/main/java/com/bitpay/sdk/client/BillClient.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import com.bitpay.sdk.exceptions.BitPayException;
1212
import com.bitpay.sdk.model.Bill.Bill;
1313
import com.bitpay.sdk.model.Facade;
14-
import com.bitpay.sdk.util.AccessTokens;
1514
import com.bitpay.sdk.util.JsonMapperFactory;
1615
import com.bitpay.sdk.util.ParameterAdder;
16+
import com.bitpay.sdk.util.TokenContainer;
1717
import com.fasterxml.jackson.core.JsonProcessingException;
18-
import com.fasterxml.jackson.databind.ObjectMapper;
1918
import com.fasterxml.jackson.databind.json.JsonMapper;
2019
import java.util.ArrayList;
2120
import java.util.Arrays;
@@ -32,15 +31,15 @@
3231
public class BillClient {
3332

3433
private final BitPayClient bitPayClient;
35-
private final AccessTokens accessTokens;
34+
private final TokenContainer accessTokens;
3635

3736
/**
3837
* Instantiates a new Bill client.
3938
*
4039
* @param bitPayClient the bit pay client
4140
* @param accessTokens the access tokens
4241
*/
43-
public BillClient(BitPayClient bitPayClient, AccessTokens accessTokens) {
42+
public BillClient(BitPayClient bitPayClient, TokenContainer accessTokens) {
4443
this.bitPayClient = bitPayClient;
4544
this.accessTokens = accessTokens;
4645
}
@@ -104,7 +103,7 @@ public Bill getBill(String billId, Facade facade, boolean signRequest) throws Bi
104103

105104
try {
106105
HttpResponse response = this.bitPayClient.get("bills/" + billId, params, signRequest);
107-
bill = new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill.class);
106+
bill = JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill.class);
108107
} catch (JsonProcessingException e) {
109108
throw new BillQueryException(null,
110109
"failed to deserialize BitPay server response (Bill) : " + e.getMessage());
@@ -133,7 +132,7 @@ public Bill getBill(String billId, Facade facade, boolean signRequest) throws Bi
133132

134133
try {
135134
HttpResponse response = this.bitPayClient.get("bills", params);
136-
bills = Arrays.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
135+
bills = Arrays.asList(JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
137136
} catch (JsonProcessingException e) {
138137
throw new BillQueryException(null,
139138
"failed to deserialize BitPay server response (Bills) : " + e.getMessage());
@@ -160,7 +159,7 @@ public List<Bill> getBills() throws BitPayException, BillQueryException {
160159

161160
try {
162161
HttpResponse response = this.bitPayClient.get("bills", params);
163-
bills = Arrays.asList(new ObjectMapper().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
162+
bills = Arrays.asList(JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Bill[].class));
164163
} catch (JsonProcessingException e) {
165164
throw new BillQueryException(null,
166165
"failed to deserialize BitPay server response (Bills) : " + e.getMessage());

src/main/java/com/bitpay/sdk/client/CurrencyClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.bitpay.sdk.exceptions.BitPayException;
88
import com.bitpay.sdk.util.JsonMapperFactory;
99
import com.fasterxml.jackson.databind.JsonNode;
10-
import com.fasterxml.jackson.databind.ObjectMapper;
1110
import com.fasterxml.jackson.databind.json.JsonMapper;
1211
import java.util.ArrayList;
1312
import java.util.Arrays;
@@ -23,7 +22,7 @@
2322
public class CurrencyClient {
2423

2524
private final BitPayClient client;
26-
private List currenciesInfo;
25+
private List<Map<String, String>> currenciesInfo;
2726

2827
/**
2928
* Instantiates a new Currency client.
@@ -45,6 +44,7 @@ public CurrencyClient(BitPayClient client) throws BitPayException {
4544
* @return Map |null
4645
* @throws BitPayException the bit pay exception
4746
*/
47+
@SuppressWarnings (value="unchecked")
4848
public Map<String, Object> getCurrencyInfo(String currencyCode) throws BitPayException {
4949
if (Objects.isNull(currencyCode)) {
5050
throw new BitPayException(null, "missing required parameter");
@@ -55,7 +55,7 @@ public Map<String, Object> getCurrencyInfo(String currencyCode) throws BitPayExc
5555
}
5656

5757
for (Object currency : this.currenciesInfo) {
58-
Map currencyInfo = new ObjectMapper().convertValue(currency, Map.class);
58+
Map<String, Object> currencyInfo = JsonMapperFactory.create().convertValue(currency, Map.class);
5959

6060
if (currencyInfo.get("code").toString().equals(currencyCode)) {
6161
return currencyInfo;
@@ -70,6 +70,7 @@ public Map<String, Object> getCurrencyInfo(String currencyCode) throws BitPayExc
7070
*
7171
* @throws BitPayException BitPayException class
7272
*/
73+
@SuppressWarnings (value="unchecked")
7374
private void loadCurrencies() throws BitPayException {
7475
try {
7576
HttpEntity newEntity = this.client.get("currencies").getEntity();
@@ -87,7 +88,9 @@ private void loadCurrencies() throws BitPayException {
8788
jsonString = node.toString();
8889
}
8990

90-
this.currenciesInfo = new ArrayList(Arrays.asList(new ObjectMapper().readValue(jsonString, Map[].class)));
91+
this.currenciesInfo = new ArrayList(Arrays.asList(
92+
JsonMapperFactory.create().readValue(jsonString, Map[].class))
93+
);
9194

9295
} catch (Exception e) {
9396
// No action required

0 commit comments

Comments
 (0)