Skip to content

Commit dbcf058

Browse files
committed
Add more test classe
1 parent bf9e263 commit dbcf058

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
<img src="https://sonarcloud.io/api/project_badges/measure?project=vijayagopalsb_spring-dynamic-microservices&metric=security_rating" alt="Security"/>
5050
</a>
5151

52-
52+
<a href="https://sonarcloud.io/summary/overall?id=vijayagopalsb_spring-dynamic-microservices">
53+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vijayagopalsb_spring-dynamic-microservices&metric=coverage" alt="Coverage Badge"/>
54+
</a>
5355

5456
</p>
5557

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.example.paymentservicepaypal;
2+
public class PaymentService {
3+
public String process() {
4+
return "Success";
5+
}
6+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.example.paymentservicepaypal;
2+
3+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
4+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
5+
6+
import org.junit.jupiter.api.Test;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
9+
import org.springframework.test.web.servlet.MockMvc;
10+
11+
@WebMvcTest(TestController.class)
12+
public class PaymentControllerTest {
13+
14+
@Autowired
15+
private MockMvc mockMvc;
16+
17+
@Test
18+
void testGetPaymentStatus() throws Exception {
19+
mockMvc.perform(get("/api/payments/status"))
20+
.andExpect(status().isOk());
21+
}
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.paymentservicepaypal;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class PaymentServiceTest {
8+
@Test
9+
void shouldReturnSuccess() {
10+
PaymentService service = new PaymentService();
11+
assertEquals("Success", service.process());
12+
}
13+
}

0 commit comments

Comments
 (0)