diff --git a/.forge/BAIS-POLICY-1783705261-attempt-1.md b/.forge/BAIS-POLICY-1783705261-attempt-3.md similarity index 60% rename from .forge/BAIS-POLICY-1783705261-attempt-1.md rename to .forge/BAIS-POLICY-1783705261-attempt-3.md index 53daa39..9f2d8e5 100644 --- a/.forge/BAIS-POLICY-1783705261-attempt-1.md +++ b/.forge/BAIS-POLICY-1783705261-attempt-3.md @@ -1,3 +1,3 @@ -# BAIS-POLICY-1783705261-attempt-1 +# BAIS-POLICY-1783705261-attempt-3 -Forge 이슈 작업 브랜치 `forge/BAIS-POLICY-1783705261-attempt-1`. +Forge 이슈 작업 브랜치 `forge/BAIS-POLICY-1783705261-attempt-3`. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1d4db07 --- /dev/null +++ b/pom.xml @@ -0,0 +1,39 @@ + + 4.0.0 + com.example.baispolicy + bais-policy + 1.0-SNAPSHOT + jar + + + org.springframework.boot + spring-boot-starter-parent + 3.5.14 + + + + + 17 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/com/example/baispolicy/PaymentService.java b/src/main/java/com/example/baispolicy/PaymentService.java index f5f9ae7..420d154 100644 --- a/src/main/java/com/example/baispolicy/PaymentService.java +++ b/src/main/java/com/example/baispolicy/PaymentService.java @@ -3,8 +3,8 @@ package com.example.baispolicy; public class PaymentService { public String approve(String transactionId) { if (transactionId == null || transactionId.isBlank()) { - throw new IllegalArgumentException("Transaction ID cannot be blank"); + throw new IllegalArgumentException("Transaction ID must not be blank."); } return "APPROVED:" + transactionId; } -} \ No newline at end of file +} diff --git a/src/test/java/com/example/baispolicy/PaymentServiceTest.java b/src/test/java/com/example/baispolicy/PaymentServiceTest.java new file mode 100644 index 0000000..e29ee02 --- /dev/null +++ b/src/test/java/com/example/baispolicy/PaymentServiceTest.java @@ -0,0 +1,25 @@ +package com.example.baispolicy; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class PaymentServiceTest { + private final PaymentService paymentService = new PaymentService(); + + @Test + void testApprove_WithValidTransactionId_ShouldReturnApprovedMessage() { + String transactionId = "12345"; + String result = paymentService.approve(transactionId); + assertEquals("APPROVED:12345", result); + } + + @Test + void testApprove_WithBlankTransactionId_ShouldThrowException() { + assertThrows(IllegalArgumentException.class, () -> { + paymentService.approve(""); + }); + assertThrows(IllegalArgumentException.class, () -> { + paymentService.approve(null); + }); + } +}