PaymentService 승인 규칙 구현 (BAIS-SOURCE-1783702539)
This commit is contained in:
parent
1d1a558cfc
commit
af5ee7ca80
1 changed files with 32 additions and 0 deletions
32
src/test/java/com/example/baisgate/PaymentServiceTest.java
Normal file
32
src/test/java/com/example/baisgate/PaymentServiceTest.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package com.example.baisgate;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class PaymentServiceTest {
|
||||
|
||||
@Test
|
||||
void testApprove_WithValidTransactionId_ReturnsApproved() {
|
||||
PaymentService paymentService = new PaymentService();
|
||||
String result = paymentService.approve("12345");
|
||||
assertEquals("APPROVED:12345", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testApprove_WithBlankTransactionId_ThrowsIllegalArgumentException() {
|
||||
PaymentService paymentService = new PaymentService();
|
||||
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
|
||||
paymentService.approve("");
|
||||
});
|
||||
assertEquals("Transaction ID cannot be blank", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testApprove_WithNullTransactionId_ThrowsIllegalArgumentException() {
|
||||
PaymentService paymentService = new PaymentService();
|
||||
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
|
||||
paymentService.approve(null);
|
||||
});
|
||||
assertEquals("Transaction ID cannot be blank", exception.getMessage());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue