feat: company-scoped events, leads, event leads and exports
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
de2ae63cea
commit
ec504fd529
31 files changed
+1096
-190
No files matched your search
+3
-3
@@ -72,16 +72,16 @@ class AdminEventControllerTest {
|
||||
|
||||
@Test
|
||||
void list_passesQueryParamsAndDefaults() throws Exception {
|
||||
when(events.list(any(), any(), eq(0), eq(20), any(), any())).thenReturn(Map.of("content", List.of(row()), "totalElements", 1));
|
||||
when(events.list(any(), any(), eq(0), eq(20), any(), any(), any())).thenReturn(Map.of("content", List.of(row()), "totalElements", 1));
|
||||
mvc.perform(get("/api/admin/events").param("q", "food").param("enabled", "Y").param("sortBy", "endDate").param("sortDir", "desc"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().json("{\"content\":[{\"uuid\":\"7123456789012345678\"}],\"totalElements\":1}"));
|
||||
verify(events).list("food", "Y", 0, 20, "endDate", "desc");
|
||||
verify(events).list("food", "Y", 0, 20, "endDate", "desc", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void salespersonOptions_isNotShadowedByTheUuidRoute() throws Exception {
|
||||
when(events.salespersonOptions()).thenReturn(List.of(Map.of("id", 1, "name", "Amy", "username", "amy")));
|
||||
when(events.salespersonOptions(null)).thenReturn(List.of(Map.of("id", 1, "name", "Amy", "username", "amy")));
|
||||
mvc.perform(get("/api/admin/events/salesperson-options")).andExpect(status().isOk())
|
||||
.andExpect(content().json("[{\"id\":1,\"name\":\"Amy\",\"username\":\"amy\"}]"));
|
||||
}
|
||||
|
||||
+5
-5
@@ -59,7 +59,7 @@ class AdminEventLeadControllerTest {
|
||||
|
||||
@Test
|
||||
void optionsEndpoints() throws Exception {
|
||||
when(eventLeads.events()).thenReturn(List.of(Map.of("uuid", EV, "name", "Fair")));
|
||||
when(eventLeads.events(null)).thenReturn(List.of(Map.of("uuid", EV, "name", "Fair")));
|
||||
mvc.perform(get("/api/admin/event-leads/events")).andExpect(status().isOk())
|
||||
.andExpect(content().json("[{\"uuid\":\"" + EV + "\",\"name\":\"Fair\"}]", true));
|
||||
when(eventLeads.interestOptions()).thenReturn(List.of(Map.of("id", 3, "name", "Cookware", "active", true)));
|
||||
@@ -85,15 +85,15 @@ class AdminEventLeadControllerTest {
|
||||
|
||||
@Test
|
||||
void listPassesFiltersAndPaging() throws Exception {
|
||||
when(eventLeads.list(EV, 21L, "HOT", "OPEN", 3L, "NEW", 1, 25)).thenReturn(Map.of("content", List.of(), "totalElements", 0));
|
||||
when(eventLeads.list(EV, 21L, "HOT", "OPEN", 3L, "NEW", 1, 25, null)).thenReturn(Map.of("content", List.of(), "totalElements", 0));
|
||||
mvc.perform(get("/api/admin/event-leads/" + EV + "/leads").param("salespersonId", "21").param("temperature", "HOT")
|
||||
.param("status", "OPEN").param("interestId", "3").param("leadType", "NEW").param("page", "1").param("size", "25"))
|
||||
.andExpect(status().isOk());
|
||||
verify(eventLeads).list(EV, 21L, "HOT", "OPEN", 3L, "NEW", 1, 25);
|
||||
verify(eventLeads).list(EV, 21L, "HOT", "OPEN", 3L, "NEW", 1, 25, null);
|
||||
|
||||
when(eventLeads.list(EV, null, null, null, null, null, 0, 20)).thenReturn(Map.of("content", List.of()));
|
||||
when(eventLeads.list(EV, null, null, null, null, null, 0, 20, null)).thenReturn(Map.of("content", List.of()));
|
||||
mvc.perform(get("/api/admin/event-leads/" + EV + "/leads")).andExpect(status().isOk());
|
||||
verify(eventLeads).list(EV, null, null, null, null, null, 0, 20);
|
||||
verify(eventLeads).list(EV, null, null, null, null, null, 0, 20, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ class AdminLeadControllerTest {
|
||||
|
||||
@Test
|
||||
void listDefaultsPagingAndPassesQuery() throws Exception {
|
||||
when(leads.list("ai", 0, 20)).thenReturn(Map.of("content", java.util.List.of(), "totalElements", 0));
|
||||
when(leads.list("ai", 0, 20, null)).thenReturn(Map.of("content", java.util.List.of(), "totalElements", 0));
|
||||
mvc.perform(get("/api/admin/leads").param("q", "ai")).andExpect(status().isOk())
|
||||
.andExpect(content().json("{\"content\":[],\"totalElements\":0}"));
|
||||
}
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ class AdminLeadExportControllerTest {
|
||||
@Test
|
||||
void leadExportReturnsTheFileWithHeaders() throws Exception {
|
||||
AdminLeadService leads = mock(AdminLeadService.class);
|
||||
when(leads.export("ai")).thenReturn(new byte[]{1, 2, 3});
|
||||
when(leads.export("ai", null)).thenReturn(new byte[]{1, 2, 3});
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(new AdminLeadController(leads)).build();
|
||||
mvc.perform(get("/api/admin/leads/export").param("q", "ai")).andExpect(status().isOk())
|
||||
.andExpect(header().string("Content-Type", XLSX))
|
||||
@@ -56,7 +56,7 @@ class AdminLeadExportControllerTest {
|
||||
@Test
|
||||
void eventLeadExportPassesFiltersAndNamesTheFile() throws Exception {
|
||||
AdminEventLeadService svc = mock(AdminEventLeadService.class);
|
||||
when(svc.export("77", 22L, "HOT", "OPEN", 3L, "NEW")).thenReturn(new byte[]{9});
|
||||
when(svc.export("77", 22L, "HOT", "OPEN", 3L, "NEW", null)).thenReturn(new byte[]{9});
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(new AdminEventLeadExportController(svc)).build();
|
||||
mvc.perform(get("/api/admin/event-leads/77/export").param("salespersonId", "22").param("temperature", "HOT")
|
||||
.param("status", "OPEN").param("interestId", "3").param("leadType", "NEW")).andExpect(status().isOk())
|
||||
@@ -70,7 +70,7 @@ class AdminLeadExportControllerTest {
|
||||
// The service accepts " 77\r\n" (it trims before parsing); none of those characters may reach the header.
|
||||
AdminEventLeadService svc = mock(AdminEventLeadService.class);
|
||||
when(svc.export(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any(),
|
||||
org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any())).thenReturn(new byte[]{9});
|
||||
org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any())).thenReturn(new byte[]{9});
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(new AdminEventLeadExportController(svc)).build();
|
||||
mvc.perform(get("/api/admin/event-leads/{uuid}/export", " 77\r\n")).andExpect(status().isOk())
|
||||
.andExpect(header().string("Content-Disposition", org.hamcrest.Matchers.matchesPattern("attachment; filename=\"event-leads-77-\\d{8}-\\d{4}\\.xlsx\"")));
|
||||
|
||||
Reference in new issue
Block a user