Merge pull request 'PaymentService 승인 규칙 구현' (#5) from forge/BAIS-SOURCE-1783702539-attempt-1 into main

This commit is contained in:
forge-bot 2026-07-10 16:59:38 +00:00
commit fec4828f0d
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`.

12
pom.xml
View file

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

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