-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-추가된 내용 : 1. 세션에 orderId, amount 값을 임시 저장한 것이 제대로 저장되었는지 테스트 이유 : 결제 최종 승인 요청 전에 값이 변조되지 않았는지 검증하기 위함 미흡 : 결제 요청 받았을 때, 세션에 값이 저장되지 않았을 경우에 대한 예외 처리 미완
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
src/test/java/com/tasksprints/auction/domain/payment/repository/PaymentRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tasksprints.auction.domain.payment.repository; | ||
|
||
public class PaymentRepositoryTest { | ||
} |
58 changes: 58 additions & 0 deletions
58
src/test/java/com/tasksprints/auction/domain/payment/service/PaymentServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.tasksprints.auction.domain.payment.service; | ||
|
||
import com.tasksprints.auction.domain.payment.dto.request.PaymentRequest; | ||
import jakarta.servlet.http.HttpSession; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class PaymentServiceImplTest { | ||
@InjectMocks | ||
private PaymentServiceImpl paymentService; | ||
|
||
@Mock | ||
private HttpSession session; | ||
|
||
@Nested | ||
@DisplayName("결제 전 세션 임시 저장 테스트") | ||
class 임시_저장_테스트{ | ||
@Test | ||
void 결제_요청을_받았을_때_세션에_값이_저장되면_성공한다 () { | ||
//given | ||
String orderId = "testOrderId"; | ||
BigDecimal amount = BigDecimal.valueOf(1000.00); | ||
PaymentRequest.Prepare prepareRequest = new PaymentRequest.Prepare(orderId, amount); | ||
|
||
when(session.getAttribute("orderId")).thenReturn(orderId); | ||
when(session.getAttribute("amount")).thenReturn(amount); | ||
//when | ||
paymentService.prepare(session, prepareRequest); | ||
//then | ||
verify(session).setAttribute("orderId", orderId); | ||
verify(session).setAttribute("amount", amount); | ||
|
||
assertThat(orderId).isEqualTo(session.getAttribute("orderId")); | ||
assertThat(amount).isEqualTo(session.getAttribute("amount")); | ||
} | ||
@Test | ||
void 결제_요청을_받았을_때_세션에_값이_저장되지_않으면_예외_처리 () { | ||
//given | ||
//when | ||
//then | ||
} | ||
} | ||
} |