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); + }); + } +}