Compare commits
5 commits
forge/BAIS
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 64570f0082 | |||
| 861121ef3b | |||
| 1d34b48888 | |||
| 0294bea574 | |||
| 175e5ed093 |
4 changed files with 68 additions and 4 deletions
|
|
@ -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`.
|
||||||
39
pom.xml
Normal file
39
pom.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<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.baispolicy</groupId>
|
||||||
|
<artifactId>bais-policy</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.5.14</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
|
|
@ -3,8 +3,8 @@ package com.example.baispolicy;
|
||||||
public class PaymentService {
|
public class PaymentService {
|
||||||
public String approve(String transactionId) {
|
public String approve(String transactionId) {
|
||||||
if (transactionId == null || transactionId.isBlank()) {
|
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;
|
return "APPROVED:" + transactionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
src/test/java/com/example/baispolicy/PaymentServiceTest.java
Normal file
25
src/test/java/com/example/baispolicy/PaymentServiceTest.java
Normal file
|
|
@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue