Skip to content

Commit cf1cfff

Browse files
authored
<fix>(test): remove unnecessary dependency com.google.guava. (#811)
1 parent c20a3d7 commit cf1cfff

File tree

5 files changed

+37
-49
lines changed

5 files changed

+37
-49
lines changed

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ext {
2424
webankJavaCryptoVersion = "1.0.3"
2525
junitVersion = '4.13.2'
2626
commonsCollections4Version = "4.4"
27-
guavaVersion = '31.1-jre'
2827
bcosSdkJniVersion = "3.4.0"
2928
slf4jApiVerison = '1.7.36'
3029
mockitoVersion = '4.8.0'
@@ -68,7 +67,6 @@ allprojects {
6867
api("org.slf4j:slf4j-api:${slf4jApiVerison}")
6968
testImplementation("junit:junit:${junitVersion}")
7069
testImplementation("org.apache.commons:commons-collections4:${commonsCollections4Version}")
71-
testImplementation("com.google.guava:guava:${guavaVersion}")
7270
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
7371
}
7472

src/integration-test/java/org/fisco/bcos/sdk/v3/test/transaction/decoder/EventDecodeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
package org.fisco.bcos.sdk.v3.test.transaction.decoder;
1616

17-
import com.google.common.collect.Lists;
17+
import java.util.ArrayList;
1818
import java.util.List;
1919
import java.util.Map;
2020
import org.fisco.bcos.sdk.v3.BcosSDK;
@@ -53,7 +53,7 @@ public void testDecode() throws Exception {
5353
client, client.getCryptoSuite().getCryptoKeyPair(), abiFile, binFile);
5454
ContractCodec contractCodec = new ContractCodec(client.getCryptoSuite(), client.isWASM());
5555
// deploy
56-
List<Object> params = Lists.newArrayList();
56+
List<Object> params = new ArrayList<>();
5757
params.add(1);
5858
params.add("test2");
5959
TransactionResponse response = manager.deployByContractLoader("ComplexSol", params);

src/integration-test/java/org/fisco/bcos/sdk/v3/test/transaction/decoder/TransactionDecoderServiceTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
*/
1515
package org.fisco.bcos.sdk.v3.test.transaction.decoder;
1616

17-
import com.google.common.collect.Lists;
1817
import java.math.BigInteger;
19-
import java.util.ArrayList;
20-
import java.util.List;
21-
import java.util.Map;
18+
import java.util.*;
19+
2220
import org.fisco.bcos.sdk.v3.BcosSDK;
2321
import org.fisco.bcos.sdk.v3.client.Client;
2422
import org.fisco.bcos.sdk.v3.model.ConstantConfig;
@@ -57,7 +55,7 @@ public void testDecode() throws Exception {
5755
TransactionProcessorFactory.createAssembleTransactionProcessor(
5856
client, client.getCryptoSuite().getCryptoKeyPair(), abiFile, binFile);
5957
// deploy
60-
List<Object> params = Lists.newArrayList();
58+
List<Object> params = new ArrayList<>();
6159
params.add(1);
6260
params.add("test2");
6361
TransactionResponse response = manager.deployByContractLoader(contractName, params);
@@ -71,9 +69,10 @@ public void testDecode() throws Exception {
7169
contractName,
7270
contractAddress,
7371
"incrementUint256",
74-
Lists.newArrayList(BigInteger.valueOf(1)));
72+
Collections.singletonList(BigInteger.ONE));
7573
TransactionResponse transactionResponseWithoutValues =
7674
decoder.decodeReceiptWithoutValues(abi, transactionReceipt);
75+
Assert.assertEquals(0, transactionResponseWithoutValues.getReturnCode());
7776
TransactionResponse transactionResponseWithValues =
7877
decoder.decodeReceiptWithValues(abi, "incrementUint256", transactionReceipt);
7978
Assert.assertEquals("Success", transactionResponseWithValues.getReceiptMessages());
@@ -83,8 +82,8 @@ public void testDecode() throws Exception {
8382
}
8483
// setBytesMapping
8584
{
86-
List<Object> s = Lists.newArrayList("2".getBytes());
87-
List<Object> paramsSetBytes = new ArrayList<Object>();
85+
List<Object> s = Collections.singletonList("2".getBytes());
86+
List<Object> paramsSetBytes = new ArrayList<>();
8887
paramsSetBytes.add(s);
8988
TransactionReceipt transactionReceipt2 =
9089
manager.sendTransactionAndGetReceiptByContractLoader(
@@ -96,7 +95,7 @@ public void testDecode() throws Exception {
9695
Assert.assertEquals(
9796
transactionResponse2.getReceiptMessages(), "Bytes array is less than 2");
9897

99-
List<Object> s2 = Lists.newArrayList("2".getBytes(), "3".getBytes());
98+
List<Object> s2 = Arrays.asList("2".getBytes(), "3".getBytes());
10099
List<Object> paramsSetBytes2 = new ArrayList<>();
101100
paramsSetBytes2.add(s2);
102101
TransactionReceipt transactionReceipt =

src/integration-test/java/org/fisco/bcos/sdk/v3/test/transaction/manager/AssembleTransactionProcessorTest.java

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414
*/
1515
package org.fisco.bcos.sdk.v3.test.transaction.manager;
1616

17-
import com.google.common.collect.Lists;
18-
1917
import java.math.BigInteger;
20-
import java.util.ArrayList;
21-
import java.util.Arrays;
22-
import java.util.Base64;
23-
import java.util.List;
24-
import java.util.Map;
25-
import java.util.Objects;
18+
import java.util.*;
2619
import java.util.concurrent.CompletableFuture;
2720

2821
import org.apache.commons.collections4.ListUtils;
@@ -174,7 +167,7 @@ public void test11HelloWorldAsync() throws Exception {
174167
// send tx with callback
175168
String to = callbackMock.getResult().getContractAddress();
176169
System.out.println("contract address is " + to);
177-
List<Object> params = Lists.newArrayList("test");
170+
List<Object> params = Collections.singletonList("test");
178171
transactionProcessor.sendTransactionAsync(to, abi, "set", params, callbackMock);
179172
Assert.assertEquals(0, callbackMock.getResult().getStatus());
180173

@@ -205,7 +198,7 @@ public void test2ComplexDeploy() throws Exception {
205198
TransactionProcessorFactory.createAssembleTransactionProcessor(
206199
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
207200
// deploy
208-
List<Object> params = Lists.newArrayList();
201+
List<Object> params = new ArrayList<>();
209202
params.add(1);
210203
params.add("test2");
211204
TransactionResponse response =
@@ -233,7 +226,7 @@ public void test3ComplexQuery() throws Exception {
233226
TransactionProcessorFactory.createAssembleTransactionProcessor(
234227
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
235228
// deploy
236-
List<Object> params = Lists.newArrayList();
229+
List<Object> params = new ArrayList<>();
237230
params.add(1);
238231
params.add("test2");
239232
TransactionResponse response =
@@ -273,7 +266,7 @@ public void test4ComplexEmptyTx() throws Exception {
273266
TransactionProcessorFactory.createAssembleTransactionProcessor(
274267
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
275268
// deploy
276-
List<Object> params = Lists.newArrayList();
269+
List<Object> params = new ArrayList<>();
277270
params.add(1);
278271
params.add("test2");
279272
TransactionResponse response =
@@ -293,7 +286,7 @@ public void test5ComplexIncrement() throws Exception {
293286
TransactionProcessorFactory.createAssembleTransactionProcessor(
294287
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
295288
// deploy
296-
List<Object> params = Lists.newArrayList();
289+
List<Object> params = new ArrayList<>();
297290
params.add(1);
298291
params.add("test2");
299292
TransactionResponse response =
@@ -305,7 +298,7 @@ public void test5ComplexIncrement() throws Exception {
305298
contractAddress,
306299
this.ABI,
307300
"incrementUint256",
308-
Lists.newArrayList(BigInteger.valueOf(10)),
301+
Collections.singletonList(BigInteger.valueOf(10)),
309302
new TransactionCallback() {
310303
@Override
311304
public void onResponse(TransactionReceipt receipt) {
@@ -320,7 +313,7 @@ public void onResponse(TransactionReceipt receipt) {
320313
contractAddress,
321314
AssembleTransactionProcessorTest.this.ABI,
322315
"getUint256",
323-
Lists.newArrayList());
316+
new ArrayList<>());
324317
System.out.println(JsonUtils.toJson(callResponse3));
325318
Assert.assertEquals("Success", callResponse3.getReturnMessage());
326319
} catch (TransactionBaseException | ContractCodecException e) {
@@ -336,15 +329,15 @@ public void test6ComplexSetValues() throws Exception {
336329
TransactionProcessorFactory.createAssembleTransactionProcessor(
337330
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
338331
// deploy
339-
List<Object> params = Lists.newArrayList();
332+
List<Object> params = new ArrayList<>();
340333
params.add(-1);
341334
params.add("test2");
342335
TransactionResponse response =
343336
transactionProcessor.deployByContractLoader("ComplexSol", params);
344337
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
345338
String contractAddress = response.getContractAddress();
346339
// set values
347-
List<Object> paramsSetValues = Lists.newArrayList(-20);
340+
List<Object> paramsSetValues = new ArrayList<>(Collections.singletonList(-20));
348341
String[] o = {"0x1", "0x2", "0x3"};
349342
List<String> a = Arrays.asList(o);
350343
paramsSetValues.add(a);
@@ -363,7 +356,7 @@ public void test6ComplexSetValues() throws Exception {
363356
contractAddress,
364357
ABI,
365358
"getValues",
366-
Lists.newArrayList());
359+
new ArrayList<>());
367360
Assert.assertEquals(0, callResponse4.getReturnCode());
368361
Assert.assertEquals(
369362
callResponse4.getResults().get(0).getValue(), new Int256(-20).getValue());
@@ -376,7 +369,7 @@ public void test7ComplexSetBytes() throws Exception {
376369
TransactionProcessorFactory.createAssembleTransactionProcessor(
377370
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
378371
// deploy
379-
List<Object> params = Lists.newArrayList();
372+
List<Object> params = new ArrayList<>();
380373
params.add(1);
381374
params.add("test2");
382375
TransactionResponse response =
@@ -385,7 +378,7 @@ public void test7ComplexSetBytes() throws Exception {
385378
String contractAddress = response.getContractAddress();
386379
// setBytes
387380
{
388-
List<String> paramsSetBytes = Lists.newArrayList(new String("123".getBytes()));
381+
List<String> paramsSetBytes = Collections.singletonList(new String("123".getBytes()));
389382
TransactionResponse transactionResponse3 =
390383
transactionProcessor.sendTransactionWithStringParamsAndGetResponse(
391384
contractAddress, ABI, "setBytes", paramsSetBytes);
@@ -402,7 +395,7 @@ public void test7ComplexSetBytes() throws Exception {
402395
contractAddress,
403396
ABI,
404397
"_bytesV",
405-
Lists.newArrayList());
398+
new ArrayList<>());
406399
Assert.assertEquals(0, callResponse4.getReturnCode());
407400
Assert.assertEquals(
408401
Hex.toHexString((byte[]) callResponse4.getResults().get(0).getValue()),
@@ -412,7 +405,7 @@ public void test7ComplexSetBytes() throws Exception {
412405
// setBytes
413406
{
414407
List<String> paramsSetBytes2 =
415-
Lists.newArrayList(new String("hex://0x1234".getBytes()));
408+
Collections.singletonList(new String("hex://0x1234".getBytes()));
416409
TransactionResponse transactionResponse4 =
417410
transactionProcessor.sendTransactionWithStringParamsAndGetResponse(
418411
contractAddress, ABI, "setBytes", paramsSetBytes2);
@@ -428,7 +421,7 @@ public void test7ComplexSetBytes() throws Exception {
428421
contractAddress,
429422
ABI,
430423
"_bytesV",
431-
Lists.newArrayList());
424+
new ArrayList<>());
432425
Assert.assertEquals(0, callResponse4.getReturnCode());
433426
}
434427
}
@@ -439,24 +432,22 @@ public void test8ComplexSetBytesFuture() throws Exception {
439432
TransactionProcessorFactory.createAssembleTransactionProcessor(
440433
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
441434
// deploy
442-
List<Object> params = Lists.newArrayList();
435+
List<Object> params = new ArrayList<>();
443436
params.add(1);
444437
params.add("test2");
445438
TransactionResponse response =
446439
transactionProcessor.deployByContractLoader("ComplexSol", params);
447440
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
448441
String contractAddress = response.getContractAddress();
449-
List<Object> paramsSetBytes = Lists.newArrayList("2".getBytes());
442+
List<Object> paramsSetBytes = Collections.singletonList("2".getBytes());
450443
byte[] data = transactionProcessor.encodeFunction(ABI, "setBytes", paramsSetBytes);
451444
TxPair txPair =
452445
transactionProcessor.createSignedTransaction(
453446
contractAddress, data, this.cryptoKeyPair, 0);
454447
CompletableFuture<TransactionReceipt> future =
455448
transactionProcessor.sendTransactionAsync(txPair.getSignedTx());
456449
future.thenAccept(
457-
r -> {
458-
Assert.assertEquals(0, response.getTransactionReceipt().getStatus());
459-
});
450+
r -> Assert.assertEquals(0, response.getTransactionReceipt().getStatus()));
460451

461452
TxPair txPair0 =
462453
transactionProcessor.createSignedTransaction(
@@ -475,7 +466,7 @@ public void test9ComplexSetStaticBytes() throws Exception {
475466
TransactionProcessorFactory.createAssembleTransactionProcessor(
476467
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
477468
// deploy
478-
List<Object> params = Lists.newArrayList();
469+
List<Object> params = new ArrayList<>();
479470
params.add(1);
480471
params.add("test2");
481472
TransactionResponse response =
@@ -485,7 +476,7 @@ public void test9ComplexSetStaticBytes() throws Exception {
485476

486477
// setStaticByte4 in hex
487478
{
488-
List<String> paramsSetBytes = Lists.newArrayList("hex://0x12345678");
479+
List<String> paramsSetBytes = Collections.singletonList("hex://0x12345678");
489480
TransactionResponse transactionResponse3 =
490481
transactionProcessor.sendTransactionWithStringParamsAndGetResponse(
491482
contractAddress, ABI, "setStaticByte4", paramsSetBytes);
@@ -498,7 +489,7 @@ public void test9ComplexSetStaticBytes() throws Exception {
498489
contractAddress,
499490
ABI,
500491
"_bytes4V",
501-
Lists.newArrayList());
492+
new ArrayList<>());
502493
Assert.assertEquals(0, callResponse4.getReturnCode());
503494
Assert.assertEquals(
504495
Hex.toHexString((byte[]) callResponse4.getResults().get(0).getValue()),
@@ -514,7 +505,7 @@ public void test10EventDemo() throws Exception {
514505
String contractAddress = null;
515506
// deploy
516507
{
517-
List<Object> params = Lists.newArrayList();
508+
List<Object> params = new ArrayList<>();
518509
TransactionResponse response =
519510
transactionProcessor.deployByContractLoader("EventSubDemo", params);
520511
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
@@ -561,13 +552,13 @@ public void test11CallWithSign() throws Exception {
561552
TransactionProcessorFactory.createAssembleTransactionProcessor(
562553
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
563554

564-
if(client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_4_0.toVersionObj()) < 0){
555+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_4_0.toVersionObj()) < 0) {
565556
return;
566557
}
567558
String contractAddress = null;
568559
// deploy
569560
{
570-
List<Object> params = Lists.newArrayList();
561+
List<Object> params = new ArrayList<>();
571562
TransactionResponse response =
572563
transactionProcessor.deployByContractLoader("TestCallWithSign", params);
573564
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);

src/integration-test/java/org/fisco/bcos/sdk/v3/test/transaction/manager/AssembleTransactionWithRemoteSignProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
package org.fisco.bcos.sdk.v3.test.transaction.manager;
1616

17-
import com.google.common.collect.Lists;
1817
import java.util.ArrayList;
18+
import java.util.Collections;
1919
import java.util.List;
2020
import java.util.concurrent.CompletableFuture;
2121
import org.apache.commons.lang3.StringUtils;
@@ -48,7 +48,7 @@ public class AssembleTransactionWithRemoteSignProcessorTest {
4848
"src/integration-test/resources/" + ConstantConfig.CONFIG_FILE_NAME;
4949
private static final String abiFile = "src/integration-test/resources/abi/";
5050
private static final String binFile = "src/integration-test/resources/bin/";
51-
private List<Object> params = Lists.newArrayList("test");
51+
private List<Object> params = new ArrayList<>(Collections.singletonList("test"));
5252
// prepare sdk, read from the config file
5353
private BcosSDK sdk = BcosSDK.build(configFile);
5454
// set the group number 1

0 commit comments

Comments
 (0)