feat: finalize AI analyzer, sync endpoints, and stabilize builds

This commit is contained in:
2026-05-19 12:27:08 +07:00
parent f697ef16cd
commit 23d0cf6f66
23 changed files with 375 additions and 142 deletions
@@ -114,6 +114,16 @@ public class UserController {
"SOS dikirim! Guardian sudah diberitahu."));
}
@GetMapping("/sos-events")
public ResponseEntity<ApiResponse<Page<SosEventResponse>>> getSosEvents(
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) {
return ResponseEntity.ok(ApiResponse.ok(
sosService.getSosEvents(SecurityHelper.getCurrentUserId(),
PageRequest.of(page, size)),
"Riwayat SOS"));
}
@GetMapping("/activity-logs")
public ResponseEntity<ApiResponse<Page<ActivityLogResponse>>> getActivityLogs(
@RequestParam(defaultValue = "0") int page,
@@ -183,6 +183,10 @@ paths:
post:
responses:
"200": { description: SOS triggered }
/user/sos-events:
get:
responses:
"200": { description: User SOS history }
/user/activity-logs:
get:
responses:
@@ -1,11 +1,23 @@
package com.walkguide;
import com.walkguide.config.DataSeeder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
@SpringBootTest
@SpringBootTest(properties = {
"spring.datasource.url=jdbc:postgresql://localhost:5432/walkguide_test",
"spring.datasource.username=test",
"spring.datasource.password=test",
"spring.flyway.enabled=false",
"spring.jpa.hibernate.ddl-auto=none",
"jwt.secret=404E635266556A586E3272357538782F413F4428472B4B6250645367566B5970"
})
class DemoApplicationTests {
@MockBean
private DataSeeder dataSeeder;
@Test
void contextLoads() {
}
@@ -281,6 +281,26 @@ class UserControllerTest {
}
}
@Test
@DisplayName("GET /api/v1/user/sos-events - harus return paginated riwayat SOS user")
void getSosEvents_shouldReturn200() throws Exception {
try (MockedStatic<SecurityHelper> sh = mockStatic(SecurityHelper.class)) {
sh.when(SecurityHelper::getCurrentUserId).thenReturn(1L);
Page<SosEventResponse> page = new PageImpl<>(List.of());
when(sosService.getSosEvents(eq(1L), any(PageRequest.class))).thenReturn(page);
mockMvc.perform(get("/api/v1/user/sos-events")
.param("page", "0")
.param("size", "10"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.message").value("Riwayat SOS"));
verify(sosService).getSosEvents(eq(1L), any(PageRequest.class));
}
}
// ===== ACTIVITY LOGS =====
@Test