From 78ae57eb3953a9fe2f361dc235ab74c4a7b01885 Mon Sep 17 00:00:00 2001 From: Menkene Koufan Date: Fri, 18 Oct 2024 14:53:17 +0100 Subject: [PATCH] chore: created OBS module --- online-banking-service/.gitignore | 2 +- online-banking-service/pom.xml | 9 -------- .../obs/controller/OBSRestController.java | 13 +++++++++++ .../webank/obs/service/api/OBServiceAPI.java | 6 +++++ .../obs/service/impl/OBServiceImpl.java | 13 +++++++++++ .../OnlineBankingServiceApplicationTests.java | 11 +++++---- .../obs/controller/OBSRestControllerTest.java | 23 +++++++++++++++++++ 7 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 online-banking-service/src/main/java/com/adorsys/webank/obs/controller/OBSRestController.java create mode 100644 online-banking-service/src/main/java/com/adorsys/webank/obs/service/api/OBServiceAPI.java create mode 100644 online-banking-service/src/main/java/com/adorsys/webank/obs/service/impl/OBServiceImpl.java create mode 100644 online-banking-service/src/test/java/com/adorsys/webank/obs/controller/OBSRestControllerTest.java diff --git a/online-banking-service/.gitignore b/online-banking-service/.gitignore index 549e00a..ee6e957 100644 --- a/online-banking-service/.gitignore +++ b/online-banking-service/.gitignore @@ -14,7 +14,7 @@ target/ .sts4-cache ### IntelliJ IDEA ### -.idea +.idea/ *.iws *.iml *.ipr diff --git a/online-banking-service/pom.xml b/online-banking-service/pom.xml index 2699c34..7d5d46f 100644 --- a/online-banking-service/pom.xml +++ b/online-banking-service/pom.xml @@ -35,10 +35,6 @@ org.springframework.boot spring-boot-starter-web - - org.springframework.cloud - spring-cloud-starter-gateway - org.projectlombok @@ -50,11 +46,6 @@ spring-boot-starter-test test - - io.projectreactor - reactor-test - test - diff --git a/online-banking-service/src/main/java/com/adorsys/webank/obs/controller/OBSRestController.java b/online-banking-service/src/main/java/com/adorsys/webank/obs/controller/OBSRestController.java new file mode 100644 index 0000000..bdde2ef --- /dev/null +++ b/online-banking-service/src/main/java/com/adorsys/webank/obs/controller/OBSRestController.java @@ -0,0 +1,13 @@ +package com.adorsys.webank.obs.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class OBSRestController { + + @GetMapping("/message") + public String getMessage() { + return "Hello from OBService!"; + } +} diff --git a/online-banking-service/src/main/java/com/adorsys/webank/obs/service/api/OBServiceAPI.java b/online-banking-service/src/main/java/com/adorsys/webank/obs/service/api/OBServiceAPI.java new file mode 100644 index 0000000..6a3c995 --- /dev/null +++ b/online-banking-service/src/main/java/com/adorsys/webank/obs/service/api/OBServiceAPI.java @@ -0,0 +1,6 @@ +package com.adorsys.webank.obs.service.api; + + +public interface OBServiceAPI { + String getMessage(); +} diff --git a/online-banking-service/src/main/java/com/adorsys/webank/obs/service/impl/OBServiceImpl.java b/online-banking-service/src/main/java/com/adorsys/webank/obs/service/impl/OBServiceImpl.java new file mode 100644 index 0000000..b927ba8 --- /dev/null +++ b/online-banking-service/src/main/java/com/adorsys/webank/obs/service/impl/OBServiceImpl.java @@ -0,0 +1,13 @@ +package com.adorsys.webank.obs.service.impl; + +import com.adorsys.webank.obs.service.api.OBServiceAPI; +import org.springframework.stereotype.Service; + +@Service +public class OBServiceImpl implements OBServiceAPI { + + @Override + public String getMessage() { + return "Hello from OBService!"; + } +} diff --git a/online-banking-service/src/test/java/com/adorsys/webank/obs/OnlineBankingServiceApplicationTests.java b/online-banking-service/src/test/java/com/adorsys/webank/obs/OnlineBankingServiceApplicationTests.java index df95c41..04fa7c9 100644 --- a/online-banking-service/src/test/java/com/adorsys/webank/obs/OnlineBankingServiceApplicationTests.java +++ b/online-banking-service/src/test/java/com/adorsys/webank/obs/OnlineBankingServiceApplicationTests.java @@ -3,11 +3,12 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest -class OnlineBankingServiceApplicationTests { +@SpringBootTest(classes = OnlineBankingServiceApplication.class) // Specify main class +public class OnlineBankingServiceApplicationTests { @Test - void contextLoads() { + public void contextLoads() { + // This test intentionally does nothing. + // The @SpringBootTest annotation simulates application startup. } - -} +} \ No newline at end of file diff --git a/online-banking-service/src/test/java/com/adorsys/webank/obs/controller/OBSRestControllerTest.java b/online-banking-service/src/test/java/com/adorsys/webank/obs/controller/OBSRestControllerTest.java new file mode 100644 index 0000000..1b55be1 --- /dev/null +++ b/online-banking-service/src/test/java/com/adorsys/webank/obs/controller/OBSRestControllerTest.java @@ -0,0 +1,23 @@ +package com.adorsys.webank.obs.controller; + + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@WebMvcTest(OBSRestController.class) +public class OBSRestControllerTest { + + @Autowired + private MockMvc mockMvc; + + @Test + public void testGetMessage() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/message")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().string("Hello from OBService!")); + } +}