generated from pricelees/issue-pr-template
feat: 테스트를 위해 임의의 결제 정보를 제공하기 위한 랜덤값 생성 유틸 클래스 추가
This commit is contained in:
parent
6eb132b644
commit
c921a9a89a
@ -0,0 +1,45 @@
|
||||
package com.sangdol.tosspaymock.business.domain
|
||||
|
||||
object RandomCardValueGenerator {
|
||||
fun cardNumber(): String {
|
||||
return "${(10000000..99999999).random()}****${(100..999).random()}*"
|
||||
}
|
||||
|
||||
fun approvalNumber(): String {
|
||||
return "${(0..99999999).random()}".padStart(8, '0')
|
||||
}
|
||||
|
||||
fun installmentPlanMonths(amount: Int): Int {
|
||||
return if (amount < 50_000 || Math.random() < 0.95) {
|
||||
0
|
||||
} else {
|
||||
(1..6).random()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object RandomEasypayValueGenerator {
|
||||
fun point(amount: Int): Int =
|
||||
if (amount < 100 || Math.random() < 0.8) {
|
||||
0
|
||||
} else {
|
||||
// 100~amount 까지 100원 단위로 생성
|
||||
((100..amount).random() / 100) * 100
|
||||
}
|
||||
}
|
||||
|
||||
object RandomPaymentValueGenerator {
|
||||
fun mId(): String {
|
||||
val words = ('a'..'z')
|
||||
val randomValue = (1..9).map { words.random() }.joinToString("")
|
||||
|
||||
return "tgen_${randomValue}"
|
||||
}
|
||||
|
||||
fun transactionKey(): String {
|
||||
val prefix = "txrd"
|
||||
val characters = ('0'..'9') + ('a'..'z')
|
||||
val randomString = (1..24).map { characters.random() }.joinToString("")
|
||||
return "${prefix}_${randomString}"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user