From c7d1276b5634a87bd910b12677d484c5a6164f1b Mon Sep 17 00:00:00 2001 From: Philip Liu <12836897+philipliu@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:52:26 -0400 Subject: [PATCH] [ANCHOR-634] Bump Java SDK version to 0.43.0 (#1289) ### Description This bumps the Java SDK version from 0.42.0 to 0.43.0. This is an attempt to resolve an issue with the payment observer getting stuck on unparsable payment operations. Bumping the SDK version required bumping the Kotlin to 1.9 and `ktfmt` versions, which is why the lines changed are so large. ### Context ``` 19:54:54.694 ERROR - o.s.a.p.p.o.s.StellarPaymentObserver - stellar payment observer stream error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: "problem" at com.google.gson.Gson.fromJson(Gson.java:1238) at com.google.gson.Gson.fromJson(Gson.java:1137) at com.google.gson.Gson.fromJson(Gson.java:1047) at com.google.gson.Gson.fromJson(Gson.java:982) at org.stellar.sdk.requests.SSEStream$StellarEventSourceListener.onEvent(SSEStream.java:257) at ``` ### Testing - `./gradlew test` ### Documentation N/A ### Known limitations N/A --- .../anchor/api/shared/StellarPaymentTest.kt | 3 +- .../api/shared/StellarTransactionTest.kt | 15 +- build.gradle.kts | 4 +- .../stellar/anchor/sep10/Sep10Service.java | 4 +- .../anchor/sep24/Sep24Transaction.java | 1 + .../anchor/sep24/Sep24TransactionStore.java | 1 + .../kotlin/org/stellar/anchor/TestHelper.kt | 4 +- .../org/stellar/anchor/auth/AuthHelperTest.kt | 2 +- .../org/stellar/anchor/auth/JwtServiceTest.kt | 10 +- .../anchor/dto/sep38/InfoResponseTest.kt | 6 +- .../stellar/anchor/sep10/Sep10ServiceTest.kt | 14 +- .../stellar/anchor/sep24/Sep24ServiceTest.kt | 16 +- .../org/stellar/anchor/sep31/RefundsTest.kt | 6 +- .../stellar/anchor/sep31/Sep31HelperTest.kt | 3 +- .../stellar/anchor/sep31/Sep31ServiceTest.kt | 52 +-- .../sep31/Sep31TransactionBuilderTest.kt | 2 +- .../anchor/sep31/Sep31TransactionTest.kt | 8 +- .../stellar/anchor/sep38/Sep38ServiceTest.kt | 427 +++++++++--------- .../util/ExponentialBackoffTimerTest.kt | 6 +- .../org/stellar/anchor/util/MathHelperTest.kt | 2 +- .../org/stellar/anchor/util/OkHttpUtilTest.kt | 1 + .../anchor/util/SepLanguageHelperTest.kt | 3 +- gradle/libs.versions.toml | 8 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../stellar/anchor/platform/Sep10Client.kt | 8 +- .../stellar/anchor/platform/Sep12Client.kt | 2 +- .../stellar/anchor/platform/Sep38Client.kt | 4 +- .../org/stellar/anchor/platform/SepClient.kt | 5 +- .../platform/AnchorPlatformIntegrationTest.kt | 22 +- .../platform/ApiKeyAuthIntegrationTest.kt | 21 +- .../stellar/anchor/platform/PlatformTests.kt | 6 +- .../anchor/platform/RestFeeIntegrationTest.kt | 72 ++- .../platform/RestRateIntegrationTest.kt | 187 ++++---- .../org/stellar/anchor/platform/Sep10Tests.kt | 8 +- .../org/stellar/anchor/platform/Sep24Tests.kt | 2 +- .../org/stellar/anchor/platform/Sep31Tests.kt | 2 +- .../org/stellar/anchor/platform/Sep38Tests.kt | 8 +- .../stellar/anchor/platform/SepTestSuite.kt | 6 +- .../CirclePaymentObserverController.java | 4 +- .../platform/controller/Sep10Controller.java | 8 +- .../platform/controller/Sep38Controller.java | 1 + .../platform/payment/common/Balance.java | 1 + .../platform/payment/common/Payment.java | 1 + .../circle/CirclePaymentObserverService.java | 8 +- .../circle/CirclePaymentServiceTest.kt | 335 +++++++------- .../circle/StellarReconciliationTest.kt | 6 +- .../model/CircleTransferSerializationTest.kt | 24 +- .../anchor/platform/LogAppenderTest.kt | 3 +- .../anchor/platform/PaymentConfigTest.kt | 80 ++-- .../callback/PlatformIntegrationHelperTest.kt | 2 +- .../callback/RestCustomerIntegrationTest.kt | 15 +- .../anchor/platform/config/Sep38ConfigTest.kt | 1 + .../platform/data/JdbcSep31TransactionTest.kt | 6 +- .../CirclePaymentObserverServiceTest.kt | 126 +++--- .../PaymentObservingAccountsManagerTest.kt | 12 +- .../PaymentOperationToEventListenerTest.kt | 28 +- .../service/TransactionServiceTest.kt | 14 +- .../sep31/Sep31DepositInfoGeneratorTest.kt | 24 +- 58 files changed, 807 insertions(+), 845 deletions(-) diff --git a/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarPaymentTest.kt b/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarPaymentTest.kt index 31c7aed3eb..2805195882 100644 --- a/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarPaymentTest.kt +++ b/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarPaymentTest.kt @@ -97,7 +97,8 @@ class StellarPaymentTest { "source_account": "GAS4OW4HKJCC2D6VWUHVFR3MJRRVQBXBFQ3LCZJXBR7TWOOBJWE4SRWZ", "destination_account": "GBQC7NCZMQIPWN6ASUJYIDKDPRK34IOIZNQE5WOHPQH536VMOMQVJTN7" } - """.trimIndent() + """ + .trimIndent() val actual = mapper.writeValueAsString(mockPayment1) JSONAssert.assertEquals(expected, actual, true) diff --git a/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarTransactionTest.kt b/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarTransactionTest.kt index 2dbc90efa9..634e80f4b9 100644 --- a/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarTransactionTest.kt +++ b/api-schema/src/test/kotlin/org/stellar/anchor/api/shared/StellarTransactionTest.kt @@ -53,7 +53,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment1)) - .build() + .build(), ) val wantTxList = @@ -95,7 +95,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment1)) - .build() + .build(), ) val wantTxList = @@ -133,7 +133,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment1)) - .build() + .build(), ) val wantTxList = @@ -175,7 +175,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment2, mockPayment3)) - .build() + .build(), ) val wantTxList = @@ -221,7 +221,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment3)) - .build() + .build(), ) val wantTxList = @@ -245,7 +245,7 @@ class StellarTransactionTest { .createdAt(createdAt) .envelope("here_comes_the_envelope") .payments(listOf(mockPayment3)) - .build() + .build(), ) assertEquals(wantTxList, txList) @@ -279,7 +279,8 @@ class StellarTransactionTest { "memo_type": "text", "created_at": 1690415946.788000000 } - """.trimIndent() + """ + .trimIndent() val actual = mapper.writeValueAsString( StellarTransaction.builder() diff --git a/build.gradle.kts b/build.gradle.kts index 349955ae02..db6e1a708d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -53,7 +53,7 @@ subprojects { googleJavaFormat() } - kotlin { ktfmt("0.30").googleStyle() } + kotlin { ktfmt("0.47").googleStyle() } } dependencies { @@ -118,7 +118,7 @@ subprojects { allprojects { group = "org.stellar.anchor-sdk" - version = "1.2.24" + version = "1.2.25" tasks.jar { manifest { diff --git a/core/src/main/java/org/stellar/anchor/sep10/Sep10Service.java b/core/src/main/java/org/stellar/anchor/sep10/Sep10Service.java index 3b1dc2942b..ded56375e8 100644 --- a/core/src/main/java/org/stellar/anchor/sep10/Sep10Service.java +++ b/core/src/main/java/org/stellar/anchor/sep10/Sep10Service.java @@ -175,7 +175,9 @@ public ChallengeResponse createChallenge(ChallengeRequest challengeRequest) thro } public ValidationResponse validateChallenge(ValidationRequest validationRequest) - throws IOException, InvalidSep10ChallengeException, URISyntaxException, + throws IOException, + InvalidSep10ChallengeException, + URISyntaxException, SepValidationException { if (validationRequest == null || validationRequest.getTransaction() == null) { throw new SepValidationException("{transaction} is required."); diff --git a/core/src/main/java/org/stellar/anchor/sep24/Sep24Transaction.java b/core/src/main/java/org/stellar/anchor/sep24/Sep24Transaction.java index 33e7ca4f85..fc863decf9 100644 --- a/core/src/main/java/org/stellar/anchor/sep24/Sep24Transaction.java +++ b/core/src/main/java/org/stellar/anchor/sep24/Sep24Transaction.java @@ -233,6 +233,7 @@ public interface Sep24Transaction { String getAmountOutAsset(); void setAmountOutAsset(String amountOutAsset); + /** * Amount of fee charged by anchor. * diff --git a/core/src/main/java/org/stellar/anchor/sep24/Sep24TransactionStore.java b/core/src/main/java/org/stellar/anchor/sep24/Sep24TransactionStore.java index 14ec9ac29c..74bc47b109 100644 --- a/core/src/main/java/org/stellar/anchor/sep24/Sep24TransactionStore.java +++ b/core/src/main/java/org/stellar/anchor/sep24/Sep24TransactionStore.java @@ -46,6 +46,7 @@ public interface Sep24TransactionStore { */ List findTransactions( String accountId, String accountMemo, GetTransactionsRequest request) throws SepException; + /** * Save a transaction. * diff --git a/core/src/test/kotlin/org/stellar/anchor/TestHelper.kt b/core/src/test/kotlin/org/stellar/anchor/TestHelper.kt index b57b43b4d3..f027229bb2 100644 --- a/core/src/test/kotlin/org/stellar/anchor/TestHelper.kt +++ b/core/src/test/kotlin/org/stellar/anchor/TestHelper.kt @@ -13,7 +13,7 @@ class TestHelper { account: String = TEST_ACCOUNT, accountMemo: String? = null, hostUrl: String = "", - clientDomain: String = "vibrant.stellar.org" + clientDomain: String = "vibrant.stellar.org", ): JwtToken { val issuedAt: Long = System.currentTimeMillis() / 1000L return JwtToken.of( @@ -22,7 +22,7 @@ class TestHelper { issuedAt, issuedAt + 60, "", - clientDomain + clientDomain, ) } } diff --git a/core/src/test/kotlin/org/stellar/anchor/auth/AuthHelperTest.kt b/core/src/test/kotlin/org/stellar/anchor/auth/AuthHelperTest.kt index 9f5534d6e2..ce9755789d 100644 --- a/core/src/test/kotlin/org/stellar/anchor/auth/AuthHelperTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/auth/AuthHelperTest.kt @@ -40,7 +40,7 @@ class AuthHelperTest { JwtToken.of( "http://localhost:8080", currentTimeMilliseconds / 1000L, - (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L + (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L, ) val jwtService = JwtService("secret") diff --git a/core/src/test/kotlin/org/stellar/anchor/auth/JwtServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/auth/JwtServiceTest.kt index 40b825cbe4..5d4d201b44 100644 --- a/core/src/test/kotlin/org/stellar/anchor/auth/JwtServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/auth/JwtServiceTest.kt @@ -29,15 +29,7 @@ internal class JwtServiceTest { every { appConfig.jwtSecretKey } returns "jwt_secret" val jwtService = JwtService(appConfig) - val token = - JwtToken.of( - TEST_ISS, - TEST_SUB, - TEST_IAT, - TEST_EXP, - TEST_JTI, - TEST_CLIENT_DOMAIN, - ) + val token = JwtToken.of(TEST_ISS, TEST_SUB, TEST_IAT, TEST_EXP, TEST_JTI, TEST_CLIENT_DOMAIN) val cipher = jwtService.encode(token) val dt = jwtService.decode(cipher) diff --git a/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt b/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt index 61a58ccb63..4daff4d9ab 100644 --- a/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/dto/sep38/InfoResponseTest.kt @@ -63,19 +63,19 @@ class InfoResponseTest { val wantSellDeliveryMethod = AssetInfo.Sep38Operation.DeliveryMethod( "WIRE", - "Send USD directly to the Anchor's bank account." + "Send USD directly to the Anchor's bank account.", ) assertEquals(listOf(wantSellDeliveryMethod), fiatUSD.sellDeliveryMethods) val wantBuyDeliveryMethod = AssetInfo.Sep38Operation.DeliveryMethod( "WIRE", - "Have USD sent directly to your bank account." + "Have USD sent directly to your bank account.", ) assertEquals(listOf(wantBuyDeliveryMethod), fiatUSD.buyDeliveryMethods) wantAssets = listOf( "stellar:JPYC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", - "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" + "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", ) assertTrue(fiatUSD.exchangeableAssetNames.containsAll(wantAssets)) assertTrue(wantAssets.containsAll(fiatUSD.exchangeableAssetNames)) diff --git a/core/src/test/kotlin/org/stellar/anchor/sep10/Sep10ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep10/Sep10ServiceTest.kt index 2c5943b8f1..d16bfbab56 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep10/Sep10ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep10/Sep10ServiceTest.kt @@ -54,7 +54,7 @@ internal class TestSigner( @SerializedName("key") val key: String, @SerializedName("type") val type: String, @SerializedName("weight") val weight: Int, - @SerializedName("sponsor") val sponsor: String + @SerializedName("sponsor") val sponsor: String, ) { fun toSigner(): AccountResponse.Signer { val gson = GsonUtils.getInstance() @@ -181,7 +181,7 @@ internal class Sep10ServiceTest { val transaction = TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET) - .addTimeBounds(TimeBounds.expiresAfter(900)) + .setTimeout(900) .setBaseFee(100) .addOperation(op1DomainNameMandatory) .addOperation(op2WebAuthDomainMandatory) @@ -272,7 +272,7 @@ internal class Sep10ServiceTest { val transaction = TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET) - .addTimeBounds(TimeBounds.expiresAfter(900)) + .setTimeout(900) .setBaseFee(100) .addOperation(op1DomainNameMandatory) .addOperation(op2WebAuthDomainMandatory) @@ -345,7 +345,7 @@ internal class Sep10ServiceTest { val transaction = TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET) - .addTimeBounds(TimeBounds.expiresAfter(900)) + .setTimeout(900) .setBaseFee(100) .addOperation(op1DomainNameMandatory) .addOperation(op2WebAuthDomainMandatory) @@ -396,7 +396,7 @@ internal class Sep10ServiceTest { any(), any(), any(), - any() + any(), ) } } @@ -415,7 +415,7 @@ internal class Sep10ServiceTest { TimeBounds(now, now + 900), clientDomain, if (clientDomain.isEmpty()) "" else clientDomainKeyPair.accountId, - memo + memo, ) txn.sign(clientKeyPair) if (clientDomain.isNotEmpty() && signWithClientDomain) { @@ -448,7 +448,7 @@ internal class Sep10ServiceTest { val signers = arrayOf( TestSigner(clientKeyPair.accountId, "ed25519_public_key", 1, "").toSigner(), - TestSigner(clientDomainKeyPair.accountId, "ed25519_public_key", 1, "").toSigner() + TestSigner(clientDomainKeyPair.accountId, "ed25519_public_key", 1, "").toSigner(), ) every { accountResponse.signers } returns signers diff --git a/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt index ff57c11251..5065035874 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt @@ -110,7 +110,7 @@ internal class Sep24ServiceTest { assertEquals(slotTxn.captured.assetCode, "USDC") assertEquals( slotTxn.captured.assetIssuer, - "GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP" + "GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", ) assertEquals(slotTxn.captured.sep10Account, TEST_ACCOUNT) assertEquals(slotTxn.captured.fromAccount, TEST_ACCOUNT) @@ -135,10 +135,7 @@ internal class Sep24ServiceTest { assertEquals(tokenStrings.size, 1) tokenString = tokenStrings[0].value decodedToken = jwtService.decode(tokenString) - assertEquals( - "$TEST_ACCOUNT:$TEST_MEMO", - decodedToken.sub, - ) + assertEquals("$TEST_ACCOUNT:$TEST_MEMO", decodedToken.sub) assertEquals(TEST_CLIENT_DOMAIN, decodedToken.clientDomain) } @@ -151,7 +148,7 @@ internal class Sep24ServiceTest { "amount" to "123.4", "email_address" to "jamie@stellar.org", "first_name" to "Jamie", - "last_name" to "Li" + "last_name" to "Li", ) } @@ -249,10 +246,7 @@ internal class Sep24ServiceTest { assertEquals(tokenStrings.size, 1) val tokenString = tokenStrings[0].value val decodedToken = jwtService.decode(tokenString) - assertEquals( - "$TEST_ACCOUNT:$TEST_MEMO", - decodedToken.sub, - ) + assertEquals("$TEST_ACCOUNT:$TEST_MEMO", decodedToken.sub) assertEquals(TEST_CLIENT_DOMAIN, decodedToken.clientDomain) } @@ -354,7 +348,7 @@ internal class Sep24ServiceTest { 10, "2021-12-20T19:30:58+00:00", "1", - "en-US" + "en-US", ) sep24Service.findTransactions(createJwtToken(), gtr) } diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/RefundsTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/RefundsTest.kt index deee947e50..09cf5b6462 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/RefundsTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/RefundsTest.kt @@ -69,7 +69,7 @@ class RefundsTest { .id("B") .amount("50") .fee("4") - .build() + .build(), ) ) .build() @@ -118,7 +118,7 @@ class RefundsTest { .fee(Amount("4", stellarUSDC)) .refundedAt(null) .refundedAt(null) - .build() + .build(), ) ) .build() @@ -152,7 +152,7 @@ class RefundsTest { .fee(Amount("4", stellarUSDC)) .refundedAt(Instant.now()) .refundedAt(Instant.now()) - .build() + .build(), ) ) .build() diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31HelperTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31HelperTest.kt index 41e9c63f91..e23f42edf6 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31HelperTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31HelperTest.kt @@ -38,7 +38,8 @@ class Sep31HelperTest { "pending_sender", "completed", "expired", - "error"] + "error", + ] ) fun `test validate status`(status: String) { val txn = PojoSep31Transaction() diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt index 3010eefa72..7cb8a8fd54 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31ServiceTest.kt @@ -351,9 +351,7 @@ class Sep31ServiceTest { @Test fun `test quotes supported and required validation`() { val assetServiceQuotesNotSupported: AssetService = - ResourceJsonAssetService( - "test_assets.json.quotes_required_but_not_supported", - ) + ResourceJsonAssetService("test_assets.json.quotes_required_but_not_supported") val ex: AnchorException = assertThrows { Sep31Service( appConfig, @@ -368,10 +366,7 @@ class Sep31ServiceTest { ) } assertInstanceOf(SepValidationException::class.java, ex) - assertEquals( - "if quotes_required is true, quotes_supported must also be true", - ex.message, - ) + assertEquals("if quotes_required is true, quotes_supported must also be true", ex.message) } @Test @@ -611,7 +606,7 @@ class Sep31ServiceTest { assertInstanceOf(Sep31CustomerInfoNeededException::class.java, ex) assertEquals( "[sep31-receiver, sep31-foreign-receiver]", - (ex as Sep31CustomerInfoNeededException).type + (ex as Sep31CustomerInfoNeededException).type, ) // receiver status is not ACCEPTED @@ -625,7 +620,7 @@ class Sep31ServiceTest { assertInstanceOf(Sep31CustomerInfoNeededException::class.java, ex) assertEquals( "[sep31-receiver, sep31-foreign-receiver]", - (ex as Sep31CustomerInfoNeededException).type + (ex as Sep31CustomerInfoNeededException).type, ) // missing sender_id @@ -641,7 +636,7 @@ class Sep31ServiceTest { assertInstanceOf(Sep31CustomerInfoNeededException::class.java, ex) assertEquals( "[sep31-sender, sep31-large-sender, sep31-foreign-sender]", - (ex as Sep31CustomerInfoNeededException).type + (ex as Sep31CustomerInfoNeededException).type, ) // sender status is not ACCEPTED @@ -655,7 +650,7 @@ class Sep31ServiceTest { assertInstanceOf(Sep31CustomerInfoNeededException::class.java, ex) assertEquals( "[sep31-sender, sep31-large-sender, sep31-foreign-sender]", - (ex as Sep31CustomerInfoNeededException).type + (ex as Sep31CustomerInfoNeededException).type, ) // ----- QUOTE_ID IS USED ⬇️ ----- @@ -742,7 +737,7 @@ class Sep31ServiceTest { "receiver_account_number" to "1", "type" to "1", "receiver_routing_number" to "SWIFT", - ), + ) ) // Make sure we can get the sender and receiver customers @@ -826,7 +821,8 @@ class Sep31ServiceTest { "creator": { "account": "GBJDSMTMG4YBP27ZILV665XBISBBNRP62YB7WZA2IQX2HIPK7ABLF4C2" } - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantTx, gotTx, true) // validate event response @@ -858,13 +854,13 @@ class Sep31ServiceTest { .customers( Customers( StellarId.builder().id(senderId).build(), - StellarId.builder().id(receiverId).build() + StellarId.builder().id(receiverId).build(), ) ) .creator( StellarId.builder() .account("GBJDSMTMG4YBP27ZILV665XBISBBNRP62YB7WZA2IQX2HIPK7ABLF4C2") - .build(), + .build() ) .build() assertEquals(wantEvent, txEventSlot.captured) @@ -897,7 +893,7 @@ class Sep31ServiceTest { "receiver_account_number" to "1", "type" to "1", "receiver_routing_number" to "SWIFT", - ), + ) ) // Make sure we can get the sender and receiver customers @@ -943,7 +939,7 @@ class Sep31ServiceTest { "receiver_account_number" to "1", "type" to "1", "receiver_routing_number" to "SWIFT", - ), + ) ) // Make sure we can get the sender and receiver customers @@ -991,9 +987,7 @@ class Sep31ServiceTest { } val assetServiceQuotesNotSupported: AssetService = - ResourceJsonAssetService( - "test_assets.json.quotes_not_supported", - ) + ResourceJsonAssetService("test_assets.json.quotes_not_supported") sep31Service = Sep31Service( appConfig, @@ -1021,17 +1015,11 @@ class Sep31ServiceTest { "receiver_account_number" to "1", "type" to "1", "receiver_routing_number" to "SWIFT", - ), + ) ) // Provide fee response. - every { feeIntegration.getFee(any()) } returns - GetFeeResponse( - Amount( - "2", - "stellar:USDC", - ), - ) + every { feeIntegration.getFee(any()) } returns GetFeeResponse(Amount("2", "stellar:USDC")) // Make sure we can get the sender and receiver customers val mockCustomer = Sep12GetCustomerResponse() @@ -1056,12 +1044,14 @@ class Sep31ServiceTest { val jpycJson = """ {"enabled":true,"quotes_supported":true,"quotes_required":true,"fee_fixed":0,"fee_percent":0,"min_amount":1,"max_amount":1000000,"sep12":{"sender":{"types":{"sep31-sender":{"description":"Japanese citizens"}}},"receiver":{"types":{"sep31-receiver":{"description":"Japanese citizens receiving USD"}}}},"fields":{"transaction":{"receiver_routing_number":{"description":"routing number of the destination bank account","optional":false},"receiver_account_number":{"description":"bank account number of the destination","optional":false},"type":{"description":"type of deposit to make","choices":["ACH","SWIFT","WIRE"],"optional":false}}}} - """.trimIndent() + """ + .trimIndent() val usdcJson = """ {"enabled":true,"quotes_supported":true,"quotes_required":true,"fee_fixed":0,"fee_percent":0,"min_amount":1,"max_amount":1000000,"sep12":{"sender":{"types":{"sep31-sender":{"description":"U.S. citizens limited to sending payments of less than ${'$'}10,000 in value"},"sep31-large-sender":{"description":"U.S. citizens that do not have sending limits"},"sep31-foreign-sender":{"description":"non-U.S. citizens sending payments of less than ${'$'}10,000 in value"}}},"receiver":{"types":{"sep31-receiver":{"description":"U.S. citizens receiving USD"},"sep31-foreign-receiver":{"description":"non-U.S. citizens receiving USD"}}}},"fields":{"transaction":{"receiver_routing_number":{"description":"routing number of the destination bank account","optional":false},"receiver_account_number":{"description":"bank account number of the destination","optional":false},"type":{"description":"type of deposit to make","choices":["SEPA","SWIFT"],"optional":false}}}} - """.trimIndent() + """ + .trimIndent() @Test fun `test INFO response`() { @@ -1102,7 +1092,7 @@ class Sep31ServiceTest { "type" to AssetInfo.Sep31TxnFieldSpec("type of deposit to make", listOf("SEPA", "SWIFT"), false), "receiver_routing_number" to - AssetInfo.Sep31TxnFieldSpec("routing number of the destination bank account", null, false) + AssetInfo.Sep31TxnFieldSpec("routing number of the destination bank account", null, false), ) assertEquals(wantMissingFields, ex4.missingFields) diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionBuilderTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionBuilderTest.kt index 5cabfefeba..965f977963 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionBuilderTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionBuilderTest.kt @@ -31,7 +31,7 @@ class Sep31TransactionBuilderTest { .id("aa762cda-a193-4961-861e-57b31fed6eb3") .amount("20") .fee("1") - .build()) + .build()), ) val refunds = diff --git a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionTest.kt index b88fd2639a..4d69abc300 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep31/Sep31TransactionTest.kt @@ -71,7 +71,7 @@ class Sep31TransactionTest { mockMissingFields.transaction = mapOf( "receiver_account_number" to - AssetInfo.Sep31TxnFieldSpec("bank account number of the destination", null, false), + AssetInfo.Sep31TxnFieldSpec("bank account number of the destination", null, false) ) stellarTransaction = @@ -158,7 +158,7 @@ class Sep31TransactionTest { .fee(Amount("4.0000", fiatUSD)) .requestedAt(null) .refundedAt(null) - .build() + .build(), ) ) .build() @@ -185,7 +185,7 @@ class Sep31TransactionTest { .customers( Customers( StellarId("6c1770b0-0ea4-11ed-861d-0242ac120002", null), - StellarId("31212353-f265-4dba-9eb4-0bbeda3ba7f2", null) + StellarId("31212353-f265-4dba-9eb4-0bbeda3ba7f2", null), ) ) .creator(StellarId("141ee445-f32c-4c38-9d25-f4475d6c5558", null)) @@ -204,7 +204,7 @@ class Sep31TransactionTest { .payments( listOf( Sep31RefundPayment.builder().id("1111").amount("50.0000").fee("4.0000").build(), - Sep31RefundPayment.builder().id("2222").amount("40.0000").fee("4.0000").build() + Sep31RefundPayment.builder().id("2222").amount("40.0000").fee("4.0000").build(), ) ) .build() diff --git a/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt b/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt index c2c7b6fc85..ee1136f391 100644 --- a/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/sep38/Sep38ServiceTest.kt @@ -121,13 +121,13 @@ class Sep38ServiceTest { val wantSellDeliveryMethod = AssetInfo.Sep38Operation.DeliveryMethod( "WIRE", - "Send USD directly to the Anchor's bank account." + "Send USD directly to the Anchor's bank account.", ) assertEquals(listOf(wantSellDeliveryMethod), fiatUSD.sellDeliveryMethods) val wantBuyDeliveryMethod = AssetInfo.Sep38Operation.DeliveryMethod( "WIRE", - "Have USD sent directly to your bank account." + "Have USD sent directly to your bank account.", ) assertEquals(listOf(wantBuyDeliveryMethod), fiatUSD.buyDeliveryMethods) wantAssets = @@ -153,7 +153,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) val token = createJwtToken("GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG") @@ -230,7 +230,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with the minimum parameters @@ -279,7 +279,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with all the parameters @@ -315,7 +315,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with the minimum parameters and specify buy_delivery_method @@ -347,7 +347,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // empty sell_asset @@ -469,7 +469,7 @@ class Sep38ServiceTest { "1.03", "102000000", "100000000", - mockSellAssetFee(fiatUSD) + mockSellAssetFee(fiatUSD), ) ex = assertThrows { sep38Service.getPrice(sep10Token, getPriceRequestBuilder.build()) } assertInstanceOf(BadRequestException::class.java, ex) @@ -507,7 +507,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with the minimum parameters using sellAmount @@ -554,7 +554,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with the minimum parameters using buyAmount @@ -603,7 +603,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with all the parameters using sellAmount @@ -655,7 +655,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // test happy path with all the parameters using buyAmount @@ -698,7 +698,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, null, - null + null, ) // empty sep38QuoteStore should throw an error @@ -713,7 +713,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, quoteStore, - null + null, ) // empty token @@ -734,256 +734,236 @@ class Sep38ServiceTest { assertEquals("sell_asset cannot be empty", ex.message) // nonexistent sell_asset - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder().sellAssetName("foo:bar").build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder().sellAssetName("foo:bar").build(), + ) + } assertInstanceOf(NotFoundException::class.java, ex) assertEquals("sell_asset not found", ex.message) // empty buy_asset - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).build() - ) - } + ex = assertThrows { + sep38Service.postQuote(token, Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).build()) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("buy_asset cannot be empty", ex.message) // nonexistent buy_asset - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).buyAssetName("foo:bar").build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).buyAssetName("foo:bar").build(), + ) + } assertInstanceOf(NotFoundException::class.java, ex) assertEquals("buy_asset not found", ex.message) // both sell_amount & buy_amount are empty - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).buyAssetName(stellarUSDC).build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder().sellAssetName(fiatUSD).buyAssetName(stellarUSDC).build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Please provide either sell_amount or buy_amount", ex.message) // both sell_amount & buy_amount are filled - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("100") - .buyAssetName(stellarUSDC) - .buyAmount("100") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("100") + .buyAssetName(stellarUSDC) + .buyAmount("100") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Please provide either sell_amount or buy_amount", ex.message) // invalid (not a number) sell_amount - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("foo") - .buyAssetName(stellarUSDC) - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("foo") + .buyAssetName(stellarUSDC) + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount is invalid", ex.message) // sell_amount should be positive - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("-0.01") - .buyAssetName(stellarUSDC) - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("-0.01") + .buyAssetName(stellarUSDC) + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount should be positive", ex.message) // sell_amount should be positive - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("0") - .buyAssetName(stellarUSDC) - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("0") + .buyAssetName(stellarUSDC) + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount should be positive", ex.message) // invalid (not a number) buy_amount - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .buyAssetName(stellarUSDC) - .buyAmount("bar") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .buyAssetName(stellarUSDC) + .buyAmount("bar") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("buy_amount is invalid", ex.message) // buy_amount should be positive - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .buyAssetName(stellarUSDC) - .buyAmount("-0.02") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .buyAssetName(stellarUSDC) + .buyAmount("-0.02") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("buy_amount should be positive", ex.message) // buy_amount should be positive - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .buyAssetName(stellarUSDC) - .buyAmount("0") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .buyAssetName(stellarUSDC) + .buyAmount("0") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("buy_amount should be positive", ex.message) // unsupported sell_delivery_method - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("1.23") - .sellDeliveryMethod("FOO") - .buyAssetName(stellarUSDC) - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("1.23") + .sellDeliveryMethod("FOO") + .buyAssetName(stellarUSDC) + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Unsupported sell delivery method", ex.message) // unsupported buy_delivery_method - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("1.23") - .sellDeliveryMethod("WIRE") - .buyAssetName(stellarUSDC) - .buyDeliveryMethod("BAR") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("1.23") + .sellDeliveryMethod("WIRE") + .buyAssetName(stellarUSDC) + .buyDeliveryMethod("BAR") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Unsupported buy delivery method", ex.message) // unsupported country_code - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("1.23") - .sellDeliveryMethod("WIRE") - .buyAssetName(stellarUSDC) - .countryCode("BRA") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("1.23") + .sellDeliveryMethod("WIRE") + .buyAssetName(stellarUSDC) + .countryCode("BRA") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Unsupported country code", ex.message) // unsupported expire_after - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("1.23") - .sellDeliveryMethod("WIRE") - .buyAssetName(stellarUSDC) - .countryCode("USA") - .expireAfter("2022-04-18T23:33:24.629719Z") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("1.23") + .sellDeliveryMethod("WIRE") + .buyAssetName(stellarUSDC) + .countryCode("USA") + .expireAfter("2022-04-18T23:33:24.629719Z") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("Unsupported context. Should be one of [sep6, sep31].", ex.message) // sell_amount should be within limit - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("100000000") - .sellDeliveryMethod("WIRE") - .context(SEP31) - .buyAssetName(stellarUSDC) - .countryCode("USA") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("100000000") + .sellDeliveryMethod("WIRE") + .context(SEP31) + .buyAssetName(stellarUSDC) + .countryCode("USA") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount exceeds max limit", ex.message) // sell_amount should be positive - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellAmount("0.5") - .sellDeliveryMethod("WIRE") - .context(SEP31) - .buyAssetName(stellarUSDC) - .countryCode("USA") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellAmount("0.5") + .sellDeliveryMethod("WIRE") + .context(SEP31) + .buyAssetName(stellarUSDC) + .countryCode("USA") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount less than min limit", ex.message) @@ -994,22 +974,21 @@ class Sep38ServiceTest { "1.03", "102000000", "100000000", - mockSellAssetFee(fiatUSD) + mockSellAssetFee(fiatUSD), ) - ex = - assertThrows { - sep38Service.postQuote( - token, - Sep38PostQuoteRequest.builder() - .sellAssetName(fiatUSD) - .sellDeliveryMethod("WIRE") - .context(SEP31) - .buyAssetName(stellarUSDC) - .buyAmount("100000000") - .countryCode("USA") - .build() - ) - } + ex = assertThrows { + sep38Service.postQuote( + token, + Sep38PostQuoteRequest.builder() + .sellAssetName(fiatUSD) + .sellDeliveryMethod("WIRE") + .context(SEP31) + .buyAssetName(stellarUSDC) + .buyAmount("100000000") + .countryCode("USA") + .build(), + ) + } assertInstanceOf(BadRequestException::class.java, ex) assertEquals("sell_amount exceeds max limit", ex.message) } @@ -1049,7 +1028,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, quoteStore, - eventService + eventService, ) val slotQuote = slot() @@ -1071,7 +1050,7 @@ class Sep38ServiceTest { .sellAssetName(fiatUSD) .sellAmount("103") .buyAssetName(stellarUSDC) - .build() + .build(), ) } val wantResponse = @@ -1182,7 +1161,7 @@ class Sep38ServiceTest { .sellAssetName(fiatUSD) .buyAssetName(stellarUSDC) .buyAmount("100") - .build() + .build(), ) } val wantResponse = @@ -1274,7 +1253,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, quoteStore, - eventService + eventService, ) val slotQuote = slot() @@ -1299,7 +1278,7 @@ class Sep38ServiceTest { .buyAssetName(stellarUSDC) .countryCode("USA") .expireAfter(now.toString()) - .build() + .build(), ) } val wantResponse = @@ -1393,7 +1372,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, quoteStore, - eventService + eventService, ) val slotQuote = slot() @@ -1418,7 +1397,7 @@ class Sep38ServiceTest { .buyAmount("100") .countryCode("USA") .expireAfter(now.toString()) - .build() + .build(), ) } val wantResponse = @@ -1518,7 +1497,7 @@ class Sep38ServiceTest { sep38Service.assetService, mockRateIntegration, quoteStore, - eventService + eventService, ) val slotQuote = slot() @@ -1543,7 +1522,7 @@ class Sep38ServiceTest { .buyAmount(requestBuyAmount) .countryCode("USA") .expireAfter(now.toString()) - .build() + .build(), ) } val wantResponse = diff --git a/core/src/test/kotlin/org/stellar/anchor/util/ExponentialBackoffTimerTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/ExponentialBackoffTimerTest.kt index 0ef3bf505d..e4ada48ef2 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/ExponentialBackoffTimerTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/ExponentialBackoffTimerTest.kt @@ -18,7 +18,7 @@ internal class ExponentialBackoffTimerTest { ex = assertThrows { ExponentialBackoffTimer(1, 0) } assertEquals( "The formula 'maxSleepSeconds >= initialSleepSeconds' is not being respected.", - ex.message + ex.message, ) // constructor with all parameters works @@ -31,11 +31,11 @@ internal class ExponentialBackoffTimerTest { assertDoesNotThrow { exponentialBackoffTimer = ExponentialBackoffTimer() } assertEquals( ExponentialBackoffTimer.DEFAULT_INITIAL_SLEEP_SECONDS, - exponentialBackoffTimer.initialSleepSeconds + exponentialBackoffTimer.initialSleepSeconds, ) assertEquals( ExponentialBackoffTimer.DEFAULT_MAX_SLEEP_SECONDS, - exponentialBackoffTimer.maxSleepSeconds + exponentialBackoffTimer.maxSleepSeconds, ) } diff --git a/core/src/test/kotlin/org/stellar/anchor/util/MathHelperTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/MathHelperTest.kt index b152ce64e8..fbd6b6ec28 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/MathHelperTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/MathHelperTest.kt @@ -30,7 +30,7 @@ class MathHelperTest { assertInstanceOf(NumberFormatException::class.java, ex) assertEquals( "Character a is neither a decimal digit number, decimal point, nor \"e\" notation exponential mark.", - ex.message + ex.message, ) } } diff --git a/core/src/test/kotlin/org/stellar/anchor/util/OkHttpUtilTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/OkHttpUtilTest.kt index daafaaf3e5..a5d949f509 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/OkHttpUtilTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/OkHttpUtilTest.kt @@ -10,6 +10,7 @@ internal class OkHttpUtilTest { val TEST_URL = "https://www.stellar.org" val TEST_JSON = "{}" } + @Test fun `test buildClient() ok`() { val client = OkHttpUtil.buildClient() diff --git a/core/src/test/kotlin/org/stellar/anchor/util/SepLanguageHelperTest.kt b/core/src/test/kotlin/org/stellar/anchor/util/SepLanguageHelperTest.kt index 257494e744..a60b886971 100644 --- a/core/src/test/kotlin/org/stellar/anchor/util/SepLanguageHelperTest.kt +++ b/core/src/test/kotlin/org/stellar/anchor/util/SepLanguageHelperTest.kt @@ -17,6 +17,7 @@ class SepLanguageHelperTest { MockKAnnotations.init(this, relaxUnitFun = true) SepLanguageHelper.reset() } + @Test fun `test validateLanguage()`() { every { appConfig.languages } returns @@ -31,7 +32,7 @@ class SepLanguageHelperTest { "fr-CA", "zh-TW", "zh-CN", - "uk-UA" + "uk-UA", ) Assertions.assertEquals("en", validateLanguage(appConfig, "pt")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 28518d111d..1119d43b01 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ httpclient = "4.5.13" h2database = "1.4.200" hibernate-types = "2.18.0" jackson-dataformat-yaml = "2.13.2" -java-stellar-sdk = "0.42.0" +java-stellar-sdk = "0.43.0" javax-jaxb-api = "2.3.1" javax-transaction-api = "1.3" jjwt = "0.9.1" @@ -25,13 +25,13 @@ junit = "5.8.2" junit-suite-engine = "1.8.2" kafka = "3.1.0" kafka-json-schema = "7.0.1" -kotlin = "1.6.20" +kotlin = "1.9.23" log4j = "2.17.1" log4j-template-json = "2.14.1" lombok = "1.18.22" mockk = "1.12.2" micrometer-prometheus = "1.9.0" -okhttp3 = "4.9.3" +okhttp3 = "4.12.0" postgresql = "42.3.5" reactor-core = "3.4.14" reactor-netty = "1.0.15" @@ -44,7 +44,7 @@ toml4j = "0.7.2" # Plugin versions -spotless = "6.2.1" +spotless = "6.24.0" spring-boot = "2.6.3" spring-dependency-management = "1.0.11.RELEASE" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661ee7..a595206642 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep10Client.kt b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep10Client.kt index a019e85762..6c8f3a3a6d 100644 --- a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep10Client.kt +++ b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep10Client.kt @@ -14,13 +14,13 @@ class Sep10Client( private val endpoint: String, private val serverAccount: String, private val walletAccount: String, - private val signingKeys: Array + private val signingKeys: Array, ) : SepClient() { constructor( endpoint: String, serverAccount: String, walletAccount: String, - signingSeed: String + signingSeed: String, ) : this(endpoint, serverAccount, walletAccount, arrayOf(signingSeed)) fun auth(): String { @@ -41,7 +41,7 @@ class Sep10Client( private fun sign( challengeResponse: ChallengeResponse, signingKeys: Array, - serverAccount: String + serverAccount: String, ): String { val url = URL(endpoint) val webAuthDomain = url.authority @@ -51,7 +51,7 @@ class Sep10Client( serverAccount, Network(challengeResponse.networkPassphrase), webAuthDomain, // TODO: home domain may be different than WEB_AUTH_DOMAIN - webAuthDomain + webAuthDomain, ) for (signingKey in signingKeys) { challengeTransaction.transaction.sign(KeyPair.fromSecretSeed(signingKey)) diff --git a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep12Client.kt b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep12Client.kt index 4685c7f0ea..dc99ff2d5c 100644 --- a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep12Client.kt +++ b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep12Client.kt @@ -31,7 +31,7 @@ class Sep12Client(private val endpoint: String, private val jwt: String) : SepCl fun putCustomer( customerRequest: Sep12PutCustomerRequest, - mediaType: MediaType = TYPE_JSON + mediaType: MediaType = TYPE_JSON, ): Sep12PutCustomerResponse? { val body: RequestBody? when (mediaType) { diff --git a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep38Client.kt b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep38Client.kt index ef15f32256..4ac2108f46 100644 --- a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep38Client.kt +++ b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/Sep38Client.kt @@ -36,7 +36,7 @@ class Sep38Client(private val endpoint: String, private val jwt: String) : SepCl sellAsset: String, sellAmount: String, buyAsset: String, - context: Sep38Context + context: Sep38Context, ): GetPriceResponse { // build URL val urlBuilder = @@ -59,7 +59,7 @@ class Sep38Client(private val endpoint: String, private val jwt: String) : SepCl sellAmount: String, buyAsset: String, context: Sep38Context = SEP31, - expireAfter: Instant? = null + expireAfter: Instant? = null, ): Sep38QuoteResponse { // build URL println("$endpoint/quote") diff --git a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/SepClient.kt b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/SepClient.kt index af1c1f794d..50449868c7 100644 --- a/integration-tests/src/main/kotlin/org/stellar/anchor/platform/SepClient.kt +++ b/integration-tests/src/main/kotlin/org/stellar/anchor/platform/SepClient.kt @@ -56,8 +56,9 @@ open class SepClient { println("statusCode: " + response.code) println("responseBody: $responseBody") when (response.code) { - HttpStatus.OK.value(), HttpStatus.CREATED.value(), HttpStatus.ACCEPTED.value() -> - return responseBody + HttpStatus.OK.value(), + HttpStatus.CREATED.value(), + HttpStatus.ACCEPTED.value() -> return responseBody HttpStatus.FORBIDDEN.value() -> throw SepNotAuthorizedException("Forbidden") HttpStatus.NOT_FOUND.value() -> { val sepException = gson.fromJson(responseBody, SepExceptionResponse::class.java) diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/AnchorPlatformIntegrationTest.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/AnchorPlatformIntegrationTest.kt index 0aebac8494..e8257456fb 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/AnchorPlatformIntegrationTest.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/AnchorPlatformIntegrationTest.kt @@ -47,7 +47,7 @@ class AnchorPlatformIntegrationTest { AuthHelper.forJwtToken( platformToAnchorJwtService, JWT_EXPIRATION_MILLISECONDS, - "http://localhost:$SEP_SERVER_PORT" + "http://localhost:$SEP_SERVER_PORT", ) private lateinit var toml: Sep1Helper.TomlContent @@ -64,7 +64,7 @@ class AnchorPlatformIntegrationTest { "http://localhost:$REFERENCE_SERVER_PORT", httpClient, authHelper, - gson + gson, ) private val rri = RestRateIntegration("http://localhost:$REFERENCE_SERVER_PORT", httpClient, authHelper, gson) @@ -166,7 +166,8 @@ class AnchorPlatformIntegrationTest { "sell_amount": "100", "buy_amount": "98.0392" } - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantBody, gson.toJson(result), true) } @@ -202,14 +203,16 @@ class AnchorPlatformIntegrationTest { ] } } - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantBody, gson.toJson(result), true) } @Test fun testRate_firm() { val rate = - rri.getRate( + rri + .getRate( GetRateRequest.builder() .type(FIRM) .context(SEP31) @@ -265,7 +268,8 @@ class AnchorPlatformIntegrationTest { ] } } - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantBody, gson.toJson(gotQuote), true) } @@ -302,7 +306,7 @@ class AnchorPlatformIntegrationTest { "amount": "0.30" } }""", - true + true, ) } @@ -320,7 +324,7 @@ class AnchorPlatformIntegrationTest { "sep38.quoteIntegrationEndPoint" to "http://localhost:8081", "payment-gateway.circle.name" to "circle", "payment-gateway.circle.enabled" to "true", - "logging.level.root" to "INFO" + "logging.level.root" to "INFO", ) tests.forEach { assertEquals(it.value, platformServerContext.environment[it.key]) } @@ -355,7 +359,7 @@ class AnchorPlatformIntegrationTest { assertEquals(86400, sep10Config.jwtTimeout) assertEquals( "SAX3AH622R2XT6DXWWSRIDCMMUCCMATBZ5U6XKJWDO7M2EJUBFC3AW5X", - sep10Config.signingSeed + sep10Config.signingSeed, ) } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/ApiKeyAuthIntegrationTest.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/ApiKeyAuthIntegrationTest.kt index c12400ac18..cdc5f190ea 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/ApiKeyAuthIntegrationTest.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/ApiKeyAuthIntegrationTest.kt @@ -68,7 +68,7 @@ class ApiKeyAuthIntegrationTest { account: String, accountMemo: String? = null, hostUrl: String = "", - clientDomain: String = "vibrant.stellar.org" + clientDomain: String = "vibrant.stellar.org", ): JwtToken { val issuedAt: Long = System.currentTimeMillis() / 1000L return JwtToken.of( @@ -77,7 +77,7 @@ class ApiKeyAuthIntegrationTest { issuedAt, issuedAt + 60, "", - clientDomain + clientDomain, ) } @@ -110,7 +110,7 @@ class ApiKeyAuthIntegrationTest { PLATFORM_SERVER_PORT, "/", mapOf("stellar.anchor.config" to "file:${newFilePath.toStr()}"), - true + true, ) } @@ -130,7 +130,8 @@ class ApiKeyAuthIntegrationTest { "PATCH,/transactions", "GET,/transactions/my_id", "GET,/exchange/quotes", - "GET,/exchange/quotes/id"] + "GET,/exchange/quotes/id", + ] ) fun test_incomingPlatformAuth_emptyApiKey_authFails(method: String, endpoint: String) { val httpRequest = @@ -151,7 +152,8 @@ class ApiKeyAuthIntegrationTest { "PATCH,/transactions", "GET,/transactions/my_id", "GET,/exchange/quotes", - "GET,/exchange/quotes/id"] + "GET,/exchange/quotes/id", + ] ) fun test_incomingPlatformAuth_apiKey_authPasses(method: String, endpoint: String) { val httpRequest = @@ -183,7 +185,8 @@ class ApiKeyAuthIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() ) ) val sep38Service = platformServerContext.getBean(Sep38Service::class.java) @@ -220,10 +223,8 @@ class ApiKeyAuthIntegrationTest { &sell_amount=100 &buy_asset=stellar%3AUSDC%3AGDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP &client_id=GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG - """.replace( - "\n ", - "" - ) + """ + .replace("\n ", "") MatcherAssert.assertThat(request.path, CoreMatchers.endsWith(wantEndpoint)) assertEquals("", request.body.readUtf8()) } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/PlatformTests.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/PlatformTests.kt index e87160798e..08e928e15d 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/PlatformTests.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/PlatformTests.kt @@ -162,11 +162,11 @@ fun testSep31UnhappyPath() { assertEquals(postTxResponse.id, gotSep31TxResponse.transaction.id) assertEquals( TransactionEvent.Status.PENDING_CUSTOMER_INFO_UPDATE.status, - gotSep31TxResponse.transaction.status + gotSep31TxResponse.transaction.status, ) assertEquals( "The receiving customer clabe_number is invalid!", - gotSep31TxResponse.transaction.requiredInfoMessage + gotSep31TxResponse.transaction.requiredInfoMessage, ) assertNull(gotSep31TxResponse.transaction.completedAt) @@ -206,6 +206,6 @@ fun testSep31UnhappyPath() { assertNull(gotSep31TxResponse.transaction.requiredInfoMessage) assertEquals( patchedTx.completedAt.truncatedTo(SECONDS), - gotSep31TxResponse.transaction.completedAt.truncatedTo(SECONDS) + gotSep31TxResponse.transaction.completedAt.truncatedTo(SECONDS), ) } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestFeeIntegrationTest.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestFeeIntegrationTest.kt index 811902d24b..e3e08cf3d4 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestFeeIntegrationTest.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestFeeIntegrationTest.kt @@ -37,9 +37,10 @@ class RestFeeIntegrationTest { AuthHelper.forJwtToken( platformToAnchorJwtService, JWT_EXPIRATION_MILLISECONDS, - "http://localhost:8080" + "http://localhost:8080", ) } + private lateinit var server: MockWebServer private lateinit var feeIntegration: RestFeeIntegration private lateinit var mockJwtToken: String @@ -54,7 +55,7 @@ class RestFeeIntegrationTest { server.url("").toString(), OkHttpUtil.buildClient(), authHelper, - GsonUtils.getInstance() + GsonUtils.getInstance(), ) // Mock calendar to guarantee the jwt token format @@ -70,7 +71,7 @@ class RestFeeIntegrationTest { JwtToken.of( "http://localhost:8080", currentTimeMilliseconds / 1000L, - (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L + (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L, ) mockJwtToken = platformToAnchorJwtService.encode(jwtToken) } @@ -81,15 +82,8 @@ class RestFeeIntegrationTest { unmockkAll() } - private fun mockGetFeeResponse( - amount: String, - asset: String, - ): MockResponse { - val fee = - hashMapOf( - "amount" to amount, - "asset" to asset, - ) + private fun mockGetFeeResponse(amount: String, asset: String): MockResponse { + val fee = hashMapOf("amount" to amount, "asset" to asset) val bodyMap = hashMapOf("fee" to fee) return MockResponse() @@ -129,40 +123,38 @@ class RestFeeIntegrationTest { &send_amount=10 &client_id=%3Cclient-id%3E &sender_id=%3Csender-id%3E - &receiver_id=%3Creceiver-id%3E""".replace( - "\n ", - "" - ) - ) + &receiver_id=%3Creceiver-id%3E""" + .replace("\n ", "") + ), ) } @Test fun test_getFee_errorHandling() { val validateRequest = - { statusCode: Int, responseBody: String?, wantException: AnchorException -> - // mock response - var mockResponse = - MockResponse().addHeader("Content-Type", "application/json").setResponseCode(statusCode) - if (responseBody != null) mockResponse = mockResponse.setBody(responseBody) - server.enqueue(mockResponse) - - // execute command - val dummyRequest = GetFeeRequest.builder().build() - val ex = assertThrows { feeIntegration.getFee(dummyRequest) } - - // validate exception - assertEquals(wantException.javaClass, ex.javaClass) - assertEquals(wantException.message, ex.message) - - // validateRequest - val request = server.takeRequest() - assertEquals("GET", request.method) - assertEquals("application/json", request.headers["Content-Type"]) - assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) - MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/fee")) - assertEquals("", request.body.readUtf8()) - } + { statusCode: Int, responseBody: String?, wantException: AnchorException -> + // mock response + var mockResponse = + MockResponse().addHeader("Content-Type", "application/json").setResponseCode(statusCode) + if (responseBody != null) mockResponse = mockResponse.setBody(responseBody) + server.enqueue(mockResponse) + + // execute command + val dummyRequest = GetFeeRequest.builder().build() + val ex = assertThrows { feeIntegration.getFee(dummyRequest) } + + // validate exception + assertEquals(wantException.javaClass, ex.javaClass) + assertEquals(wantException.message, ex.message) + + // validateRequest + val request = server.takeRequest() + assertEquals("GET", request.method) + assertEquals("application/json", request.headers["Content-Type"]) + assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) + MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/fee")) + assertEquals("", request.body.readUtf8()) + } // 400 without body validateRequest(400, null, BadRequestException("Bad Request")) diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestRateIntegrationTest.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestRateIntegrationTest.kt index 23f56412db..9c3dfc9ca5 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestRateIntegrationTest.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/RestRateIntegrationTest.kt @@ -40,9 +40,10 @@ class RestRateIntegrationTest { AuthHelper.forJwtToken( platformToAnchorJwtService, JWT_EXPIRATION_MILLISECONDS, - "http://localhost:8080" + "http://localhost:8080", ) } + private lateinit var server: MockWebServer private lateinit var rateIntegration: RestRateIntegration private lateinit var mockJwtToken: String @@ -57,7 +58,7 @@ class RestRateIntegrationTest { server.url("").toString(), OkHttpUtil.buildClient(), authHelper, - GsonUtils.getInstance() + GsonUtils.getInstance(), ) // Mock calendar to guarantee the jwt token format @@ -73,7 +74,7 @@ class RestRateIntegrationTest { JwtToken.of( "http://localhost:8080", currentTimeMilliseconds / 1000L, - (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L + (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L, ) mockJwtToken = platformToAnchorJwtService.encode(jwtToken) } @@ -91,7 +92,7 @@ class RestRateIntegrationTest { totalPrice: String? = null, id: String? = null, fee: RateFee? = null, - expiresAt: String? = null + expiresAt: String? = null, ): MockResponse { val rate = hashMapOf( @@ -144,7 +145,7 @@ class RestRateIntegrationTest { totalPrice = "1.02", id = "my-id", expiresAt = "2022-04-30T02:15:44.000Z", - fee = fee + fee = fee, ) // This is a dummy response, we're not testing its values ) @@ -175,11 +176,9 @@ class RestRateIntegrationTest { &sell_asset=iso4217%3AUSD &sell_amount=100 &sell_delivery_method=WIRE - &country_code=USA""".replace( - "\n ", - "" - ), - getRateRequest + &country_code=USA""" + .replace("\n ", ""), + getRateRequest, ) // getPrice parameters @@ -203,11 +202,9 @@ class RestRateIntegrationTest { &sell_delivery_method=WIRE &buy_asset=stellar%3AUSDC%3AGA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN &buy_delivery_method=CASH - &country_code=USA""".replace( - "\n ", - "" - ), - getRateRequest + &country_code=USA""" + .replace("\n ", ""), + getRateRequest, ) // postQuote parameters @@ -231,11 +228,9 @@ class RestRateIntegrationTest { &sell_delivery_method=WIRE &buy_asset=stellar%3AUSDC%3AGA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN &buy_delivery_method=CASH - &country_code=USA""".replace( - "\n ", - "" - ), - getRateRequest + &country_code=USA""" + .replace("\n ", ""), + getRateRequest, ) // all parameters @@ -265,44 +260,42 @@ class RestRateIntegrationTest { &buy_delivery_method=WIRE &country_code=USA &expire_after=2022-04-30T02%3A15%3A44.000Z - &client_id=GDGWTSQKQQAT2OXRSFLADMN4F6WJQMPJ5MIOKIZ2AMBYUI67MJA4WRLA""".replace( - "\n ", - "" - ), - getRateRequest + &client_id=GDGWTSQKQQAT2OXRSFLADMN4F6WJQMPJ5MIOKIZ2AMBYUI67MJA4WRLA""" + .replace("\n ", ""), + getRateRequest, ) } @Test fun test_getRate_errorHandling() { val validateRequest = - { - statusCode: Int, - responseBody: String?, - wantException: AnchorException, - type: GetRateRequest.Type -> - // mock response - var mockResponse = - MockResponse().addHeader("Content-Type", "application/json").setResponseCode(statusCode) - if (responseBody != null) mockResponse = mockResponse.setBody(responseBody) - server.enqueue(mockResponse) - - // execute command - val dummyRequest = GetRateRequest.builder().type(type).build() - val ex = assertThrows { rateIntegration.getRate(dummyRequest) } - - // validate exception - assertEquals(wantException.javaClass, ex.javaClass) - assertEquals(wantException.message, ex.message) - - // validateRequest - val request = server.takeRequest() - assertEquals("GET", request.method) - assertEquals("application/json", request.headers["Content-Type"]) - assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) - MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/rate?type=$type")) - assertEquals("", request.body.readUtf8()) - } + { + statusCode: Int, + responseBody: String?, + wantException: AnchorException, + type: GetRateRequest.Type -> + // mock response + var mockResponse = + MockResponse().addHeader("Content-Type", "application/json").setResponseCode(statusCode) + if (responseBody != null) mockResponse = mockResponse.setBody(responseBody) + server.enqueue(mockResponse) + + // execute command + val dummyRequest = GetRateRequest.builder().type(type).build() + val ex = assertThrows { rateIntegration.getRate(dummyRequest) } + + // validate exception + assertEquals(wantException.javaClass, ex.javaClass) + assertEquals(wantException.message, ex.message) + + // validateRequest + val request = server.takeRequest() + assertEquals("GET", request.method) + assertEquals("application/json", request.headers["Content-Type"]) + assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) + MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/rate?type=$type")) + assertEquals("", request.body.readUtf8()) + } // 400 without body validateRequest(400, null, BadRequestException("Bad Request"), INDICATIVE_PRICES) @@ -312,7 +305,7 @@ class RestRateIntegrationTest { 400, """{"error": "foo 400"}""", BadRequestException("foo 400"), - INDICATIVE_PRICES + INDICATIVE_PRICES, ) // 404 without body @@ -323,7 +316,7 @@ class RestRateIntegrationTest { 404, """{"error": "foo 404"}""", NotFoundException("foo 404"), - INDICATIVE_PRICES + INDICATIVE_PRICES, ) // 422 without body @@ -334,7 +327,7 @@ class RestRateIntegrationTest { 422, """{"error": "foo 422"}""", BadRequestException("foo 422"), - INDICATIVE_PRICES + INDICATIVE_PRICES, ) // 500 @@ -342,7 +335,7 @@ class RestRateIntegrationTest { 500, """{"error": "foo 500"}""", ServerErrorException("internal server error"), - INDICATIVE_PRICES + INDICATIVE_PRICES, ) // 200 with invalid body @@ -351,7 +344,7 @@ class RestRateIntegrationTest { 200, """{"rate": {"price": "invalid json",}}""", serverErrorException, - INDICATIVE_PRICES + INDICATIVE_PRICES, ) // 200 where getRateResponse is missing "price" @@ -366,13 +359,13 @@ class RestRateIntegrationTest { 200, """{"rate": {"price": "1", "total_price": "1.01"} }""", serverErrorException, - FIRM + FIRM, ) validateRequest( 200, """{"rate": {"price": "1", "total_price": "1.01"} }""", serverErrorException, - INDICATIVE_PRICE + INDICATIVE_PRICE, ) // 200 for type=firm|indicative_price where getRateResponse is missing "total_price" @@ -385,7 +378,8 @@ class RestRateIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() validateRequest(200, body, serverErrorException, FIRM) validateRequest(200, body, serverErrorException, INDICATIVE_PRICE) @@ -400,7 +394,8 @@ class RestRateIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() validateRequest(200, body, serverErrorException, FIRM) // 200 for type=firm where getRateResponse is missing "id" but contains "expires_at" @@ -415,7 +410,8 @@ class RestRateIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() validateRequest(200, body, serverErrorException, FIRM) // 200 for type=firm where getRateResponse is missing "expires_at" @@ -430,7 +426,8 @@ class RestRateIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() validateRequest(200, body, serverErrorException, FIRM) // 200 for type=firm where getRateResponse's "expires_at" is invalid @@ -446,7 +443,8 @@ class RestRateIntegrationTest { "asset": "iso4217:USD" } } - }""".trimMargin() + }""" + .trimMargin() validateRequest(200, body, serverErrorException, FIRM) } @@ -455,29 +453,29 @@ class RestRateIntegrationTest { val fee = mockSellAssetFee("iso4217:USD") val validateRequest = - { type: GetRateRequest.Type, responseBody: String, wantResponse: GetRateResponse -> - // mock response - val mockResponse = - MockResponse() - .addHeader("Content-Type", "application/json") - .setResponseCode(200) - .setBody(responseBody) - server.enqueue(mockResponse) - - // execute command - val dummyRequest = GetRateRequest.builder().type(type).build() - var gotResponse: GetRateResponse? = null - assertDoesNotThrow { gotResponse = rateIntegration.getRate(dummyRequest) } - assertEquals(wantResponse, gotResponse) - - // validateRequest - val request = server.takeRequest() - assertEquals("GET", request.method) - assertEquals("application/json", request.headers["Content-Type"]) - assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) - MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/rate?type=$type")) - assertEquals("", request.body.readUtf8()) - } + { type: GetRateRequest.Type, responseBody: String, wantResponse: GetRateResponse -> + // mock response + val mockResponse = + MockResponse() + .addHeader("Content-Type", "application/json") + .setResponseCode(200) + .setBody(responseBody) + server.enqueue(mockResponse) + + // execute command + val dummyRequest = GetRateRequest.builder().type(type).build() + var gotResponse: GetRateResponse? = null + assertDoesNotThrow { gotResponse = rateIntegration.getRate(dummyRequest) } + assertEquals(wantResponse, gotResponse) + + // validateRequest + val request = server.takeRequest() + assertEquals("GET", request.method) + assertEquals("application/json", request.headers["Content-Type"]) + assertEquals("Bearer $mockJwtToken", request.headers["Authorization"]) + MatcherAssert.assertThat(request.path, CoreMatchers.endsWith("/rate?type=$type")) + assertEquals("", request.body.readUtf8()) + } // indicative_prices quote successful response var wantGetRateResponse = GetRateResponse.indicativePrices("1.02", "102", "100") @@ -489,8 +487,9 @@ class RestRateIntegrationTest { "sell_amount": "102", "buy_amount": "100" } - }""".trimMargin(), - wantGetRateResponse + }""" + .trimMargin(), + wantGetRateResponse, ) // indicative_price quote successful response @@ -514,8 +513,9 @@ class RestRateIntegrationTest { ] } } - }""".trimMargin(), - wantGetRateResponse + }""" + .trimMargin(), + wantGetRateResponse, ) // firm quote @@ -554,8 +554,9 @@ class RestRateIntegrationTest { ] } } - }""".trimMargin(), - wantGetRateResponse + }""" + .trimMargin(), + wantGetRateResponse, ) verify(atLeast = 1) { Instant.now() } } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep10Tests.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep10Tests.kt index c8f09d6d7f..db5be5e2e7 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep10Tests.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep10Tests.kt @@ -20,7 +20,7 @@ fun sep10TestAll(toml: Sep1Helper.TomlContent): String { toml.getString("WEB_AUTH_ENDPOINT"), toml.getString("SIGNING_KEY"), CLIENT_WALLET_ACCOUNT, - CLIENT_WALLET_SECRET + CLIENT_WALLET_SECRET, ) sep10ClientMultiSig = @@ -31,8 +31,8 @@ fun sep10TestAll(toml: Sep1Helper.TomlContent): String { arrayOf( CLIENT_WALLET_SECRET, CLIENT_WALLET_EXTRA_SIGNER_1_SECRET, - CLIENT_WALLET_EXTRA_SIGNER_2_SECRET - ) + CLIENT_WALLET_EXTRA_SIGNER_2_SECRET, + ), ) val jwt = testOk() @@ -55,6 +55,6 @@ fun testUnsignedChallenge() { assertFailsWith( exceptionClass = SepNotAuthorizedException::class, - block = { sep10Client.validate(ValidationRequest.of(challenge.transaction)) } + block = { sep10Client.validate(ValidationRequest.of(challenge.transaction)) }, ) } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep24Tests.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep24Tests.kt index 4d8949dc4b..e511a3c764 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep24Tests.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep24Tests.kt @@ -44,6 +44,6 @@ fun testSep24PostInteractive() { assertFalse(savedTxn.transaction.refunded) assertEquals( "GAIUIZPHLIHQEMNJGSZKCEUWHAZVGUZDBDMO2JXNAJZZZVNSVHQCEWJ4", - savedTxn.transaction.from + savedTxn.transaction.from, ) } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep31Tests.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep31Tests.kt index 77cdd997f9..33403ce785 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep31Tests.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep31Tests.kt @@ -73,7 +73,7 @@ fun testSep31PostAndGetTransaction() { val postTxResponse = sep31Client.postTransaction(txnRequest) assertEquals( "GBN4NNCDGJO4XW4KQU3CBIESUJWFVBUZPOKUZHT7W7WRB7CWOA7BXVQF", - postTxResponse.stellarAccountId + postTxResponse.stellarAccountId, ) // GET Sep31 transaction diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep38Tests.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep38Tests.kt index 108299c349..e7e37d41d7 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep38Tests.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/Sep38Tests.kt @@ -37,7 +37,7 @@ fun sep38TestHappyPath() { "iso4217:USD", "100", "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", - SEP31 + SEP31, ) printResponse(price) @@ -48,7 +48,7 @@ fun sep38TestHappyPath() { "iso4217:USD", "100", "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", - SEP31 + SEP31, ) printResponse(postQuote) @@ -61,7 +61,7 @@ fun sep38TestHappyPath() { "100", "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", SEP31, - expireAfter = expireAfter + expireAfter = expireAfter, ) printResponse(postQuote) @@ -82,7 +82,7 @@ fun testSellOverAssetLimit() { "iso4217:USD", "10000000000", "stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP", - SEP31 + SEP31, ) } } diff --git a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/SepTestSuite.kt b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/SepTestSuite.kt index 286656ce0b..0bd9426c57 100644 --- a/integration-tests/src/test/kotlin/org/stellar/anchor/platform/SepTestSuite.kt +++ b/integration-tests/src/test/kotlin/org/stellar/anchor/platform/SepTestSuite.kt @@ -22,7 +22,7 @@ fun main(args: Array) { "r", "start-anchor-reference-server", false, - "Start anchor reference test server." + "Start anchor reference test server.", ) options.addOption("t", "sep1-toml", true, "The path where the SEP1 TOML file can be read.") val sepTestOptions = @@ -30,7 +30,7 @@ fun main(args: Array) { "p", "tests", false, - "Tests to be performed. One or multiple of [sep1,sep10,sep12,sep24,sep31,ref,platform]" + "Tests to be performed. One or multiple of [sep1,sep10,sep12,sep24,sep31,ref,platform]", ) sepTestOptions.isRequired = true sepTestOptions.args = Option.UNLIMITED_VALUES @@ -103,7 +103,7 @@ fun getOrCreateJwt(tomlContent: TomlContent): String? { issuedAt, issuedAt + 60, "", - null + null, ) jwt = jwtService.encode(token) } diff --git a/platform/src/main/java/org/stellar/anchor/platform/controller/CirclePaymentObserverController.java b/platform/src/main/java/org/stellar/anchor/platform/controller/CirclePaymentObserverController.java index d6102d5677..eca2e1da68 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/controller/CirclePaymentObserverController.java +++ b/platform/src/main/java/org/stellar/anchor/platform/controller/CirclePaymentObserverController.java @@ -53,7 +53,9 @@ public void handleCircleNotificationJson( method = {RequestMethod.POST, RequestMethod.GET, RequestMethod.HEAD}, consumes = {MediaType.TEXT_PLAIN_VALUE}) public void handleCircleNotificationTextPlain(@RequestBody(required = false) String jsonBodyStr) - throws UnprocessableEntityException, BadRequestException, ServerErrorException, + throws UnprocessableEntityException, + BadRequestException, + ServerErrorException, EventPublishException { CircleNotification circleNotification = gson.fromJson(jsonBodyStr, CircleNotification.class); circlePaymentObserverService.handleCircleNotification(circleNotification); diff --git a/platform/src/main/java/org/stellar/anchor/platform/controller/Sep10Controller.java b/platform/src/main/java/org/stellar/anchor/platform/controller/Sep10Controller.java index 105452734e..b1a3e6bf1a 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/controller/Sep10Controller.java +++ b/platform/src/main/java/org/stellar/anchor/platform/controller/Sep10Controller.java @@ -66,7 +66,9 @@ public ChallengeResponse createChallenge( consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}, method = {RequestMethod.POST}) public ValidationResponse validateChallenge(@RequestParam String transaction) - throws InvalidSep10ChallengeException, IOException, URISyntaxException, + throws InvalidSep10ChallengeException, + IOException, + URISyntaxException, SepValidationException { debugF("POST /auth transaction={}", transaction); return validateChallenge(ValidationRequest.of(transaction)); @@ -79,7 +81,9 @@ public ValidationResponse validateChallenge(@RequestParam String transaction) method = {RequestMethod.POST}) public ValidationResponse validateChallenge( @RequestBody(required = false) ValidationRequest validationRequest) - throws InvalidSep10ChallengeException, IOException, URISyntaxException, + throws InvalidSep10ChallengeException, + IOException, + URISyntaxException, SepValidationException { debug("POST /auth details:", validationRequest); return sep10Service.validateChallenge(validationRequest); diff --git a/platform/src/main/java/org/stellar/anchor/platform/controller/Sep38Controller.java b/platform/src/main/java/org/stellar/anchor/platform/controller/Sep38Controller.java index b06856bbf8..956afa6240 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/controller/Sep38Controller.java +++ b/platform/src/main/java/org/stellar/anchor/platform/controller/Sep38Controller.java @@ -33,6 +33,7 @@ public class Sep38Controller { public Sep38Controller(Sep38Service sep38Service) { this.sep38Service = sep38Service; } + // TODO: add integration tests @CrossOrigin(origins = "*") diff --git a/platform/src/main/java/org/stellar/anchor/platform/payment/common/Balance.java b/platform/src/main/java/org/stellar/anchor/platform/payment/common/Balance.java index 7a555625bd..70a1c17906 100644 --- a/platform/src/main/java/org/stellar/anchor/platform/payment/common/Balance.java +++ b/platform/src/main/java/org/stellar/anchor/platform/payment/common/Balance.java @@ -5,6 +5,7 @@ @Data public class Balance { String amount; + /** * The name of the currency that will be ultimately credited into the beneficiary user account. It * should obey the {scheme}:{identifier} format described in ( "id" to "c58e2613-a808-4075-956c-e576787afb3b", "source" to hashMapOf("id" to "1000066041", "type" to "wallet"), - "destination" to - hashMapOf( - "id" to "1000067536", - "type" to "wallet", - ), - "amount" to - hashMapOf( - "amount" to "0.91", - "currency" to "USD", - ), + "destination" to hashMapOf("id" to "1000067536", "type" to "wallet"), + "amount" to hashMapOf("amount" to "0.91", "currency" to "USD"), "status" to "pending", "createDate" to "2022-01-01T01:01:01.544Z", ) @@ -704,7 +696,8 @@ class CirclePaymentServiceTest { "amount": "0.91", "currency": "USD" } - }""".trimIndent() + }""" + .trimIndent() JSONAssert.assertEquals(wantBody, gotBody, false) } @@ -740,7 +733,8 @@ class CirclePaymentServiceTest { "status":"pending", "createDate":"2022-01-01T01:01:01.544Z" } - }""".trimIndent() + }""" + .trimIndent() ) } return MockResponse().setResponseCode(404) @@ -754,7 +748,7 @@ class CirclePaymentServiceTest { PaymentNetwork.STELLAR, "GBG7VGZFH4TU2GS7WL5LMPYFNP64ZFR23XEGAV7GPEEXKWOR2DKCYPCK", "test tag", - Account.Capabilities() + Account.Capabilities(), ) var payment: Payment? = null assertDoesNotThrow { @@ -764,7 +758,7 @@ class CirclePaymentServiceTest { source, destination, "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", - BigDecimal.valueOf(0.91) + BigDecimal.valueOf(0.91), ) .block() } @@ -776,13 +770,13 @@ class CirclePaymentServiceTest { PaymentNetwork.STELLAR, "GBG7VGZFH4TU2GS7WL5LMPYFNP64ZFR23XEGAV7GPEEXKWOR2DKCYPCK", "test tag", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ), - payment?.destinationAccount + payment?.destinationAccount, ) assertEquals( Balance("0.91", "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"), - payment?.balance + payment?.balance, ) assertEquals(Payment.Status.PENDING, payment?.status) assertNull(payment?.errorCode) @@ -794,11 +788,7 @@ class CirclePaymentServiceTest { val wantOriginalResponse = hashMapOf( "id" to "c58e2613-a808-4075-956c-e576787afb3b", - "source" to - hashMapOf( - "id" to "1000066041", - "type" to "wallet", - ), + "source" to hashMapOf("id" to "1000066041", "type" to "wallet"), "destination" to hashMapOf( "address" to "GBG7VGZFH4TU2GS7WL5LMPYFNP64ZFR23XEGAV7GPEEXKWOR2DKCYPCK", @@ -806,11 +796,7 @@ class CirclePaymentServiceTest { "type" to "blockchain", "chain" to "XLM", ), - "amount" to - hashMapOf( - "amount" to "0.91", - "currency" to "USD", - ), + "amount" to hashMapOf("amount" to "0.91", "currency" to "USD"), "status" to "pending", "createDate" to "2022-01-01T01:01:01.544Z", ) @@ -846,7 +832,8 @@ class CirclePaymentServiceTest { "amount": "0.91", "currency": "USD" } - }""".trimIndent() + }""" + .trimIndent() JSONAssert.assertEquals(wantBody, gotBody, false) } @@ -883,7 +870,8 @@ class CirclePaymentServiceTest { "createDate":"2021-11-25T15:43:03.477Z", "updateDate":"2021-11-25T16:10:01.618Z" } - }""".trimIndent() + }""" + .trimIndent() ) } return MockResponse().setResponseCode(404) @@ -897,7 +885,7 @@ class CirclePaymentServiceTest { PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", "test@mail.com", - Account.Capabilities() + Account.Capabilities(), ) var payment: Payment? = null assertDoesNotThrow { @@ -913,9 +901,9 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ), - payment?.destinationAccount + payment?.destinationAccount, ) assertEquals(Balance("0.91", "iso4217:USD"), payment?.balance) assertEquals(Payment.Status.PENDING, payment?.status) @@ -937,7 +925,7 @@ class CirclePaymentServiceTest { put("amount", "0.91") put("currency", "USD") } - } + }, ) put( "fees", @@ -946,7 +934,7 @@ class CirclePaymentServiceTest { put("amount", "0.09") put("currency", "USD") } - } + }, ) put("status", "pending") put("sourceWalletId", "1000066041") @@ -958,7 +946,7 @@ class CirclePaymentServiceTest { put("id", "6c87da10-feb8-484f-822c-2083ed762d25") put("name", "JPMORGAN CHASE BANK, NA ****6789") } - } + }, ) put("createDate", "2021-11-25T15:43:03.477Z") put("updateDate", "2021-11-25T16:10:01.618Z") @@ -990,7 +978,8 @@ class CirclePaymentServiceTest { "metadata": { "beneficiaryEmail": "test@mail.com" } - }""".trimIndent() + }""" + .trimIndent() JSONAssert.assertEquals(wantBody, gotBody, false) } @@ -1028,7 +1017,8 @@ class CirclePaymentServiceTest { $mockStellarToWalletTransferJson, $mockWalletToStellarTransferJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() "/transactions/fb8947c67856d8eb444211c1927d92bcf14abcfb34cdd27fc9e604b15d208fd1/payments" -> @@ -1073,7 +1063,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.STELLAR, "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ) p2.destinationAccount = merchantAccount p2.balance = Balance("1.50", "circle:USD") @@ -1091,7 +1081,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.STELLAR, "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ) p3.balance = Balance("1.00", "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5") @@ -1121,7 +1111,8 @@ class CirclePaymentServiceTest { $mockWalletToWalletTransferJson, $mockWalletToStellarTransferJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() } @@ -1164,7 +1155,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.STELLAR, "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ) p2.balance = Balance("1.00", "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5") @@ -1193,7 +1184,8 @@ class CirclePaymentServiceTest { "data": [ $mockWalletToWirePayoutJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() } @@ -1218,7 +1210,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p.balance = Balance("3.00", "iso4217:USD") p.status = Payment.Status.SUCCESSFUL @@ -1247,7 +1239,8 @@ class CirclePaymentServiceTest { "data": [ $mockWalletToWirePayoutJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() } @@ -1273,7 +1266,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p.balance = Balance("3.00", "iso4217:USD") p.status = Payment.Status.SUCCESSFUL @@ -1302,7 +1295,8 @@ class CirclePaymentServiceTest { "data": [ $mockWireToWalletPaymentJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() } @@ -1327,7 +1321,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "a4e76642-81c5-47ca-9229-ebd64efd74a7", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p.destinationAccount = merchantAccount p.balance = Balance("1000.00", "circle:USD") @@ -1357,7 +1351,8 @@ class CirclePaymentServiceTest { "data": [ $mockWireToWalletPaymentJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/configuration" -> return getDistAccountIdMockResponse() } @@ -1383,7 +1378,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "a4e76642-81c5-47ca-9229-ebd64efd74a7", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p.destinationAccount = merchantAccount p.balance = Balance("1000.00", "circle:USD") @@ -1419,7 +1414,7 @@ class CirclePaymentServiceTest { fun test_getTransfersOrPayoutsOrPayments_paginationRequestUri( uri: String, beforeCursor: String?, - afterCursor: String? + afterCursor: String?, ) { val dispatcher = object : Dispatcher() { @@ -1428,9 +1423,12 @@ class CirclePaymentServiceTest { if (request.path!!.startsWith("/v1/$uri")) { return MockResponse() .addHeader("Content-Type", "application/json") - .setBody("""{ + .setBody( + """{ "data": [] - }""".trimIndent()) + }""" + .trimIndent() + ) } if (request.path.equals("/v1/configuration")) { @@ -1448,8 +1446,8 @@ class CirclePaymentServiceTest { assertDoesNotThrow { paymentHistory = (service as CirclePaymentService) - .getTransfers("1000066041", beforeCursor, afterCursor, 1) - .block()!! + .getTransfers("1000066041", beforeCursor, afterCursor, 1) + .block()!! .toPaymentHistory(1, merchantAccount, "1000066041") } } @@ -1457,8 +1455,8 @@ class CirclePaymentServiceTest { assertDoesNotThrow { paymentHistory = (service as CirclePaymentService) - .getPayouts("1000066041", beforeCursor, afterCursor, 1) - .block()!! + .getPayouts("1000066041", beforeCursor, afterCursor, 1) + .block()!! .toPaymentHistory(1, merchantAccount) } } @@ -1466,8 +1464,8 @@ class CirclePaymentServiceTest { assertDoesNotThrow { paymentHistory = (service as CirclePaymentService) - .getIncomingPayments("1000066041", beforeCursor, afterCursor, 1) - .block()!! + .getIncomingPayments("1000066041", beforeCursor, afterCursor, 1) + .block()!! .toPaymentHistory(1, merchantAccount) } } @@ -1502,7 +1500,8 @@ class CirclePaymentServiceTest { $mockStellarToWalletTransferJson, $mockWalletToStellarTransferJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/payouts?pageSize=50&source=1000066041" -> return MockResponse() @@ -1512,7 +1511,8 @@ class CirclePaymentServiceTest { "data": [ $mockWalletToWirePayoutJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/v1/payments?pageSize=50" -> return MockResponse() @@ -1522,7 +1522,8 @@ class CirclePaymentServiceTest { "data": [ $mockWireToWalletPaymentJson ] - }""".trimIndent() + }""" + .trimIndent() ) "/transactions/fb8947c67856d8eb444211c1927d92bcf14abcfb34cdd27fc9e604b15d208fd1/payments" -> return MockResponse() @@ -1551,7 +1552,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "a4e76642-81c5-47ca-9229-ebd64efd74a7", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p0.destinationAccount = merchantAccount p0.balance = Balance("1000.00", "circle:USD") @@ -1579,7 +1580,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.STELLAR, "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ) p2.destinationAccount = merchantAccount p2.balance = Balance("1.50", "circle:USD") @@ -1597,7 +1598,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", - Account.Capabilities(PaymentNetwork.BANK_WIRE) + Account.Capabilities(PaymentNetwork.BANK_WIRE), ) p3.balance = Balance("3.00", "iso4217:USD") p3.status = Payment.Status.SUCCESSFUL @@ -1613,7 +1614,7 @@ class CirclePaymentServiceTest { Account( PaymentNetwork.STELLAR, "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - Account.Capabilities(PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.STELLAR), ) p4.balance = Balance("1.00", "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5") @@ -1654,7 +1655,7 @@ class CirclePaymentServiceTest { "GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU", "2454278437550473431", "USD", - "XLM" + "XLM", ) ) wantAddresses.add( @@ -1662,7 +1663,7 @@ class CirclePaymentServiceTest { "GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU", "4560730744420812493", "USD", - "XLM" + "XLM", ) ) wantAddresses.add( @@ -1707,7 +1708,7 @@ class CirclePaymentServiceTest { "GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU", "2454278437550473431", "USD", - "XLM" + "XLM", ) assertEquals(wantResponse, response) @@ -1755,7 +1756,7 @@ class CirclePaymentServiceTest { "GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU", "2454278437550473431", "USD", - "XLM" + "XLM", ) assertEquals(wantAddress, address) @@ -1834,7 +1835,7 @@ class CirclePaymentServiceTest { val wireInstructionsRequest = server.takeRequest() assertThat( wireInstructionsRequest.path, - CoreMatchers.endsWith("/v1/banks/wires/bank-id-here/instructions") + CoreMatchers.endsWith("/v1/banks/wires/bank-id-here/instructions"), ) assertEquals("GET", wireInstructionsRequest.method) assertEquals("application/json", wireInstructionsRequest.headers["Content-Type"]) @@ -1876,7 +1877,7 @@ class CirclePaymentServiceTest { ex = assertThrows { service.getDepositInstructions(config).block() } assertEquals( HttpException(400, "the only receiving currency in a circle account is \"circle:USD\""), - ex + ex, ) // missing bank id @@ -1886,9 +1887,9 @@ class CirclePaymentServiceTest { assertEquals( HttpException( 400, - "please provide a valid Circle bank id for the intermediaryAccountId field when requesting instructions for bank wire deposits" + "please provide a valid Circle bank id for the intermediaryAccountId field when requesting instructions for bank wire deposits", ), - ex + ex, ) } @@ -1897,7 +1898,7 @@ class CirclePaymentServiceTest { @EnumSource( value = PaymentNetwork::class, mode = EnumSource.Mode.EXCLUDE, - names = ["STELLAR", "CIRCLE", "BANK_WIRE"] + names = ["STELLAR", "CIRCLE", "BANK_WIRE"], ) fun test_getDepositInstructions_parameterValidation_supportedNetworks( paymentNetwork: PaymentNetwork? @@ -1908,9 +1909,9 @@ class CirclePaymentServiceTest { assertEquals( HttpException( 400, - """the only supported intermediary payment networks are "stellar", "circle" and "bank_wire"""" + """the only supported intermediary payment networks are "stellar", "circle" and "bank_wire"""", ), - ex + ex, ) } @@ -1930,7 +1931,7 @@ class CirclePaymentServiceTest { null, PaymentNetwork.CIRCLE, "circle:USD", - null + null, ) assertEquals(wantInstructions, instructions) assertEquals(0, server.requestCount) @@ -1974,7 +1975,7 @@ class CirclePaymentServiceTest { "2454278437550473431", PaymentNetwork.STELLAR, CircleAsset.stellarUSDC(Network.TESTNET), - null + null, ) assertEquals(wantInstructions, instructions) @@ -2021,7 +2022,7 @@ class CirclePaymentServiceTest { null, PaymentNetwork.BANK_WIRE, "bank-id-here", - CircleAsset.circleUSD() + CircleAsset.circleUSD(), ) assertDoesNotThrow { instructions = service.getDepositInstructions(config).block() } @@ -2040,7 +2041,7 @@ class CirclePaymentServiceTest { mapOf( "name" to "CIRCLE INTERNET FINANCIAL INC", "address1" to "1 MAIN STREET", - "address2" to "SUITE 1" + "address2" to "SUITE 1", ), "beneficiaryBank" to mapOf( @@ -2051,9 +2052,9 @@ class CirclePaymentServiceTest { "country" to "US", "swiftCode" to "CRYPTO99", "routingNumber" to "999999999", - "accountNumber" to "1000000001" - ) - ) + "accountNumber" to "1000000001", + ), + ), ) assertEquals(wantInstructions, instructions) @@ -2068,7 +2069,7 @@ class CirclePaymentServiceTest { val wireInstructionsRequest = server.takeRequest() assertThat( wireInstructionsRequest.path, - CoreMatchers.endsWith("/v1/banks/wires/bank-id-here/instructions") + CoreMatchers.endsWith("/v1/banks/wires/bank-id-here/instructions"), ) assertEquals("GET", wireInstructionsRequest.method) assertEquals("application/json", wireInstructionsRequest.headers["Content-Type"]) @@ -2145,13 +2146,13 @@ class CirclePaymentServiceTest { validateErrHandling( ErrorHandlingTestCase( service.getAccount("random_id"), - listOf(validateSecretKeyResponse, badRequestResponse) + listOf(validateSecretKeyResponse, badRequestResponse), ) ) validateErrHandling( ErrorHandlingTestCase( getMerchantAccountUnsettledBalancesMethod.invoke(service) as Mono<*>, - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( @@ -2160,7 +2161,7 @@ class CirclePaymentServiceTest { validateErrHandling( ErrorHandlingTestCase( getCircleWalletMethod.invoke(service, "random_id") as Mono<*>, - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( @@ -2169,25 +2170,25 @@ class CirclePaymentServiceTest { validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).getListOfAddresses("any_id"), - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).createNewStellarAddress("any_id"), - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).getOrCreateStellarAddress("any_id"), - listOf(emptyListResponse, badRequestResponse) + listOf(emptyListResponse, badRequestResponse), ) ) validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).getWireDepositInstructions("1000066041", "any_bank_id"), - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( @@ -2195,7 +2196,7 @@ class CirclePaymentServiceTest { service.getDepositInstructions( DepositRequirements("1000066041", PaymentNetwork.STELLAR, CircleAsset.circleUSD()) ), - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) validateErrHandling( @@ -2206,10 +2207,10 @@ class CirclePaymentServiceTest { null, PaymentNetwork.BANK_WIRE, "bank-id-here", - CircleAsset.circleUSD() + CircleAsset.circleUSD(), ) ), - listOf(badRequestResponse) + listOf(badRequestResponse), ) ) // --- tests with async/parallel requests --- @@ -2223,8 +2224,8 @@ class CirclePaymentServiceTest { hashMapOf( "/v1/configuration" to validateSecretKeyResponse, "/v1/businessAccount/balances" to mainAccountResponse, - "/v1/wallets/1000066041" to badRequestResponse - ) + "/v1/wallets/1000066041" to badRequestResponse, + ), ) ) validateErrHandling( @@ -2233,12 +2234,12 @@ class CirclePaymentServiceTest { Account(PaymentNetwork.CIRCLE, "1000066041", Account.Capabilities()), Account(PaymentNetwork.CIRCLE, "1000067536", Account.Capabilities()), CircleAsset.circleUSD(), - BigDecimal.valueOf(1) + BigDecimal.valueOf(1), ), hashMapOf( "/v1/configuration" to validateSecretKeyResponse, - "/v1/transfers" to badRequestResponse - ) + "/v1/transfers" to badRequestResponse, + ), ) ) validateErrHandling( @@ -2249,15 +2250,15 @@ class CirclePaymentServiceTest { PaymentNetwork.STELLAR, "GBG7VGZFH4TU2GS7WL5LMPYFNP64ZFR23XEGAV7GPEEXKWOR2DKCYPCK", "test tag", - Account.Capabilities(PaymentNetwork.CIRCLE, PaymentNetwork.STELLAR) + Account.Capabilities(PaymentNetwork.CIRCLE, PaymentNetwork.STELLAR), ), "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", - BigDecimal(1) + BigDecimal(1), ), hashMapOf( "/v1/configuration" to validateSecretKeyResponse, - "/v1/transfers" to badRequestResponse - ) + "/v1/transfers" to badRequestResponse, + ), ) ) validateErrHandling( @@ -2268,27 +2269,27 @@ class CirclePaymentServiceTest { PaymentNetwork.BANK_WIRE, "6c87da10-feb8-484f-822c-2083ed762d25", "test@mail.com", - Account.Capabilities() + Account.Capabilities(), ), CircleAsset.fiatUSD(), - BigDecimal(1) + BigDecimal(1), ), hashMapOf( "/v1/configuration" to validateSecretKeyResponse, - "/v1/payouts" to badRequestResponse + "/v1/payouts" to badRequestResponse, ), ) ) validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).getTransfers("1000066041", null, null, null), - hashMapOf("/v1/transfers?pageSize=50&walletId=1000066041" to badRequestResponse) + hashMapOf("/v1/transfers?pageSize=50&walletId=1000066041" to badRequestResponse), ) ) validateErrHandling( ErrorHandlingTestCase( (service as CirclePaymentService).getPayouts("1000066041", null, null, null), - hashMapOf("/v1/payouts?pageSize=50&source=1000066041" to badRequestResponse) + hashMapOf("/v1/payouts?pageSize=50&source=1000066041" to badRequestResponse), ) ) validateErrHandling( @@ -2296,8 +2297,8 @@ class CirclePaymentServiceTest { (service as CirclePaymentService).getIncomingPayments("1000066041", null, null, null), hashMapOf( "/v1/configuration" to validateSecretKeyResponse, - "/v1/payments?pageSize=50" to badRequestResponse - ) + "/v1/payments?pageSize=50" to badRequestResponse, + ), ) ) validateErrHandling( @@ -2307,8 +2308,8 @@ class CirclePaymentServiceTest { "/v1/configuration" to validateSecretKeyResponse, "/v1/transfers?pageSize=50&walletId=1000066041" to badRequestResponse, "/v1/payouts?pageSize=50&source=1000066041" to badRequestResponse, - "/v1/payments?pageSize=50" to badRequestResponse - ) + "/v1/payments?pageSize=50" to badRequestResponse, + ), ) ) } diff --git a/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/StellarReconciliationTest.kt b/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/StellarReconciliationTest.kt index a87bcbb6e5..c707c44eb0 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/StellarReconciliationTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/StellarReconciliationTest.kt @@ -57,7 +57,7 @@ class StellarReconciliationTest { val originalTransfer = gson.fromJson( CirclePaymentServiceTest.mockStellarToWalletTransferJson, - CircleTransfer::class.java + CircleTransfer::class.java, ) assertNull(originalTransfer.source.address) @@ -69,7 +69,7 @@ class StellarReconciliationTest { } assertEquals( "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - updatedTransfer?.source?.address + updatedTransfer?.source?.address, ) // verify the updated transfer is a new object and did not cause any change in the original @@ -84,7 +84,7 @@ class StellarReconciliationTest { request.path, CoreMatchers.endsWith( "/transactions/fb8947c67856d8eb444211c1927d92bcf14abcfb34cdd27fc9e604b15d208fd1/payments" - ) + ), ) } } diff --git a/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/model/CircleTransferSerializationTest.kt b/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/model/CircleTransferSerializationTest.kt index 4bb9880d04..ba6ff4554e 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/model/CircleTransferSerializationTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/paymentservice/circle/model/CircleTransferSerializationTest.kt @@ -61,7 +61,7 @@ class CircleTransferSerializationTest { wantTransfer.destination = CircleTransactionParty.stellar( "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - null + null, ) wantTransfer.amount = CircleBalance("USD", "1.00") wantTransfer.transactionHash = @@ -76,16 +76,12 @@ class CircleTransferSerializationTest { hashMapOf( "type" to "blockchain", "address" to "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - "chain" to "XLM" - ), - "amount" to - hashMapOf( - "amount" to "1.00", - "currency" to "USD", + "chain" to "XLM", ), + "amount" to hashMapOf("amount" to "1.00", "currency" to "USD"), "transactionHash" to "5239ee055b1083231c6bdaaa921d3e4b3bc090577fbd909815bd5d7fe68091ef", "status" to "complete", - "createDate" to "2022-01-01T01:01:01.544Z" + "createDate" to "2022-01-01T01:01:01.544Z", ) val transfer = gson.fromJson(mockCircleTransferJson, CircleTransfer::class.java) @@ -100,7 +96,7 @@ class CircleTransferSerializationTest { transfer.destination = CircleTransactionParty.stellar( "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - null + null, ) transfer.amount = CircleBalance("USD", "1.00") transfer.transactionHash = "5239ee055b1083231c6bdaaa921d3e4b3bc090577fbd909815bd5d7fe68091ef" @@ -114,16 +110,12 @@ class CircleTransferSerializationTest { hashMapOf( "type" to "blockchain", "address" to "GAC2OWWDD75GCP4II35UCLYA7JB6LDDZUBZQLYANAVIHIRJAAQBSCL2S", - "chain" to "XLM" - ), - "amount" to - hashMapOf( - "amount" to "1.00", - "currency" to "USD", + "chain" to "XLM", ), + "amount" to hashMapOf("amount" to "1.00", "currency" to "USD"), "transactionHash" to "5239ee055b1083231c6bdaaa921d3e4b3bc090577fbd909815bd5d7fe68091ef", "status" to "complete", - "createDate" to "2022-01-01T01:01:01.544Z" + "createDate" to "2022-01-01T01:01:01.544Z", ) val transferJson = gson.toJson(transfer) diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/LogAppenderTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/LogAppenderTest.kt index 203334091d..c1c93f0ed5 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/LogAppenderTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/LogAppenderTest.kt @@ -19,6 +19,7 @@ class LogAppenderTest { private val loggerContext: LoggerContext = LogManager.getContext(false) as LoggerContext private val rootLoggerConfig = loggerContext.configuration.getLoggerConfig("org.stellar") private val lastLevel = rootLoggerConfig.level + @BeforeEach fun setup() { every { appender.name } returns "mock appender" @@ -51,7 +52,7 @@ class LogAppenderTest { fun test_logger_outputAccurateLoggerName( methodName: String, wantMessage: String, - wantLevelName: String + wantLevelName: String, ) { when (methodName) { "error" -> Log.error(wantMessage) diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/PaymentConfigTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/PaymentConfigTest.kt index 3004e37517..db7f532c12 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/PaymentConfigTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/PaymentConfigTest.kt @@ -49,71 +49,65 @@ class PaymentConfigTest { // assetService.listAllAssets() is null val mockEmptyAssetService = mockk() every { mockEmptyAssetService.listAllAssets() } returns null - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService(mockEmptyAssetService, null, null, null, null) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService(mockEmptyAssetService, null, null, null, null) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("Asset service cannot be empty.", ex.message) // assetService.listAllAssets() doesn't contain stellar assets val mockStellarLessAssetService = mockk() every { mockStellarLessAssetService.listAllAssets() } returns listOf() - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService( - mockStellarLessAssetService, - null, - null, - null, - null - ) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService( + mockStellarLessAssetService, + null, + null, + null, + null, + ) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("Asset service should contain at least one Stellar asset.", ex.message) // paymentListeners is null - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService(assetService, null, null, null, null) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService(assetService, null, null, null, null) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("The stellar payment observer service needs at least one listener.", ex.message) // paymentListeners is empty - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService(assetService, listOf(), null, null, null) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService(assetService, listOf(), null, null, null) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("The stellar payment observer service needs at least one listener.", ex.message) // paymentStreamerCursorStore is null - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService( - assetService, - mockPaymentListeners, - null, - null, - null - ) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService( + assetService, + mockPaymentListeners, + null, + null, + null, + ) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("Payment streamer cursor store cannot be empty.", ex.message) // appConfig is null every { paymentStreamerCursorStore.load() } returns null - ex = - assertThrows { - paymentConfig.stellarPaymentObserverService( - assetService, - mockPaymentListeners, - paymentStreamerCursorStore, - null, - null - ) - } + ex = assertThrows { + paymentConfig.stellarPaymentObserverService( + assetService, + mockPaymentListeners, + paymentStreamerCursorStore, + null, + null, + ) + } assertInstanceOf(ServerErrorException::class.java, ex) assertEquals("App config cannot be empty.", ex.message) } @@ -137,7 +131,7 @@ class PaymentConfigTest { mockPaymentListeners, paymentStreamerCursorStore, paymentObservingAccountsManager, - mockAppConfig + mockAppConfig, ) } } diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/callback/PlatformIntegrationHelperTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/callback/PlatformIntegrationHelperTest.kt index c249a997ab..c0dbefe976 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/callback/PlatformIntegrationHelperTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/callback/PlatformIntegrationHelperTest.kt @@ -43,7 +43,7 @@ class PlatformIntegrationHelperTest { JwtToken.of( TEST_HOME_DOMAIN, currentTimeMilliseconds / 1000L, - (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L + (currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L, ) val jwtService = JwtService("secret") diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/callback/RestCustomerIntegrationTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/callback/RestCustomerIntegrationTest.kt index b30ee0b754..5ff63db91b 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/callback/RestCustomerIntegrationTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/callback/RestCustomerIntegrationTest.kt @@ -94,7 +94,8 @@ class RestCustomerIntegrationTest { "status": "ACCEPTED" } } - }""".trimMargin() + }""" + .trimMargin() ) ) @@ -128,10 +129,8 @@ class RestCustomerIntegrationTest { &memo_type=memoType &type=sending_user &lang=en - """.replace( - "\n ", - "" - ) + """ + .replace("\n ", "") MatcherAssert.assertThat(request.path, CoreMatchers.endsWith(wantEndpoint)) assertEquals("", request.body.readUtf8()) } @@ -197,7 +196,8 @@ class RestCustomerIntegrationTest { "memo": "memo", "first_name": "John", "last_name": "Doe" - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantBody, request.body.readUtf8(), true) } @@ -226,7 +226,8 @@ class RestCustomerIntegrationTest { """{ "id": "customer-id", "account": "$TEST_ACCOUNT" - }""".trimMargin() + }""" + .trimMargin() JSONAssert.assertEquals(wantBody, request.body.readUtf8(), true) } diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/config/Sep38ConfigTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/config/Sep38ConfigTest.kt index 4ab0debabb..f572573e9f 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/config/Sep38ConfigTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/config/Sep38ConfigTest.kt @@ -17,6 +17,7 @@ open class Sep38ConfigTest { ValidationUtils.invokeValidator(sep38Config, sep38Config, errors) assertEquals(0, errors.errorCount) } + @Test fun testSep38ConfigBadQuoteIntegrationEndpoint() { val sep38Config = PropertySep38Config() diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/data/JdbcSep31TransactionTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/data/JdbcSep31TransactionTest.kt index 1e64bfada7..39142eb78d 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/data/JdbcSep31TransactionTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/data/JdbcSep31TransactionTest.kt @@ -13,7 +13,8 @@ class JdbcSep31TransactionTest { "amount_fee": "5", "refundPayments": null } - """.trimIndent() + """ + .trimIndent() private val refundsJsonWithRefundPayment = """ @@ -33,7 +34,8 @@ class JdbcSep31TransactionTest { } ] } - """.trimIndent() + """ + .trimIndent() @Test fun `test JdbcSep31Transaction refunds Json conversion`() { diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/CirclePaymentObserverServiceTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/CirclePaymentObserverServiceTest.kt index 745baeef9e..20b098b48e 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/CirclePaymentObserverServiceTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/CirclePaymentObserverServiceTest.kt @@ -49,7 +49,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) server = MockWebServer() @@ -80,12 +80,11 @@ class CirclePaymentObserverServiceTest { // Unsupported type is ignored unsupportedNotification = mapOf("Type" to "ABC") - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(unsupportedNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(unsupportedNotification) + ) + } assertEquals("Not handling notification of unsupported type \"ABC\".", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) } @@ -102,7 +101,7 @@ class CirclePaymentObserverServiceTest { } assertEquals( "Notification body of type SubscriptionConfirmation is missing subscription URL.", - ex.message + ex.message, ) assertInstanceOf(BadRequestException::class.java, ex) @@ -111,12 +110,11 @@ class CirclePaymentObserverServiceTest { val serverUrl = server.url("").toString() subConfirmationNotification = mapOf("Type" to "SubscriptionConfirmation", "SubscribeURL" to serverUrl) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Failed to call \"SubscribeURL\" endpoint.", ex.message) assertInstanceOf(BadRequestException::class.java, ex) @@ -127,7 +125,7 @@ class CirclePaymentObserverServiceTest { newHttpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) val badRequestResponse = @@ -137,12 +135,11 @@ class CirclePaymentObserverServiceTest { .setBody("""{ "error": "Something went wrong with your request." }""") server.enqueue(badRequestResponse) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Calling the \"SubscribeURL\" endpoint didn't succeed.", ex.message) assertInstanceOf(BadRequestException::class.java, ex) @@ -186,48 +183,44 @@ class CirclePaymentObserverServiceTest { // notification type is not "transfers" subConfirmationNotification = mapOf("Type" to "Notification", "Message" to "{}") - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Won't handle notification of type \"null\".", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) // missing Message.transfer var messageJson = """{ "notificationType": "transfers" }""" subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Missing \"transfer\" value in notification of type \"transfers\".", ex.message) assertInstanceOf(BadRequestException::class.java, ex) // Not a complete transfer messageJson = """{ "notificationType": "transfers", "transfer": {} }""" subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Not a complete transfer.", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) // Incomplete transfer messageJson = """{ "notificationType": "transfers", "transfer": { "status": "pending" } }""" subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Not a complete transfer.", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) @@ -250,12 +243,11 @@ class CirclePaymentObserverServiceTest { .trimIndent() .trimMargin() subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("Neither source nor destination are Stellar accounts.", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) @@ -282,12 +274,11 @@ class CirclePaymentObserverServiceTest { .trimIndent() .trimMargin() subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("None of the transfer wallets is being tracked.", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) @@ -298,7 +289,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) messageJson = """{ @@ -322,12 +313,11 @@ class CirclePaymentObserverServiceTest { .trimIndent() .trimMargin() subConfirmationNotification = mapOf("Type" to "Notification", "Message" to messageJson) - ex = - assertThrows { - circlePaymentObserverService.handleCircleNotification( - fromMapToCircleNotification(subConfirmationNotification) - ) - } + ex = assertThrows { + circlePaymentObserverService.handleCircleNotification( + fromMapToCircleNotification(subConfirmationNotification) + ) + } assertEquals("The only supported Circle currency is USDC.", ex.message) assertInstanceOf(UnprocessableEntityException::class.java, ex) } @@ -354,7 +344,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) // Mock horizon call @@ -465,7 +455,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) // if the response is empty, returns null @@ -568,7 +558,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) party = CircleTransactionParty.wallet("11111") isWalletTracked = circlePaymentObserverService.isWalletTracked(party) @@ -585,7 +575,7 @@ class CirclePaymentObserverServiceTest { httpClient, circlePaymentObserverConfig, horizon, - listOf(paymentListener) + listOf(paymentListener), ) party = CircleTransactionParty.wallet("11111") isWalletTracked = circlePaymentObserverService.isWalletTracked(party) diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/stellar/PaymentObservingAccountsManagerTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/stellar/PaymentObservingAccountsManagerTest.kt index 770b526403..23b04c011a 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/stellar/PaymentObservingAccountsManagerTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/payment/observer/stellar/PaymentObservingAccountsManagerTest.kt @@ -24,16 +24,16 @@ class PaymentObservingAccountsManagerTest { listOf( PaymentObservingAccount( "GCK5ECMM67ZN7RWGUSDKQAW6CAF6Q5WYK2VQJ276SJMINU6WVCIQW6BL", - Instant.now().minus(0, HOURS) + Instant.now().minus(0, HOURS), ), PaymentObservingAccount( "GCIWQDKACLW26UJXY5CTLULVYUOYROZPAPDDYEQKNGIERVOAXSPLABMB", - Instant.now().minus(2, HOURS) + Instant.now().minus(2, HOURS), ), PaymentObservingAccount( "GAPBFA5ZYG5VVKN7WPMH6K5CBXGU2AM5ED7S54VX27J7S222NKMTWKR6", - Instant.now().minus(12, HOURS) - ) + Instant.now().minus(12, HOURS), + ), ) } @@ -89,7 +89,7 @@ class PaymentObservingAccountsManagerTest { PaymentObservingAccountsManager.ObservingAccount( "GB4DZFFUWC64MZ3BQ433ME7QBODCSFZRBOLWEWEMJIVHABTWGT3W2Q22", Instant.now().minus(24, HOURS), - TRANSIENT + TRANSIENT, ) ) @@ -97,7 +97,7 @@ class PaymentObservingAccountsManagerTest { PaymentObservingAccountsManager.ObservingAccount( "GCC2B7LML6UBKBA7NOMLCR57HPKMFHRO2VTZGSIMRLXDMECBXQ44MOYO", Instant.now().minus(100, DAYS), - RESIDENTIAL + RESIDENTIAL, ) ) diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt index 6a39cdde7c..1c0a87cad9 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/service/PaymentOperationToEventListenerTest.kt @@ -82,7 +82,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( capture(slotAccount), capture(slotMemo), - capture(slotStatus) + capture(slotStatus), ) } returns null paymentOperationToEventListener.onReceived(p) @@ -91,7 +91,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( slotAccount.captured, slotMemo.captured, - slotStatus.captured + slotStatus.captured, ) } assertEquals("GCIZBIBPYIOSND7KRYMTSM25POVLOGGCKGIQLLUNSQJ5MAVRBD66KF6B", slotAccount.captured) @@ -105,7 +105,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( capture(slotAccount), capture(slotMemo), - capture(slotStatus) + capture(slotStatus), ) } throws SepException("Something went wrong") paymentOperationToEventListener.onReceived(p) @@ -114,7 +114,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( slotAccount.captured, slotMemo.captured, - slotStatus.captured + slotStatus.captured, ) } assertEquals("GCIZBIBPYIOSND7KRYMTSM25POVLOGGCKGIQLLUNSQJ5MAVRBD66KF6B", slotAccount.captured) @@ -131,7 +131,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( capture(slotAccount), capture(slotMemo), - capture(slotStatus) + capture(slotStatus), ) } returns sep31TxMock paymentOperationToEventListener.onReceived(p) @@ -140,7 +140,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( slotAccount.captured, slotMemo.captured, - slotStatus.captured + slotStatus.captured, ) } assertEquals("GCIZBIBPYIOSND7KRYMTSM25POVLOGGCKGIQLLUNSQJ5MAVRBD66KF6B", slotAccount.captured) @@ -208,7 +208,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( capture(slotAccount), capture(slotMemo), - capture(slotStatus) + capture(slotStatus), ) } returns sep31TxCopy @@ -247,7 +247,7 @@ class PaymentOperationToEventListenerTest { .statusChange( TransactionEvent.StatusChange( TransactionEvent.Status.PENDING_SENDER, - TransactionEvent.Status.PENDING_RECEIVER + TransactionEvent.Status.PENDING_RECEIVER, ) ) .sep(TransactionEvent.Sep.SEP_31) @@ -271,7 +271,7 @@ class PaymentOperationToEventListenerTest { .customers( Customers( StellarId.builder().id(senderId).build(), - StellarId.builder().id(receiverId).build() + StellarId.builder().id(receiverId).build(), ) ) .stellarTransactions(listOf(stellarTransaction)) @@ -285,7 +285,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=", - "pending_sender" + "pending_sender", ) } verify(exactly = 1) { eventPublishService.publish(any()) } @@ -365,7 +365,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( capture(slotAccount), capture(slotMemo), - capture(slotStatus) + capture(slotStatus), ) } returns sep31TxCopy @@ -404,7 +404,7 @@ class PaymentOperationToEventListenerTest { .statusChange( TransactionEvent.StatusChange( TransactionEvent.Status.PENDING_SENDER, - TransactionEvent.Status.PENDING_RECEIVER + TransactionEvent.Status.PENDING_RECEIVER, ) ) .sep(TransactionEvent.Sep.SEP_31) @@ -428,7 +428,7 @@ class PaymentOperationToEventListenerTest { .customers( Customers( StellarId.builder().id(senderId).build(), - StellarId.builder().id(receiverId).build() + StellarId.builder().id(receiverId).build(), ) ) .stellarTransactions(listOf(stellarTransaction)) @@ -442,7 +442,7 @@ class PaymentOperationToEventListenerTest { transactionStore.findByStellarAccountIdAndMemoAndStatus( "GBZ4HPSEHKEEJ6MOZBSVV2B3LE27EZLV6LJY55G47V7BGBODWUXQM364", "OWI3OGYwZmEtOTNmOS00MTk4LThkOTMtZTc2ZmQwODQ=", - "pending_sender" + "pending_sender", ) } verify(exactly = 1) { eventPublishService.publish(any()) } diff --git a/platform/src/test/kotlin/org/stellar/anchor/platform/service/TransactionServiceTest.kt b/platform/src/test/kotlin/org/stellar/anchor/platform/service/TransactionServiceTest.kt index ce716dfed0..e5dee61a4a 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/platform/service/TransactionServiceTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/platform/service/TransactionServiceTest.kt @@ -127,7 +127,7 @@ class TransactionServiceTest { mockMissingFields.transaction = mapOf( "receiver_account_number" to - AssetInfo.Sep31TxnFieldSpec("bank account number of the destination", null, false), + AssetInfo.Sep31TxnFieldSpec("bank account number of the destination", null, false) ) // mock the database SEP-31 transaction @@ -188,7 +188,7 @@ class TransactionServiceTest { .fee(Amount("4.0000", fiatUSD)) .requestedAt(null) .refundedAt(null) - .build() + .build(), ) ) .build() @@ -215,7 +215,7 @@ class TransactionServiceTest { .customers( Customers( StellarId("6c1770b0-0ea4-11ed-861d-0242ac120002", null), - StellarId("31212353-f265-4dba-9eb4-0bbeda3ba7f2", null) + StellarId("31212353-f265-4dba-9eb4-0bbeda3ba7f2", null), ) ) .creator(StellarId("141ee445-f32c-4c38-9d25-f4475d6c5558", null)) @@ -303,7 +303,8 @@ class TransactionServiceTest { "COMPLETED", "REFUNDED", "EXPIRED", - "ERROR"] + "ERROR", + ], ) fun test_validateIfStatusIsSupported_failure(sepTxnStatus: SepTransactionStatus) { val ex: Exception = assertThrows { @@ -325,7 +326,8 @@ class TransactionServiceTest { "PENDING_EXTERNAL", "COMPLETED", "EXPIRED", - "ERROR"] + "ERROR", + ], ) fun test_validateIfStatusIsSupported(sepTxnStatus: SepTransactionStatus) { assertDoesNotThrow { transactionService.validateIfStatusIsSupported(sepTxnStatus.getName()) } @@ -361,7 +363,7 @@ class TransactionServiceTest { .fee(Amount("4.0000", fiatUSD)) .requestedAt(null) .refundedAt(null) - .build() + .build(), ) ) .build() diff --git a/platform/src/test/kotlin/org/stellar/anchor/sep31/Sep31DepositInfoGeneratorTest.kt b/platform/src/test/kotlin/org/stellar/anchor/sep31/Sep31DepositInfoGeneratorTest.kt index 2a379f2ac9..80d6a7014d 100644 --- a/platform/src/test/kotlin/org/stellar/anchor/sep31/Sep31DepositInfoGeneratorTest.kt +++ b/platform/src/test/kotlin/org/stellar/anchor/sep31/Sep31DepositInfoGeneratorTest.kt @@ -79,7 +79,7 @@ class Sep31DepositInfoGeneratorTest { assetService, feeIntegration, customerIntegration, - eventPublishService + eventPublishService, ) txn = gson.fromJson(txnJson, JdbcSep31Transaction::class.java) @@ -103,13 +103,13 @@ class Sep31DepositInfoGeneratorTest { assetService, feeIntegration, customerIntegration, - eventPublishService + eventPublishService, ) Assertions.assertEquals("a2392add-87c9-42f0-a5c1-5f1728030b68", txn.id) Assertions.assertEquals( "GAYR3FVW2PCXTNHHWHEAFOCKZQV4PEY2ZKGIKB47EKPJ3GSBYA52XJBY", - txn.stellarAccountId + txn.stellarAccountId, ) Assertions.assertNull(txn.stellarMemoType) Assertions.assertNull(txn.stellarMemo) @@ -123,7 +123,7 @@ class Sep31DepositInfoGeneratorTest { Assertions.assertEquals( "GAYR3FVW2PCXTNHHWHEAFOCKZQV4PEY2ZKGIKB47EKPJ3GSBYA52XJBY", - txn.stellarAccountId + txn.stellarAccountId, ) Assertions.assertEquals("hash", txn.stellarMemoType) Assertions.assertEquals("YTIzOTJhZGQtODdjOS00MmYwLWE1YzEtNWYxNzI4MDM=", txn.stellarMemo) @@ -148,7 +148,8 @@ class Sep31DepositInfoGeneratorTest { "masterWalletId":"1000066041" } } - }""".trimMargin() + }""" + .trimMargin() ) "/v1/wallets/1000066041/addresses" -> return MockResponse() @@ -161,7 +162,8 @@ class Sep31DepositInfoGeneratorTest { "currency":"USD", "chain":"XLM" } - }""".trimMargin() + }""" + .trimMargin() ) } return MockResponse().setResponseCode(404) @@ -189,7 +191,7 @@ class Sep31DepositInfoGeneratorTest { assetService, feeIntegration, customerIntegration, - eventPublishService + eventPublishService, ) Assertions.assertNull(txn.stellarMemoType) @@ -200,7 +202,7 @@ class Sep31DepositInfoGeneratorTest { Assertions.assertEquals( "GAYF33NNNMI2Z6VNRFXQ64D4E4SF77PM46NW3ZUZEEU5X7FCHAZCMHKU", - txn.stellarAccountId + txn.stellarAccountId, ) Assertions.assertEquals("text", txn.stellarMemoType) Assertions.assertEquals("2454278437550473431", txn.stellarMemo) @@ -218,13 +220,13 @@ class Sep31DepositInfoGeneratorTest { Sep31DepositInfo( "GAYR3FVW2PCXTNHHWHEAFOCKZQV4PEY2ZKGIKB47EKPJ3GSBYA52XJBY", nonEmptyMemo, - nonEmptyMemoType + nonEmptyMemoType, ) Assertions.assertEquals("a2392add-87c9-42f0-a5c1-5f1728030b68", txn.id) Assertions.assertEquals( "GAYR3FVW2PCXTNHHWHEAFOCKZQV4PEY2ZKGIKB47EKPJ3GSBYA52XJBY", - txn.stellarAccountId + txn.stellarAccountId, ) Assertions.assertNull(txn.stellarMemoType) Assertions.assertNull(txn.stellarMemo) @@ -238,7 +240,7 @@ class Sep31DepositInfoGeneratorTest { Assertions.assertEquals( "GAYR3FVW2PCXTNHHWHEAFOCKZQV4PEY2ZKGIKB47EKPJ3GSBYA52XJBY", - txn.stellarAccountId + txn.stellarAccountId, ) Assertions.assertEquals(nonEmptyMemo, txn.stellarMemo) Assertions.assertEquals(nonEmptyMemoType, txn.stellarMemoType)