PaymentService 승인 규칙 구현 #5

Merged
forge-bot merged 4 commits from forge/BAIS-SOURCE-1783702539-attempt-1 into main 2026-07-10 16:59:39 +00:00
4 changed files with 50 additions and 7 deletions

View file

@ -0,0 +1,3 @@
# BAIS-SOURCE-1783702539-attempt-1
Forge 이슈 작업 브랜치 `forge/BAIS-SOURCE-1783702539-attempt-1`.

10
pom.xml
View file

@ -1,17 +1,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>bais-gate-e2e</artifactId>
<version>1.0.0</version>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
@ -22,7 +20,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View file

@ -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;
}
}

View 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());
}
}