diff --git a/.forge/BAIS-POLICY-1783705261-attempt-3.md b/.forge/BAIS-POLICY-1783705261-attempt-3.md new file mode 100644 index 0000000..9f2d8e5 --- /dev/null +++ b/.forge/BAIS-POLICY-1783705261-attempt-3.md @@ -0,0 +1,3 @@ +# BAIS-POLICY-1783705261-attempt-3 + +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 new file mode 100644 index 0000000..420d154 --- /dev/null +++ b/src/main/java/com/example/baispolicy/PaymentService.java @@ -0,0 +1,10 @@ +package com.example.baispolicy; + +public class PaymentService { + public String approve(String transactionId) { + if (transactionId == null || transactionId.isBlank()) { + throw new IllegalArgumentException("Transaction ID must not be blank."); + } + return "APPROVED:" + transactionId; + } +} 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); + }); + } +}