Skip to content

Commit 4f4a534

Browse files
committed
Move CardSecurityCodeValidatorTest to core
COSDK-570
1 parent 76ea943 commit 4f4a534

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2024 Adyen N.V.
3+
*
4+
* This file is open source and available under the MIT license. See the LICENSE file for more info.
5+
*
6+
* Created by ozgur on 4/10/2024.
7+
*/
8+
9+
package com.adyen.checkout.core.common.helper
10+
11+
import com.adyen.checkout.core.common.CardBrand
12+
import com.adyen.checkout.core.common.CardType
13+
import org.junit.jupiter.api.Assertions.assertEquals
14+
import org.junit.jupiter.params.ParameterizedTest
15+
import org.junit.jupiter.params.provider.Arguments.arguments
16+
import org.junit.jupiter.params.provider.MethodSource
17+
18+
internal class CardSecurityCodeValidatorTest {
19+
20+
@ParameterizedTest
21+
@MethodSource("securityCodeValidationSource")
22+
fun `when validateSecurityCode is called, then expected validation result is returned`(
23+
securityCodeInput: String,
24+
cardBrand: CardBrand? = null,
25+
expectedValidationResult: CardSecurityCodeValidationResult
26+
) {
27+
val actualResult = CardSecurityCodeValidator.validateSecurityCode(securityCodeInput, cardBrand)
28+
assertEquals(expectedValidationResult.javaClass, actualResult.javaClass)
29+
}
30+
31+
companion object {
32+
@JvmStatic
33+
fun securityCodeValidationSource() = listOf(
34+
arguments(
35+
"",
36+
CardBrand(CardType.VISA.txVariant),
37+
CardSecurityCodeValidationResult.Invalid(),
38+
),
39+
arguments(
40+
"7",
41+
CardBrand(CardType.VISA.txVariant),
42+
CardSecurityCodeValidationResult.Invalid(),
43+
),
44+
arguments(
45+
"12",
46+
CardBrand(CardType.VISA.txVariant),
47+
CardSecurityCodeValidationResult.Invalid(),
48+
),
49+
arguments(
50+
"737",
51+
CardBrand(CardType.VISA.txVariant),
52+
CardSecurityCodeValidationResult.Valid(),
53+
),
54+
arguments(
55+
"8689",
56+
CardBrand(CardType.VISA.txVariant),
57+
CardSecurityCodeValidationResult.Invalid(),
58+
),
59+
arguments(
60+
"123456",
61+
CardBrand(CardType.VISA.txVariant),
62+
CardSecurityCodeValidationResult.Invalid(),
63+
),
64+
arguments(
65+
"737",
66+
CardBrand(CardType.AMERICAN_EXPRESS.txVariant),
67+
CardSecurityCodeValidationResult.Invalid(),
68+
),
69+
arguments(
70+
"8689",
71+
CardBrand(CardType.AMERICAN_EXPRESS.txVariant),
72+
CardSecurityCodeValidationResult.Valid(),
73+
),
74+
arguments(
75+
"1%y",
76+
null,
77+
CardSecurityCodeValidationResult.Invalid(),
78+
),
79+
)
80+
}
81+
}

0 commit comments

Comments
 (0)