diff --git a/.forge/BAIS-SOURCE-1783702539-attempt-1.md b/.forge/BAIS-SOURCE-1783702539-attempt-1.md new file mode 100644 index 0000000..b15de76 --- /dev/null +++ b/.forge/BAIS-SOURCE-1783702539-attempt-1.md @@ -0,0 +1,3 @@ +# BAIS-SOURCE-1783702539-attempt-1 + +Forge 이슈 작업 브랜치 `forge/BAIS-SOURCE-1783702539-attempt-1`. diff --git a/pom.xml b/pom.xml index 664b084..38f992a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,15 @@ - 4.0.0 - com.example bais-gate-e2e - 1.0.0 + 1.0-SNAPSHOT jar org.springframework.boot spring-boot-starter-parent - 2.7.5 + 3.2.0 @@ -22,7 +20,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter org.springframework.boot @@ -39,4 +37,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/example/baisgate/PaymentService.java b/src/main/java/com/example/baisgate/PaymentService.java new file mode 100644 index 0000000..489d52a --- /dev/null +++ b/src/main/java/com/example/baisgate/PaymentService.java @@ -0,0 +1,10 @@ +package com.example.baisgate; + +public class PaymentService { + public String approve(String transactionId) { + if (transactionId == null || transactionId.trim().isEmpty()) { + throw new IllegalArgumentException("Transaction ID cannot be blank"); + } + return "APPROVED:" + transactionId; + } +} \ No newline at end of file diff --git a/src/test/java/com/example/baisgate/PaymentServiceTest.java b/src/test/java/com/example/baisgate/PaymentServiceTest.java new file mode 100644 index 0000000..1caa7a9 --- /dev/null +++ b/src/test/java/com/example/baisgate/PaymentServiceTest.java @@ -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()); + } +} \ No newline at end of file