|
| 1 | +package com.braintreepayments.api.card |
| 2 | + |
| 3 | +import com.braintreepayments.api.testutils.Fixtures |
| 4 | +import com.braintreepayments.api.threedsecure.ThreeDSecureInfo |
| 5 | +import org.json.JSONException |
| 6 | +import org.json.JSONObject |
| 7 | +import org.junit.Test |
| 8 | +import kotlin.test.assertEquals |
| 9 | +import kotlin.test.assertFalse |
| 10 | +import kotlin.test.assertTrue |
| 11 | + |
| 12 | +class ThreeDSecureInfoUnitTest { |
| 13 | + |
| 14 | + @Test |
| 15 | + @Throws(JSONException::class) |
| 16 | + fun `successfully creates ThreeDSecure object from JSON`() { |
| 17 | + val json = JSONObject(Fixtures.PAYMENT_METHODS_RESPONSE_VISA_CREDIT_CARD) |
| 18 | + val info = ThreeDSecureInfo.fromJson( |
| 19 | + json.getJSONArray("creditCards") |
| 20 | + .getJSONObject(0) |
| 21 | + .getJSONObject("threeDSecureInfo") |
| 22 | + ) |
| 23 | + assertEquals("fake-cavv", info.cavv) |
| 24 | + assertEquals("fake-txn-id", info.dsTransactionId) |
| 25 | + assertEquals("07", info.eciFlag) |
| 26 | + assertEquals("Y", info.enrolled) |
| 27 | + assertTrue(info.liabilityShiftPossible) |
| 28 | + assertFalse(info.liabilityShifted) |
| 29 | + assertEquals("lookup_enrolled", info.status) |
| 30 | + assertEquals("2.2.0", info.threeDSecureVersion) |
| 31 | + assertTrue(info.wasVerified) |
| 32 | + assertEquals("fake-xid", info.xid) |
| 33 | + assertEquals("fake-acs-transaction-id", info.acsTransactionId) |
| 34 | + assertEquals("fake-threedsecure-authentication-id", info.threeDSecureAuthenticationId) |
| 35 | + assertEquals("fake-threedsecure-server-transaction-id", info.threeDSecureServerTransactionId) |
| 36 | + assertEquals("fake-pares-status", info.paresStatus) |
| 37 | + assertEquals("Y", info.authenticationTransactionStatus) |
| 38 | + assertEquals("01", info.authenticationTransactionStatusReason) |
| 39 | + assertEquals("N", info.lookupTransactionStatus) |
| 40 | + assertEquals("02", info.lookupTransactionStatusReason) |
| 41 | + } |
| 42 | +} |
0 commit comments