카드 매입 승인 경로 Spring Boot 3 전환 #10
1 changed files with 80 additions and 0 deletions
|
|
@ -0,0 +1,80 @@
|
|||
package com.acquirex.approval;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@DisplayName("카드 매입 승인 서비스 테스트")
|
||||
class CardAcquisitionApprovalServiceTest {
|
||||
|
||||
private CardAcquisitionApprovalService approvalService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
approvalService = new CardAcquisitionApprovalService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("소액 거래 승인 처리 성공")
|
||||
void testSmallAmountApproval() {
|
||||
CardAcquisitionApprovalRequest request = CardAcquisitionApprovalRequest.builder()
|
||||
.merchantId("MERCHANT001")
|
||||
.cardCompanyCode("CARD001")
|
||||
.transactionAmount(new BigDecimal("50000"))
|
||||
.transactionType("PURCHASE")
|
||||
.build();
|
||||
|
||||
CardAcquisitionApprovalResponse response = approvalService.processApproval(request);
|
||||
|
||||
assertNotNull(response);
|
||||
assertNotNull(response.getApprovalId());
|
||||
assertTrue(response.getApprovalId().startsWith("APR-"));
|
||||
assertEquals("MERCHANT001", response.getMerchantId());
|
||||
assertEquals(CardAcquisitionApprovalStatus.APPROVED, response.getStatus());
|
||||
assertEquals("0000", response.getResponseCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("대액 거래 처리 중 상태")
|
||||
void testLargeAmountProcessing() {
|
||||
CardAcquisitionApprovalRequest request = CardAcquisitionApprovalRequest.builder()
|
||||
.merchantId("MERCHANT002")
|
||||
.cardCompanyCode("CARD002")
|
||||
.transactionAmount(new BigDecimal("150000"))
|
||||
.transactionType("PURCHASE")
|
||||
.build();
|
||||
|
||||
CardAcquisitionApprovalResponse response = approvalService.processApproval(request);
|
||||
|
||||
assertNotNull(response);
|
||||
assertEquals(CardAcquisitionApprovalStatus.PROCESSING, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("승인 상태 조회 성공")
|
||||
void testGetApprovalStatus() {
|
||||
CardAcquisitionApprovalRequest request = CardAcquisitionApprovalRequest.builder()
|
||||
.merchantId("MERCHANT003")
|
||||
.cardCompanyCode("CARD003")
|
||||
.transactionAmount(new BigDecimal("30000"))
|
||||
.transactionType("PURCHASE")
|
||||
.build();
|
||||
|
||||
CardAcquisitionApprovalResponse created = approvalService.processApproval(request);
|
||||
CardAcquisitionApprovalResponse found = approvalService.getApprovalStatus(created.getApprovalId());
|
||||
|
||||
assertNotNull(found);
|
||||
assertEquals(created.getApprovalId(), found.getApprovalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("존재하지 않는 승인 ID 조회 시 null 반환")
|
||||
void testGetNonExistentApproval() {
|
||||
CardAcquisitionApprovalResponse response = approvalService.getApprovalStatus("APR-NONEXIST");
|
||||
assertNull(response);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue