fix(mobile-api): tell Spring which AdminDashboardService constructor to use

With a second, package-private constructor for a test clock, Spring found
no default constructor and mobile-api failed to start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 10:32:25 +08:00
1 parent 5eead327a6
commit 5ffd4176ec
3 files changed
+30 -3

No files matched your search

+3 -3
View File
@@ -20,7 +20,7 @@ Waves:
## 2. services-counter
- [ ] 2.1 Status history writes (decision 1) and the dashboard endpoint (decisions 2 to 4).
- [x] 2.1 Status history writes (decision 1) and the dashboard endpoint (decisions 2 to 4).
- Tests first:
- capture saves one history row null → initial status at the capture time, by doneBy;
- update saves one row when the status changes and none when it stays;
@@ -31,7 +31,7 @@ Waves:
## 3. mobile-api
- [ ] 3.1 `GET /api/admin/dashboard/leads` (decision 5).
- [x] 3.1 `GET /api/admin/dashboard/leads` (decision 5).
- Tests first:
- default period is this Malaysian month to today; DAY bucket up to 62 days, MONTH above;
- bad date and from after to → 400 `INVALID_PERIOD`;
@@ -43,7 +43,7 @@ Waves:
## 4. Portal
- [ ] 4.1 Home page dashboard (decision 7).
- [x] 4.1 Home page dashboard (decision 7).
- Tests first:
- without `BO_DASHBOARD` the welcome shows and the dashboard API is not called;
- with it: tiles, funnel, chart container, the three tables with Unassigned, whole-percent rates and "–" for null median and zero captures;
@@ -6,6 +6,7 @@ import com.solvway.mobile.api.constant.api.RestApiCounterServiceConstants;
import com.solvway.mobile.api.constant.api.RestApiSystemServiceConstants;
import com.solvway.mobile.api.useraccess.AdminCompanyScope;
import com.solvway.mobile.api.util.RestTemplateCustomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@@ -34,6 +35,7 @@ public class AdminDashboardService {
private final AdminCompanyScope scope;
private final Clock clock;
@Autowired
public AdminDashboardService(RestTemplateCustomUtil restTemplateUtil, AdminAuthenticationService adminAuthenticationService, AdminCompanyScope scope) {
this(restTemplateUtil, adminAuthenticationService, scope, Clock.systemUTC());
}
@@ -0,0 +1,25 @@
package com.solvway.mobile.api.service;
import com.solvway.mobile.api.useraccess.AdminCompanyScope;
import com.solvway.mobile.api.util.RestTemplateCustomUtil;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
/** Two constructors (one for a test clock): Spring must still know which one to use, or mobile-api fails to start. */
class AdminDashboardServiceWiringTest {
@Test
void springCreatesTheService() {
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
ctx.registerBean(RestTemplateCustomUtil.class, () -> mock(RestTemplateCustomUtil.class));
ctx.registerBean(AdminAuthenticationService.class, () -> mock(AdminAuthenticationService.class));
ctx.registerBean(AdminCompanyScope.class);
ctx.register(AdminDashboardService.class);
ctx.refresh();
assertThat(ctx.getBean(AdminDashboardService.class)).isNotNull();
}
}
}