From 7e4e8aa7dd622fb71cfe1422459a3c8e26363875 Mon Sep 17 00:00:00 2001
From: Jun Luo <4catcode@gmail.com>
Date: Tue, 26 Mar 2024 18:25:11 +0800
Subject: [PATCH] Fix compilation warnings. (#579)
---
.../org/stellar/sdk/AbstractTransaction.java | 25 ++++++--
.../org/stellar/sdk/AllowTrustOperation.java | 1 +
src/main/java/org/stellar/sdk/Operation.java | 1 +
src/main/java/org/stellar/sdk/Price.java | 5 +-
.../java/org/stellar/sdk/Transaction.java | 2 +
.../stellar/sdk/requests/ResponseHandler.java | 5 +-
.../requests/TooManyRequestsException.java | 2 +-
.../sdk/responses/EffectDeserializer.java | 1 +
.../sdk/responses/OperationDeserializer.java | 1 +
.../TrustlineAuthorizedEffectResponse.java | 1 +
...edToMaintainLiabilitiesEffectResponse.java | 1 +
.../TrustlineDeauthorizedEffectResponse.java | 1 +
.../AllowTrustOperationResponse.java | 1 +
src/test/java/org/stellar/sdk/MemoTest.java | 2 +-
.../java/org/stellar/sdk/OperationTest.java | 4 +-
.../stellar/sdk/TransactionBuilderTest.java | 6 +-
.../sdk/responses/EffectDeserializerTest.java | 23 ++++---
.../responses/FeeStatsDeserializerTest.java | 62 +++++++++----------
.../responses/OfferPageDeserializerTest.java | 8 +--
.../responses/OperationDeserializerTest.java | 13 ++--
.../SubmitTransactionResponseTest.java | 4 +-
.../TransactionDeserializerTest.java | 12 ++--
.../sdk/xdr/TransactionDecodeTest.java | 4 +-
23 files changed, 111 insertions(+), 74 deletions(-)
diff --git a/src/main/java/org/stellar/sdk/AbstractTransaction.java b/src/main/java/org/stellar/sdk/AbstractTransaction.java
index a958fa294..092718e07 100644
--- a/src/main/java/org/stellar/sdk/AbstractTransaction.java
+++ b/src/main/java/org/stellar/sdk/AbstractTransaction.java
@@ -63,17 +63,29 @@ public void sign(byte @NonNull [] preimage) {
signatures.add(decoratedSignature);
}
- /** Returns transaction hash. */
+ /**
+ * Returns transaction hash.
+ *
+ * @return the transaction hash
+ */
public byte[] hash() {
return Util.hash(this.signatureBase());
}
- /** Returns transaction hash encoded as a hexadecimal string. */
+ /**
+ * Returns transaction hash encoded as a hexadecimal string.
+ *
+ * @return the transaction hash as a hexadecimal string
+ */
public String hashHex() {
return Util.bytesToHex(this.hash()).toLowerCase();
}
- /** Returns signature base. */
+ /**
+ * Returns signature base.
+ *
+ * @return the signature base
+ */
public abstract byte[] signatureBase();
/**
@@ -99,6 +111,8 @@ public void addSignature(DecoratedSignature signature) {
/**
* Returns base64-encoded TransactionEnvelope XDR object. Transaction need to have at least one
* signature.
+ *
+ * @return the base64-encoded TransactionEnvelope XDR object.
*/
public String toEnvelopeXdrBase64() {
try {
@@ -112,7 +126,9 @@ public String toEnvelopeXdrBase64() {
* Creates a AbstractTransaction
instance from previously build
* TransactionEnvelope
*
+ * @param accountConverter the {@link AccountConverter} to use for this transaction
* @param envelope the transaction envelope
+ * @param network the network that the transaction is to be submitted to
* @return the {@link Transaction} or {@link FeeBumpTransaction} instance
*/
public static AbstractTransaction fromEnvelopeXdr(
@@ -136,6 +152,7 @@ public static AbstractTransaction fromEnvelopeXdr(
* TransactionEnvelope
*
* @param envelope the transaction envelope
+ * @param network the network that the transaction is to be submitted to
* @return the {@link Transaction} or {@link FeeBumpTransaction} instance
*/
public static AbstractTransaction fromEnvelopeXdr(TransactionEnvelope envelope, Network network) {
@@ -173,7 +190,7 @@ public static AbstractTransaction fromEnvelopeXdr(String envelope, Network netwo
* Get the signature base of this transaction envelope.
*
* @param taggedTransaction the tagged transaction for signing
- * @param network the network to sign on
+ * @param network the network that the transaction is to be submitted to
* @return the signature base of this transaction envelope
*/
public static byte[] getTransactionSignatureBase(
diff --git a/src/main/java/org/stellar/sdk/AllowTrustOperation.java b/src/main/java/org/stellar/sdk/AllowTrustOperation.java
index b003c407e..d414993bc 100644
--- a/src/main/java/org/stellar/sdk/AllowTrustOperation.java
+++ b/src/main/java/org/stellar/sdk/AllowTrustOperation.java
@@ -14,6 +14,7 @@
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor(access = lombok.AccessLevel.PRIVATE)
+@Deprecated
public class AllowTrustOperation extends Operation {
/** The account of the recipient of the trustline. */
diff --git a/src/main/java/org/stellar/sdk/Operation.java b/src/main/java/org/stellar/sdk/Operation.java
index 21a1944a8..a36dafb22 100644
--- a/src/main/java/org/stellar/sdk/Operation.java
+++ b/src/main/java/org/stellar/sdk/Operation.java
@@ -63,6 +63,7 @@ public String toXdrBase64() {
*
* @param xdr XDR object
*/
+ @SuppressWarnings("deprecation")
public static Operation fromXdr(
AccountConverter accountConverter, org.stellar.sdk.xdr.Operation xdr) {
org.stellar.sdk.xdr.Operation.OperationBody body = xdr.getBody();
diff --git a/src/main/java/org/stellar/sdk/Price.java b/src/main/java/org/stellar/sdk/Price.java
index 39ea10d4d..c1b945325 100644
--- a/src/main/java/org/stellar/sdk/Price.java
+++ b/src/main/java/org/stellar/sdk/Price.java
@@ -3,6 +3,7 @@
import com.google.gson.annotations.SerializedName;
import java.math.BigDecimal;
import java.math.MathContext;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import lombok.EqualsAndHashCode;
@@ -59,7 +60,7 @@ public static Price fromString(@NonNull String price) {
if (number.compareTo(maxInt) > 0) {
break;
}
- a = number.setScale(0, BigDecimal.ROUND_FLOOR);
+ a = number.setScale(0, RoundingMode.FLOOR);
f = number.subtract(a);
BigDecimal h = a.multiply(fractions.get(i - 1)[0]).add(fractions.get(i - 2)[0]);
BigDecimal k = a.multiply(fractions.get(i - 1)[1]).add(fractions.get(i - 2)[1]);
@@ -70,7 +71,7 @@ public static Price fromString(@NonNull String price) {
if (f.compareTo(BigDecimal.ZERO) == 0) {
break;
}
- number = new BigDecimal(1).divide(f, 20, BigDecimal.ROUND_HALF_UP);
+ number = new BigDecimal(1).divide(f, 20, RoundingMode.HALF_UP);
i = i + 1;
}
BigDecimal n = fractions.get(fractions.size() - 1)[0];
diff --git a/src/main/java/org/stellar/sdk/Transaction.java b/src/main/java/org/stellar/sdk/Transaction.java
index 99b95b94b..72c7fa0ea 100644
--- a/src/main/java/org/stellar/sdk/Transaction.java
+++ b/src/main/java/org/stellar/sdk/Transaction.java
@@ -317,7 +317,9 @@ public TransactionEnvelope toEnvelopeXdr() {
* @see org.stellar.sdk.TransactionBuilder
* @deprecated will be removed in upcoming releases. Use TransactionBuilder
instead.
*/
+ @Deprecated
public static class Builder extends TransactionBuilder {
+ // TODO: remove this class in the next release
public Builder(
AccountConverter accountConverter,
TransactionBuilderAccount sourceAccount,
diff --git a/src/main/java/org/stellar/sdk/requests/ResponseHandler.java b/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
index cdbd25fcc..f171dbdb7 100644
--- a/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
+++ b/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
@@ -6,9 +6,10 @@
import org.stellar.sdk.responses.GsonSingleton;
import org.stellar.sdk.responses.TypedResponse;
+@SuppressWarnings("unchecked")
public class ResponseHandler {
- private TypeToken type;
+ private final TypeToken type;
/**
* "Generics on a type are typically erased at runtime, except when the type is compiled with the
@@ -50,7 +51,7 @@ public T handleResponse(final Response response) throws IOException, TooManyRequ
((org.stellar.sdk.responses.Response) object).setHeaders(response.headers());
}
if (object instanceof TypedResponse) {
- ((TypedResponse) object).setType(type);
+ ((TypedResponse) object).setType(type);
}
return object;
} finally {
diff --git a/src/main/java/org/stellar/sdk/requests/TooManyRequestsException.java b/src/main/java/org/stellar/sdk/requests/TooManyRequestsException.java
index 32095aa3d..1ebc93996 100644
--- a/src/main/java/org/stellar/sdk/requests/TooManyRequestsException.java
+++ b/src/main/java/org/stellar/sdk/requests/TooManyRequestsException.java
@@ -12,7 +12,7 @@ public class TooManyRequestsException extends RuntimeException {
private final Integer retryAfter;
public TooManyRequestsException(Integer retryAfter) {
- super("The rate limit for the requesting IP address is over its alloted limit.");
+ super("The rate limit for the requesting IP address is over its allowed limit.");
this.retryAfter = retryAfter;
}
diff --git a/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java
index d4c324ecc..b4206eb65 100644
--- a/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java
+++ b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java
@@ -15,6 +15,7 @@
class EffectDeserializer implements JsonDeserializer {
@Override
+ @SuppressWarnings("deprecation")
public EffectResponse deserialize(
JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
diff --git a/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java
index 3d644acec..478359bbe 100644
--- a/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java
+++ b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java
@@ -18,6 +18,7 @@ class OperationDeserializer implements JsonDeserializer {
private static final OperationType[] AllOperationTypes = OperationType.values();
@Override
+ @SuppressWarnings("deprecation")
public OperationResponse deserialize(
JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
diff --git a/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
index 2a8ba8f1c..f12646e76 100644
--- a/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
@@ -13,6 +13,7 @@
*/
@Value
@EqualsAndHashCode(callSuper = true)
+@Deprecated
public class TrustlineAuthorizedEffectResponse extends TrustlineAuthorizationResponse {
TrustlineAuthorizedEffectResponse(String trustor, String assetType, String assetCode) {
super(trustor, assetType, assetCode);
diff --git a/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedToMaintainLiabilitiesEffectResponse.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedToMaintainLiabilitiesEffectResponse.java
index 4fa45187c..f89e78a4c 100644
--- a/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedToMaintainLiabilitiesEffectResponse.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedToMaintainLiabilitiesEffectResponse.java
@@ -13,6 +13,7 @@
*/
@Value
@EqualsAndHashCode(callSuper = true)
+@Deprecated
public class TrustlineAuthorizedToMaintainLiabilitiesEffectResponse
extends TrustlineAuthorizationResponse {
TrustlineAuthorizedToMaintainLiabilitiesEffectResponse(
diff --git a/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
index 4eee723e5..e5afabc1b 100644
--- a/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
@@ -13,6 +13,7 @@
*/
@Value
@EqualsAndHashCode(callSuper = true)
+@Deprecated
public class TrustlineDeauthorizedEffectResponse extends TrustlineAuthorizationResponse {
TrustlineDeauthorizedEffectResponse(String trustor, String assetType, String assetCode) {
super(trustor, assetType, assetCode);
diff --git a/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
index 28f2b2050..66b866d13 100644
--- a/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
@@ -21,6 +21,7 @@
*/
@Value
@EqualsAndHashCode(callSuper = true)
+@Deprecated
public class AllowTrustOperationResponse extends OperationResponse {
@SerializedName("trustor")
String trustor;
diff --git a/src/test/java/org/stellar/sdk/MemoTest.java b/src/test/java/org/stellar/sdk/MemoTest.java
index 133c5aea6..d0e9336b6 100644
--- a/src/test/java/org/stellar/sdk/MemoTest.java
+++ b/src/test/java/org/stellar/sdk/MemoTest.java
@@ -72,7 +72,7 @@ public void testMemoId() {
public void testParseMemoId() {
String maxId = "18446744073709551615";
JsonElement element =
- new JsonParser().parse(String.format("{ \"memo_type\": \"id\", \"memo\": \"%s\" }", maxId));
+ JsonParser.parseString(String.format("{ \"memo_type\": \"id\", \"memo\": \"%s\" }", maxId));
TransactionResponse transactionResponse =
new TransactionDeserializer().deserialize(element, null, null);
MemoId memoId = (MemoId) transactionResponse.getMemo();
diff --git a/src/test/java/org/stellar/sdk/OperationTest.java b/src/test/java/org/stellar/sdk/OperationTest.java
index 4da709a56..490c0918e 100644
--- a/src/test/java/org/stellar/sdk/OperationTest.java
+++ b/src/test/java/org/stellar/sdk/OperationTest.java
@@ -425,6 +425,7 @@ public void testChangeTrustOperation() throws FormatException, IOException {
}
@Test
+ @SuppressWarnings("deprecation")
public void testAllowTrustOperation() throws IOException, FormatException {
// GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
KeyPair source =
@@ -456,6 +457,7 @@ public void testAllowTrustOperation() throws IOException, FormatException {
}
@Test
+ @SuppressWarnings("deprecation")
public void testAllowTrustOperationAssetCodeBuffer() throws IOException, FormatException {
// GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
KeyPair source =
@@ -603,7 +605,7 @@ public void testSetOptionsOperationSignerSha256() {
assertEquals(null, parsedOperation.getHighThreshold());
assertEquals(null, parsedOperation.getHomeDomain());
assertTrue(Arrays.equals(hash, parsedOperation.getSigner().getHashX().getUint256()));
- assertEquals(new Integer(10), parsedOperation.getSignerWeight());
+ assertEquals(10, parsedOperation.getSignerWeight().intValue());
assertEquals(source.getAccountId(), parsedOperation.getSourceAccount());
assertEquals(
diff --git a/src/test/java/org/stellar/sdk/TransactionBuilderTest.java b/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
index 3139abb35..e114fe7ec 100644
--- a/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
@@ -269,7 +269,7 @@ public void testBuilderTimeoutNegative() throws IOException {
fail();
} catch (RuntimeException exception) {
assertTrue(exception.getMessage().contains("timeout cannot be negative"));
- assertEquals(new Long(2908908335136768L), account.getSequenceNumber());
+ assertEquals(2908908335136768L, account.getSequenceNumber().longValue());
}
}
@@ -579,7 +579,7 @@ public void testBuilderFailsWhenNoTimeBoundsOrTimeoutSet() throws IOException {
fail();
} catch (RuntimeException exception) {
assertTrue(exception.getMessage().contains("Invalid preconditions, must define timebounds"));
- assertEquals(new Long(2908908335136768L), account.getSequenceNumber());
+ assertEquals(2908908335136768L, account.getSequenceNumber().longValue());
}
}
@@ -831,7 +831,7 @@ public void testNoOperations() throws FormatException, IOException {
fail();
} catch (RuntimeException exception) {
assertTrue(exception.getMessage().contains("At least one operation required"));
- assertEquals(new Long(2908908335136768L), account.getSequenceNumber());
+ assertEquals(2908908335136768L, account.getSequenceNumber().longValue());
}
}
diff --git a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
index d1303f1a5..e7c848dee 100644
--- a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
@@ -241,9 +241,9 @@ public void testDeserializeAccountThresholdsUpdatedEffect() {
GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getLowThreshold(), new Integer(2));
- assertEquals(effect.getMedThreshold(), new Integer(3));
- assertEquals(effect.getHighThreshold(), new Integer(4));
+ assertEquals(effect.getLowThreshold().intValue(), 2);
+ assertEquals(effect.getMedThreshold().intValue(), 3);
+ assertEquals(effect.getHighThreshold().intValue(), 4);
assertEquals(
effect.getLinks().getOperation().getHref(),
@@ -326,8 +326,8 @@ public void testDeserializeAccountFlagsUpdatedEffect() {
GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getAuthRequiredFlag(), new Boolean(false));
- assertEquals(effect.getAuthRevokableFlag(), new Boolean(true));
+ assertEquals(effect.getAuthRequiredFlag(), Boolean.FALSE);
+ assertEquals(effect.getAuthRevokableFlag(), Boolean.TRUE);
assertEquals(
effect.getLinks().getOperation().getHref(),
@@ -491,7 +491,7 @@ public void testDeserializeSignerCreatedEffect() {
GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
assertEquals(effect.getAccount(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU");
- assertEquals(effect.getWeight(), new Integer(1));
+ assertEquals(effect.getWeight().intValue(), 1);
assertEquals(effect.getPublicKey(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU");
assertEquals(
@@ -534,7 +534,7 @@ public void testDeserializeSignerRemovedEffect() {
GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
assertEquals(effect.getAccount(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6");
- assertEquals(effect.getWeight(), new Integer(0));
+ assertEquals(effect.getWeight().intValue(), 0);
assertEquals(effect.getPublicKey(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6");
assertEquals(
@@ -577,7 +577,7 @@ public void testDeserializeSignerUpdatedEffect() {
GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getWeight(), new Integer(2));
+ assertEquals(effect.getWeight().intValue(), 2);
assertEquals(effect.getPublicKey(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(
@@ -844,6 +844,7 @@ public void testDeserializeLiquidityPoolTrustlineUpdatedEffect() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeTrustlineAuthorizedEffect() {
String json =
"{\n"
@@ -889,6 +890,7 @@ public void testDeserializeTrustlineAuthorizedEffect() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeTrustlineAuthorizedToMaintainLiabilitiesEffect() {
String json =
"{\n"
@@ -934,6 +936,7 @@ public void testDeserializeTrustlineAuthorizedToMaintainLiabilitiesEffect() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeTrustlineDeauthorizedEffect() {
String json =
"{\n"
@@ -1015,7 +1018,7 @@ public void testDeserializeTradeEffect() {
assertEquals(effect.getAccount(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getSeller(), "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB");
- assertEquals(effect.getOfferId(), new Long(1));
+ assertEquals(effect.getOfferId().longValue(), 1);
assertEquals(effect.getSoldAmount(), "1000.0");
assertEquals(
effect.getSoldAsset(),
@@ -1159,7 +1162,7 @@ public void testDeserializeSequenceBumpedEffect() {
assertEquals(effect.getAccount(), "GDPFGP4IPE5DXG6XRXC4ZBUI43PAGRQ5VVNJ3LJTBXDBZ4ITO6HBHNSF");
assertEquals(effect.getCreatedAt(), "2018-06-06T10:23:57Z");
- assertEquals(effect.getNewSequence(), new Long(79473726952833048L));
+ assertEquals(effect.getNewSequence().longValue(), 79473726952833048L);
}
@Test
diff --git a/src/test/java/org/stellar/sdk/responses/FeeStatsDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/FeeStatsDeserializerTest.java
index 9060826e6..78099ed31 100644
--- a/src/test/java/org/stellar/sdk/responses/FeeStatsDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/FeeStatsDeserializerTest.java
@@ -46,40 +46,40 @@ public void testDeserialize() {
+ "}";
FeeStatsResponse stats = GsonSingleton.getInstance().fromJson(json, FeeStatsResponse.class);
- assertEquals(new Long(22606298), stats.getLastLedger());
- assertEquals(new Long(100), stats.getLastLedgerBaseFee());
- assertEquals(new Float(0.97), stats.getLedgerCapacityUsage());
+ assertEquals(22606298, stats.getLastLedger().longValue());
+ assertEquals(100, stats.getLastLedgerBaseFee().longValue());
+ assertEquals(0.97F, stats.getLedgerCapacityUsage());
FeeDistribution maxFee = stats.getMaxFee();
- assertEquals(new Long(130), maxFee.getMin());
- assertEquals(new Long(8000), maxFee.getMax());
- assertEquals(new Long(250), maxFee.getMode());
- assertEquals(new Long(150), maxFee.getP10());
- assertEquals(new Long(200), maxFee.getP20());
- assertEquals(new Long(300), maxFee.getP30());
- assertEquals(new Long(400), maxFee.getP40());
- assertEquals(new Long(500), maxFee.getP50());
- assertEquals(new Long(1000), maxFee.getP60());
- assertEquals(new Long(2000), maxFee.getP70());
- assertEquals(new Long(3000), maxFee.getP80());
- assertEquals(new Long(4000), maxFee.getP90());
- assertEquals(new Long(5000), maxFee.getP95());
- assertEquals(new Long(8000), maxFee.getP99());
+ assertEquals(130, maxFee.getMin().longValue());
+ assertEquals(8000, maxFee.getMax().longValue());
+ assertEquals(250, maxFee.getMode().longValue());
+ assertEquals(150, maxFee.getP10().longValue());
+ assertEquals(200, maxFee.getP20().longValue());
+ assertEquals(300, maxFee.getP30().longValue());
+ assertEquals(400, maxFee.getP40().longValue());
+ assertEquals(500, maxFee.getP50().longValue());
+ assertEquals(1000, maxFee.getP60().longValue());
+ assertEquals(2000, maxFee.getP70().longValue());
+ assertEquals(3000, maxFee.getP80().longValue());
+ assertEquals(4000, maxFee.getP90().longValue());
+ assertEquals(5000, maxFee.getP95().longValue());
+ assertEquals(8000, maxFee.getP99().longValue());
FeeDistribution feeCharged = stats.getFeeCharged();
- assertEquals(new Long(100), feeCharged.getMin());
- assertEquals(new Long(102), feeCharged.getMax());
- assertEquals(new Long(101), feeCharged.getMode());
- assertEquals(new Long(103), feeCharged.getP10());
- assertEquals(new Long(104), feeCharged.getP20());
- assertEquals(new Long(105), feeCharged.getP30());
- assertEquals(new Long(106), feeCharged.getP40());
- assertEquals(new Long(107), feeCharged.getP50());
- assertEquals(new Long(108), feeCharged.getP60());
- assertEquals(new Long(109), feeCharged.getP70());
- assertEquals(new Long(110), feeCharged.getP80());
- assertEquals(new Long(111), feeCharged.getP90());
- assertEquals(new Long(112), feeCharged.getP95());
- assertEquals(new Long(113), feeCharged.getP99());
+ assertEquals(100, feeCharged.getMin().longValue());
+ assertEquals(102, feeCharged.getMax().longValue());
+ assertEquals(101, feeCharged.getMode().longValue());
+ assertEquals(103, feeCharged.getP10().longValue());
+ assertEquals(104, feeCharged.getP20().longValue());
+ assertEquals(105, feeCharged.getP30().longValue());
+ assertEquals(106, feeCharged.getP40().longValue());
+ assertEquals(107, feeCharged.getP50().longValue());
+ assertEquals(108, feeCharged.getP60().longValue());
+ assertEquals(109, feeCharged.getP70().longValue());
+ assertEquals(110, feeCharged.getP80().longValue());
+ assertEquals(111, feeCharged.getP90().longValue());
+ assertEquals(112, feeCharged.getP95().longValue());
+ assertEquals(113, feeCharged.getP99().longValue());
}
}
diff --git a/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java
index 6336b6936..3c622a607 100644
--- a/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/OfferPageDeserializerTest.java
@@ -13,7 +13,7 @@ public void testDeserialize() {
GsonSingleton.getInstance()
.fromJson(json, new TypeToken>() {}.getType());
- assertEquals(offerPage.getRecords().get(0).getId(), new Long(241));
+ assertEquals(offerPage.getRecords().get(0).getId().longValue(), 241);
assertEquals(
offerPage.getRecords().get(0).getSeller(),
"GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD");
@@ -28,7 +28,7 @@ public void testDeserialize() {
assertEquals(offerPage.getRecords().get(0).getPrice(), "11.0000000");
assertEquals(offerPage.getRecords().get(0).getPriceR().getDenominator().longValue(), 1);
assertEquals(offerPage.getRecords().get(0).getPriceR().getNumerator().longValue(), 10);
- assertEquals(offerPage.getRecords().get(0).getLastModifiedLedger(), new Integer(22200794));
+ assertEquals(offerPage.getRecords().get(0).getLastModifiedLedger().intValue(), 22200794);
assertEquals(offerPage.getRecords().get(0).getLastModifiedTime(), "2019-01-28T12:30:38Z");
assertFalse(offerPage.getRecords().get(0).getSponsor().isPresent());
@@ -49,7 +49,7 @@ public void testDeserializeWithSponsor() {
GsonSingleton.getInstance()
.fromJson(withSponsor, new TypeToken>() {}.getType());
- assertEquals(offerPage.getRecords().get(0).getId(), new Long(241));
+ assertEquals(offerPage.getRecords().get(0).getId().longValue(), 241);
assertEquals(
offerPage.getRecords().get(0).getSeller(),
"GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD");
@@ -62,7 +62,7 @@ public void testDeserializeWithSponsor() {
create(null, "USD", "GA2IYMIZSAMDD6QQTTSIEL73H2BKDJQTA7ENDEEAHJ3LMVF7OYIZPXQD"));
assertEquals(offerPage.getRecords().get(0).getAmount(), "10.0000000");
assertEquals(offerPage.getRecords().get(0).getPrice(), "11.0000000");
- assertEquals(offerPage.getRecords().get(0).getLastModifiedLedger(), new Integer(22200794));
+ assertEquals(offerPage.getRecords().get(0).getLastModifiedLedger().intValue(), 22200794);
assertEquals(offerPage.getRecords().get(0).getLastModifiedTime(), "2019-01-28T12:30:38Z");
assertEquals(
offerPage.getRecords().get(0).getSponsor().get(),
diff --git a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
index a79de3c91..acdd22aca 100644
--- a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
@@ -338,6 +338,7 @@ public void testDeserializeMuxedPaymentOperation() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeAllowTrustOperation() {
String json =
"{\n"
@@ -389,6 +390,7 @@ public void testDeserializeAllowTrustOperation() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeMuxedAllowTrustOperation() {
String json =
"{\n"
@@ -443,6 +445,7 @@ public void testDeserializeMuxedAllowTrustOperation() {
}
@Test
+ @SuppressWarnings("deprecation")
public void testDeserializeAllowTrustOperationAuthorizeToMaintainLiabilities() {
String json =
"{\n"
@@ -692,15 +695,15 @@ public void testDeserializeSetOptionsOperation() {
operation.getSignerKey(), "GD3ZYXVC7C3ECD5I4E5NGPBFJJSULJ6HJI2FBHGKYFV34DSIWB4YEKJZ");
assertEquals(
operation.getSignerKey(), "GD3ZYXVC7C3ECD5I4E5NGPBFJJSULJ6HJI2FBHGKYFV34DSIWB4YEKJZ");
- assertEquals(operation.getSignerWeight(), new Integer(1));
+ assertEquals(operation.getSignerWeight().intValue(), 1);
assertEquals(operation.getHomeDomain(), "stellar.org");
assertEquals(
operation.getInflationDestination(),
"GBYWSY4NPLLPTP22QYANGTT7PEHND64P4D4B6LFEUHGUZRVYJK2H4TBE");
- assertEquals(operation.getLowThreshold(), new Integer(1));
- assertEquals(operation.getMedThreshold(), new Integer(2));
- assertEquals(operation.getHighThreshold(), new Integer(3));
- assertEquals(operation.getMasterKeyWeight(), new Integer(4));
+ assertEquals(operation.getLowThreshold().intValue(), 1);
+ assertEquals(operation.getMedThreshold().intValue(), 2);
+ assertEquals(operation.getHighThreshold().intValue(), 3);
+ assertEquals(operation.getMasterKeyWeight().intValue(), 4);
assertEquals(operation.getSetFlags()[0], "auth_required_flag");
assertEquals(operation.getClearFlags()[0], "auth_revocable_flag");
}
diff --git a/src/test/java/org/stellar/sdk/responses/SubmitTransactionResponseTest.java b/src/test/java/org/stellar/sdk/responses/SubmitTransactionResponseTest.java
index fd059dd00..cdfb7eaa0 100644
--- a/src/test/java/org/stellar/sdk/responses/SubmitTransactionResponseTest.java
+++ b/src/test/java/org/stellar/sdk/responses/SubmitTransactionResponseTest.java
@@ -140,14 +140,14 @@ public void testDeserializeSuccessResponse() throws IOException {
assertEquals(
submitTransactionResponse.getHash(),
"ee14b93fcd31d4cfe835b941a0a8744e23a6677097db1fafe0552d8657bed940");
- assertEquals(submitTransactionResponse.getLedger(), new Long(3128812));
+ assertEquals(submitTransactionResponse.getLedger().longValue(), 3128812);
assertEquals(
submitTransactionResponse.getEnvelopeXdr().get(),
"AAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAZAAT3TUAAAAwAAAAAAAAAAAAAAABAAAAAAAAAAMAAAABSU5SAAAAAAA0jDEZkBgx+hCc5IIv+z6CoaYTB8jRkIA6drZUv3YRlwAAAAFVU0QAAAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAAAX14QAAAAAKAAAAAQAAAAAAAAAAAAAAAAAAAAG/dhGXAAAAQLuStfImg0OeeGAQmvLkJSZ1MPSkCzCYNbGqX5oYNuuOqZ5SmWhEsC7uOD9ha4V7KengiwNlc0oMNqBVo22S7gk=");
assertEquals(
submitTransactionResponse.getResultXdr().get(),
"AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAAAAAAPEAAAABSU5SAAAAAAA0jDEZkBgx+hCc5IIv+z6CoaYTB8jRkIA6drZUv3YRlwAAAAFVU0QAAAAAADSMMRmQGDH6EJzkgi/7PoKhphMHyNGQgDp2tlS/dhGXAAAAAAX14QAAAAAKAAAAAQAAAAAAAAAAAAAAAA==");
- assertEquals(submitTransactionResponse.getOfferIdFromResult(0).get(), new Long(241));
+ assertEquals(submitTransactionResponse.getOfferIdFromResult(0).get().longValue(), 241);
TransactionResult transactionResult =
submitTransactionResponse.getDecodedTransactionResult().get();
assertEquals(transactionResult.getResult().getDiscriminant(), TransactionResultCode.txSUCCESS);
diff --git a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
index b58f7b334..8815cd1d3 100644
--- a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
@@ -54,18 +54,18 @@ public void testDeserialize() {
transaction.getId(), "5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b");
assertEquals(
transaction.getHash(), "5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b");
- assertEquals(transaction.getLedger(), new Long(915744));
+ assertEquals(transaction.getLedger().longValue(), 915744);
assertEquals(transaction.getCreatedAt(), "2015-11-20T17:01:28Z");
assertEquals(transaction.getPagingToken(), "3933090531512320");
- assertEquals(transaction.isSuccessful(), new Boolean(true));
+ assertEquals(transaction.isSuccessful(), Boolean.TRUE);
assertEquals(
transaction.getSourceAccount(), "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK");
assertFalse(transaction.getSourceAccountMuxed().isPresent());
assertFalse(transaction.getFeeAccountMuxed().isPresent());
- assertEquals(transaction.getSourceAccountSequence(), new Long(2373051035426646L));
- assertEquals(transaction.getMaxFee(), new Long(200));
- assertEquals(transaction.getFeeCharged(), new Long(100));
- assertEquals(transaction.getOperationCount(), new Integer(1));
+ assertEquals(transaction.getSourceAccountSequence().longValue(), 2373051035426646L);
+ assertEquals(transaction.getMaxFee().longValue(), 200);
+ assertEquals(transaction.getFeeCharged().longValue(), 100);
+ assertEquals(transaction.getOperationCount().intValue(), 1);
assertEquals(
transaction.getEnvelopeXdr(),
"AAAAAKgfpXwD1fWpPmZL+GkzWcBmhRQH7ouPsoTN3RoaGCfrAAAAZAAIbkcAAB9WAAAAAAAAAANRBBZE6D1qyGjISUGLY5Ldvp31PwAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAP1qe44j+i4uIT+arbD4QDQBt8ryEeJd7a0jskQ3nwDeAAAAAAAAAADA7RnarSzCwj3OT+M2btCMFpVBdqxJS+Sr00qBjtFv7gAAAABLCs/QAAAAAAAAAAEaGCfrAAAAQG/56Cj2J8W/KCZr+oC4sWND1CTGWfaccHNtuibQH8kZIb+qBSDY94g7hiaAXrlIeg9b7oz/XuP3x9MWYw2jtwM=");
diff --git a/src/test/java/org/stellar/sdk/xdr/TransactionDecodeTest.java b/src/test/java/org/stellar/sdk/xdr/TransactionDecodeTest.java
index 9951c2704..e57b141a6 100644
--- a/src/test/java/org/stellar/sdk/xdr/TransactionDecodeTest.java
+++ b/src/test/java/org/stellar/sdk/xdr/TransactionDecodeTest.java
@@ -19,8 +19,8 @@ public void testDecodeTxBody() throws IOException {
TransactionEnvelope transactionEnvelope = TransactionEnvelope.fromXdrBase64(txBody);
assertEquals(
- new Long(2373025265623291L),
- transactionEnvelope.getV0().getTx().getSeqNum().getSequenceNumber().getInt64());
+ 2373025265623291L,
+ transactionEnvelope.getV0().getTx().getSeqNum().getSequenceNumber().getInt64().longValue());
}
@Test