generated from pricelees/issue-pr-template
213 lines
6.5 KiB
Kotlin
213 lines
6.5 KiB
Kotlin
package roomescape.util
|
|
|
|
import com.github.f4b6a3.tsid.TsidFactory
|
|
import roomescape.admin.infrastructure.persistence.AdminEntity
|
|
import roomescape.admin.infrastructure.persistence.AdminPermissionLevel
|
|
import roomescape.common.config.next
|
|
import roomescape.member.infrastructure.persistence.MemberEntity
|
|
import roomescape.member.infrastructure.persistence.Role
|
|
import roomescape.member.infrastructure.persistence.UserEntity
|
|
import roomescape.member.infrastructure.persistence.UserStatus
|
|
import roomescape.member.web.MIN_PASSWORD_LENGTH
|
|
import roomescape.member.web.UserCreateRequest
|
|
import roomescape.payment.infrastructure.client.*
|
|
import roomescape.payment.infrastructure.common.*
|
|
import roomescape.payment.web.PaymentCancelRequest
|
|
import roomescape.payment.web.PaymentConfirmRequest
|
|
import roomescape.reservation.web.PendingReservationCreateRequest
|
|
import roomescape.schedule.web.ScheduleCreateRequest
|
|
import roomescape.theme.infrastructure.persistence.Difficulty
|
|
import roomescape.theme.web.ThemeCreateRequest
|
|
import java.time.LocalDate
|
|
import java.time.LocalTime
|
|
import java.time.OffsetDateTime
|
|
|
|
const val INVALID_PK: Long = 9999L
|
|
val tsidFactory = TsidFactory(0)
|
|
|
|
object MemberFixture {
|
|
val admin: MemberEntity = MemberEntity(
|
|
_id = 9304,
|
|
name = "ADMIN",
|
|
email = "admin@example.com",
|
|
password = "adminPassword",
|
|
role = Role.ADMIN
|
|
)
|
|
|
|
val user: MemberEntity = MemberEntity(
|
|
_id = 9305,
|
|
name = "USER",
|
|
email = "user@example.com",
|
|
password = "userPassword",
|
|
role = Role.MEMBER
|
|
)
|
|
}
|
|
|
|
object AdminFixture {
|
|
val default: AdminEntity = create()
|
|
|
|
fun create(
|
|
id: Long = tsidFactory.next(),
|
|
account: String = "admin",
|
|
password: String = "adminPassword",
|
|
name: String = "admin12345",
|
|
phone: String = "01012345678",
|
|
permissionLevel: AdminPermissionLevel = AdminPermissionLevel.FULL_ACCESS
|
|
): AdminEntity = AdminEntity(
|
|
id = id,
|
|
account = account,
|
|
password = password,
|
|
name = name,
|
|
phone = phone,
|
|
permissionLevel = permissionLevel
|
|
)
|
|
}
|
|
|
|
object UserFixture {
|
|
val default: UserEntity = createUser()
|
|
|
|
fun createUser(
|
|
id: Long = tsidFactory.next(),
|
|
name: String = "sample",
|
|
email: String = "sample@example.com",
|
|
password: String = "a".repeat(MIN_PASSWORD_LENGTH),
|
|
phone: String = "01012345678",
|
|
regionCode: String = "1130510300",
|
|
status: UserStatus = UserStatus.ACTIVE
|
|
): UserEntity = UserEntity(
|
|
id = id,
|
|
name = name,
|
|
email = email,
|
|
password = password,
|
|
phone = phone,
|
|
regionCode = regionCode,
|
|
status = status
|
|
)
|
|
|
|
val createRequest: UserCreateRequest = UserCreateRequest(
|
|
name = "sample",
|
|
email = "sample@example.com",
|
|
password = "a".repeat(MIN_PASSWORD_LENGTH),
|
|
phone = "01012345678",
|
|
regionCode = "1130510300"
|
|
)
|
|
}
|
|
|
|
object ThemeFixture {
|
|
val createRequest: ThemeCreateRequest = ThemeCreateRequest(
|
|
name = "Matilda Green",
|
|
description = "constituto",
|
|
thumbnailUrl = "https://duckduckgo.com/?q=mediocrem",
|
|
difficulty = Difficulty.VERY_EASY,
|
|
price = 10000,
|
|
minParticipants = 3,
|
|
maxParticipants = 5,
|
|
availableMinutes = 80,
|
|
expectedMinutesFrom = 60,
|
|
expectedMinutesTo = 70,
|
|
isOpen = true
|
|
)
|
|
}
|
|
|
|
object ScheduleFixture {
|
|
val createRequest: ScheduleCreateRequest = ScheduleCreateRequest(
|
|
date = LocalDate.now().plusDays(1),
|
|
time = LocalTime.now(),
|
|
themeId = 1L
|
|
)
|
|
}
|
|
|
|
object PaymentFixture {
|
|
val confirmRequest: PaymentConfirmRequest = PaymentConfirmRequest(
|
|
paymentKey = "paymentKey",
|
|
orderId = "orderId",
|
|
amount = 10000,
|
|
paymentType = PaymentType.NORMAL
|
|
)
|
|
|
|
val cancelRequest: PaymentCancelRequest = PaymentCancelRequest(
|
|
reservationId = 1L,
|
|
cancelReason = "cancelReason",
|
|
)
|
|
|
|
fun cardDetail(
|
|
amount: Int,
|
|
issuerCode: CardIssuerCode = CardIssuerCode.SHINHAN,
|
|
cardType: CardType = CardType.CREDIT,
|
|
ownerType: CardOwnerType = CardOwnerType.PERSONAL,
|
|
installmentPlanMonths: Int = 0,
|
|
): CardDetail = CardDetail(
|
|
issuerCode = issuerCode,
|
|
number = "429335*********",
|
|
amount = amount,
|
|
cardType = cardType,
|
|
ownerType = ownerType,
|
|
isInterestFree = false,
|
|
approveNo = "1828382",
|
|
installmentPlanMonths = installmentPlanMonths
|
|
)
|
|
|
|
fun easypayDetail(
|
|
amount: Int,
|
|
provider: EasyPayCompanyCode = EasyPayCompanyCode.TOSSPAY,
|
|
discountAmount: Int = 0
|
|
): EasyPayDetail = EasyPayDetail(provider, amount, discountAmount)
|
|
|
|
fun transferDetail(
|
|
bankCode: BankCode = BankCode.SHINHAN,
|
|
settlementStatus: String = "COMPLETED"
|
|
): TransferDetail = TransferDetail(
|
|
bankCode = bankCode,
|
|
settlementStatus = settlementStatus
|
|
)
|
|
|
|
fun confirmResponse(
|
|
paymentKey: String,
|
|
amount: Int,
|
|
method: PaymentMethod,
|
|
cardDetail: CardDetail?,
|
|
easyPayDetail: EasyPayDetail?,
|
|
transferDetail: TransferDetail?
|
|
) = PaymentClientConfirmResponse(
|
|
paymentKey = paymentKey,
|
|
status = PaymentStatus.DONE,
|
|
totalAmount = amount,
|
|
vat = (amount * 0.1).toInt(),
|
|
suppliedAmount = (amount * 0.9).toInt(),
|
|
method = method,
|
|
card = cardDetail,
|
|
easyPay = easyPayDetail,
|
|
transfer = transferDetail,
|
|
requestedAt = OffsetDateTime.now(),
|
|
approvedAt = OffsetDateTime.now().plusSeconds(5)
|
|
)
|
|
|
|
fun cancelResponse(
|
|
amount: Int,
|
|
cardDiscountAmount: Int = 0,
|
|
transferDiscountAmount: Int = 0,
|
|
easypayDiscountAmount: Int = 0,
|
|
cancelReason: String = "cancelReason"
|
|
) = PaymentClientCancelResponse(
|
|
status = PaymentStatus.CANCELED,
|
|
cancels = CancelDetail(
|
|
cancelAmount = amount,
|
|
cardDiscountAmount = cardDiscountAmount,
|
|
transferDiscountAmount = transferDiscountAmount,
|
|
easyPayDiscountAmount = easypayDiscountAmount,
|
|
canceledAt = OffsetDateTime.now().plusSeconds(5),
|
|
cancelReason = cancelReason
|
|
),
|
|
)
|
|
}
|
|
|
|
object ReservationFixture {
|
|
val pendingCreateRequest: PendingReservationCreateRequest = PendingReservationCreateRequest(
|
|
scheduleId = 1L,
|
|
reserverName = "Wilbur Stuart",
|
|
reserverContact = "wilbur@example.com",
|
|
participantCount = 5,
|
|
requirement = "Hello, Nice to meet you!"
|
|
)
|
|
}
|