-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Sep31Transaction.refunds Gson serialization exception (#630) * Trigger workflow commit
- Loading branch information
Showing
10 changed files
with
137 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
platform/src/test/kotlin/org/stellar/anchor/platform/data/JdbcSep31TransactionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.stellar.anchor.platform.data | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertNull | ||
import org.junit.jupiter.api.Test | ||
import org.skyscreamer.jsonassert.JSONAssert | ||
|
||
class JdbcSep31TransactionTest { | ||
private val refundsJsonNoRefundPayment = | ||
""" | ||
{ | ||
"amount_refunded": "10", | ||
"amount_fee": "5", | ||
"refundPayments": null | ||
} | ||
""".trimIndent() | ||
|
||
private val refundsJsonWithRefundPayment = | ||
""" | ||
{ | ||
"amount_refunded": "10", | ||
"amount_fee": "5", | ||
"payments": [ | ||
{ | ||
"id": "1", | ||
"amount": "5", | ||
"fee": "1" | ||
}, | ||
{ | ||
"id": "2", | ||
"amount": "5", | ||
"fee": "4" | ||
} | ||
] | ||
} | ||
""".trimIndent() | ||
|
||
@Test | ||
fun `test JdbcSep31Transaction refunds Json conversion`() { | ||
val txn = JdbcSep31Transaction() | ||
txn.refundsJson = refundsJsonNoRefundPayment | ||
// strict is set to false because refundPayments is omitted in txn.refundsJson when it is set to | ||
// null. | ||
JSONAssert.assertEquals(txn.refundsJson, refundsJsonNoRefundPayment, false) | ||
assertEquals("10", txn.refunds.amountRefunded) | ||
assertEquals("5", txn.refunds.amountFee) | ||
assertNull(txn.refunds.refundPayments) | ||
|
||
txn.refundsJson = refundsJsonWithRefundPayment | ||
JSONAssert.assertEquals(txn.refundsJson, refundsJsonWithRefundPayment, true) | ||
assertEquals("10", txn.refunds.amountRefunded) | ||
assertEquals("5", txn.refunds.amountFee) | ||
assertEquals(2, txn.refunds.refundPayments.size) | ||
assertEquals("1", txn.refunds.refundPayments[0].id) | ||
assertEquals("5", txn.refunds.refundPayments[0].amount) | ||
assertEquals("1", txn.refunds.refundPayments[0].fee) | ||
assertEquals("2", txn.refunds.refundPayments[1].id) | ||
assertEquals("5", txn.refunds.refundPayments[1].amount) | ||
assertEquals("4", txn.refunds.refundPayments[1].fee) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters