chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
e396568cc3
commit
5ee51d1913
2918 files changed
+302373
-3
No files matched your search
+65
@@ -0,0 +1,65 @@
|
||||
package com.solvway.services.system.controller;
|
||||
|
||||
import com.solvway.services.system.model.AppBanner;
|
||||
import com.solvway.services.system.service.AppBannerService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AppBannerControllerTest {
|
||||
|
||||
@Mock
|
||||
private AppBannerService appBannerService;
|
||||
@InjectMocks
|
||||
private AppBannerController controller;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
}
|
||||
|
||||
private AppBanner banner(long id, String message) {
|
||||
AppBanner b = new AppBanner();
|
||||
b.setId(id);
|
||||
b.setMessage(message);
|
||||
b.setStyle("INFO");
|
||||
b.setEnabled(true);
|
||||
return b;
|
||||
}
|
||||
|
||||
@Test
|
||||
void findActiveReturnsActiveBanners() throws Exception {
|
||||
when(appBannerService.findActive(any())).thenReturn(List.of(banner(1L, "Grand sale")));
|
||||
|
||||
mvc.perform(get("/system/appBanner/findActive"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].message").value("Grand sale"))
|
||||
.andExpect(jsonPath("$[0].style").value("INFO"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void findAllReturnsList() throws Exception {
|
||||
when(appBannerService.findAll()).thenReturn(List.of(banner(2L, "Notice")));
|
||||
|
||||
mvc.perform(get("/system/appBanner/findAll"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].id").value(2))
|
||||
.andExpect(jsonPath("$[0].message").value("Notice"));
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.solvway.services.system.controller;
|
||||
|
||||
import com.solvway.services.system.model.AppPromo;
|
||||
import com.solvway.services.system.service.AppPromoService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class AppPromoControllerTest {
|
||||
|
||||
@Mock
|
||||
private AppPromoService appPromoService;
|
||||
@InjectMocks
|
||||
private AppPromoController controller;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
}
|
||||
|
||||
private AppPromo promo(long id, String mediaUrl) {
|
||||
AppPromo p = new AppPromo();
|
||||
p.setId(id);
|
||||
p.setMediaType("IMAGE");
|
||||
p.setMediaUrl(mediaUrl);
|
||||
p.setEnabled(true);
|
||||
return p;
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveReturnsSavedPromo() throws Exception {
|
||||
when(appPromoService.save(any())).thenReturn(promo(1L, "app-promo/img1.jpg"));
|
||||
|
||||
mvc.perform(post("/system/appPromo/save")
|
||||
.contentType(APPLICATION_JSON)
|
||||
.content("{\"mediaType\":\"IMAGE\",\"mediaUrl\":\"app-promo/img1.jpg\"}"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id").value(1))
|
||||
.andExpect(jsonPath("$.mediaUrl").value("app-promo/img1.jpg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void findAllReturnsList() throws Exception {
|
||||
when(appPromoService.findAll()).thenReturn(List.of(promo(2L, "app-promo/img2.jpg")));
|
||||
|
||||
mvc.perform(get("/system/appPromo/findAll"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].id").value(2))
|
||||
.andExpect(jsonPath("$[0].mediaUrl").value("app-promo/img2.jpg"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByIdReturnsPromo() throws Exception {
|
||||
when(appPromoService.findById(eq(3L))).thenReturn(Optional.of(promo(3L, "app-promo/img3.jpg")));
|
||||
|
||||
mvc.perform(get("/system/appPromo/findById/3"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id").value(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeByIdReturnsCount() throws Exception {
|
||||
when(appPromoService.removeById(eq(4L))).thenReturn(1L);
|
||||
|
||||
mvc.perform(get("/system/appPromo/removeById/4"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$").value(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void findActiveReturnsActivePromos() throws Exception {
|
||||
when(appPromoService.findActive(any())).thenReturn(List.of(promo(5L, "app-promo/img5.jpg")));
|
||||
|
||||
mvc.perform(get("/system/appPromo/findActive"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].id").value(5))
|
||||
.andExpect(jsonPath("$[0].mediaUrl").value("app-promo/img5.jpg"));
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.solvway.services.system.controller;
|
||||
|
||||
import com.solvway.core.enums.GeolocationEnum.GeolocationType;
|
||||
import com.solvway.services.system.model.GeoLocationHierarchy;
|
||||
import com.solvway.services.system.service.ConfigCountryService;
|
||||
import com.solvway.services.system.service.GeoLocationHierarchyService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class GeoLocationHierarchyControllerPostCodeTest {
|
||||
|
||||
@Mock
|
||||
private GeoLocationHierarchyService geoLcationHierarchyService;
|
||||
@Mock
|
||||
private ConfigCountryService configCountryService;
|
||||
@Mock
|
||||
private ModelMapper modelMapper;
|
||||
@InjectMocks
|
||||
private GeoLocationHierarchyController controller;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
}
|
||||
|
||||
private GeoLocationHierarchy town(long id, String name, String postCode) {
|
||||
GeoLocationHierarchy g = new GeoLocationHierarchy();
|
||||
g.setId(id);
|
||||
g.setName(name);
|
||||
g.setParentId(10L);
|
||||
g.setStatus("Y");
|
||||
g.setType(GeolocationType.T);
|
||||
g.setPostCode(postCode);
|
||||
return g;
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByParentIdExposesPostCode() throws Exception {
|
||||
when(geoLcationHierarchyService.findByParentId(10L))
|
||||
.thenReturn(List.of(town(10178L, "{\"en_US\": \"Bukit Jalil\"}", "57000")));
|
||||
|
||||
mvc.perform(get("/geoLocationHierarchy/findByParentId/10"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].postCode").value("57000"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByParentIdSerialisesNullPostCodeForUnknownTown() throws Exception {
|
||||
when(geoLcationHierarchyService.findByParentId(10L))
|
||||
.thenReturn(List.of(town(10173L, "{\"en_US\": \"Bangsar\"}", null)));
|
||||
|
||||
mvc.perform(get("/geoLocationHierarchy/findByParentId/10"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0].postCode").value(nullValue()));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.solvway.services.system.controller;
|
||||
|
||||
import com.solvway.services.system.constant.SystemConstants.Area;
|
||||
import com.solvway.services.system.service.MessageService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class MessageControllerCatalogTest {
|
||||
|
||||
@Mock
|
||||
private MessageService messageService;
|
||||
@Mock
|
||||
private ModelMapper modelMapper;
|
||||
@InjectMocks
|
||||
private MessageController controller;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
mvc = MockMvcBuilders.standaloneSetup(controller).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsCatalogForAreaAndLocale() throws Exception {
|
||||
when(messageService.getMessageJsonByAreaAndLocale(Area.A, "en_US"))
|
||||
.thenReturn(Map.of("FirstName", "First Name"));
|
||||
|
||||
mvc.perform(get("/message/getMessageJsonByAreaAndLocale/A/en_US"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.FirstName").value("First Name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void returns400ForUnknownArea() throws Exception {
|
||||
mvc.perform(get("/message/getMessageJsonByAreaAndLocale/BOGUS/en_US"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user