feat: event lead rows carry attendance and source, with an attended filter

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 21:31:03 +08:00
1 parent cba2929a00
commit 3af5cccd59
16 files changed
+160 -55

No files matched your search

@@ -53,7 +53,7 @@ class EventLeadControllerTest {
@Test
void findByEventDelegates() {
EventLeadSearchRequest req = new EventLeadSearchRequest(42L, 1L, null, null, null, null, null, 0, 20);
EventLeadSearchRequest req = new EventLeadSearchRequest(42L, 1L, null, null, null, null, null, null, 0, 20);
Page<EventLeadDetail> out = Page.empty();
when(service.search(req)).thenReturn(out);
@@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.never;
@@ -61,13 +62,13 @@ class EventLeadListAndUpdateTest {
@Test
void listingPassesEveryFilterAndPagesNewestCaptureFirstWithIdTieBreak() {
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), eq(11L), eq("HOT"), eq("OPEN"), eq(3L), eq("NEW"), any()))
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), eq(11L), eq("HOT"), eq("OPEN"), eq(3L), eq("NEW"), eq(null), any()))
.thenReturn(Page.empty());
service.search(new EventLeadSearchRequest(COMPANY, EVENT, 11L, "HOT", "OPEN", 3L, "NEW", 2, 25));
service.search(new EventLeadSearchRequest(COMPANY, EVENT, 11L, "HOT", "OPEN", 3L, "NEW", null, 2, 25));
ArgumentCaptor<Pageable> pageable = ArgumentCaptor.forClass(Pageable.class);
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(11L), eq("HOT"), eq("OPEN"), eq(3L), eq("NEW"), pageable.capture());
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(11L), eq("HOT"), eq("OPEN"), eq(3L), eq("NEW"), eq(null), pageable.capture());
assertThat(pageable.getValue().getPageNumber()).isEqualTo(2);
assertThat(pageable.getValue().getPageSize()).isEqualTo(25);
assertThat(pageable.getValue().getSort().toString()).isEqualTo("capturedAt: DESC,id: DESC");
@@ -75,13 +76,13 @@ class EventLeadListAndUpdateTest {
@Test
void blankFiltersAreIgnoredAndPageSizeIsBounded() {
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), any()))
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), any()))
.thenReturn(Page.empty());
service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, " ", "", null, null, -1, 1000));
service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, " ", "", null, null, null, -1, 1000));
ArgumentCaptor<Pageable> pageable = ArgumentCaptor.forClass(Pageable.class);
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), pageable.capture());
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), pageable.capture());
assertThat(pageable.getValue().getPageNumber()).isZero();
assertThat(pageable.getValue().getPageSize()).isEqualTo(100);
}
@@ -92,12 +93,12 @@ class EventLeadListAndUpdateTest {
EventLead b = eventLead(2L, 502L);
Lead la = lead(501L, "Aisyah");
Lead lb = lead(502L, "Ahmad");
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), any(), any(), any(), any(), any(), any()))
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), any(), any(), any(), any(), any(), any(), any()))
.thenReturn(new PageImpl<>(List.of(new Object[]{a, la}, new Object[]{b, lb}), PageRequest.of(0, 20), 2));
when(eventLeadInterestRepository.findByIdEventLeadIdIn(anyCollection()))
.thenReturn(List.of(row(1L, 3L), row(1L, 4L), row(2L, 3L)));
Page<EventLeadDetail> page = service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, 0, 20));
Page<EventLeadDetail> page = service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, null, 0, 20));
assertThat(page.getTotalElements()).isEqualTo(2);
assertThat(page.getContent()).extracting(EventLeadDetail::name).containsExactly("Aisyah", "Ahmad");
@@ -107,10 +108,56 @@ class EventLeadListAndUpdateTest {
}
@Test
void emptyPageSkipsTheInterestQuery() {
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), any(), any(), any(), any(), any(), any())).thenReturn(Page.empty());
void attendedFilterIsPassedToTheQuery() {
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(), any())).thenReturn(Page.empty());
assertThat(service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, 0, 20)).getContent()).isEmpty();
service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, true, 0, 20));
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), eq(true), any());
}
@Test
void notAttendedFilterIsPassedToTheQuery() {
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(), any())).thenReturn(Page.empty());
service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, false, 0, 20));
verify(eventLeadRepository).search(eq(COMPANY), eq(EVENT), eq(null), eq(null), eq(null), eq(null), eq(null), eq(false), any());
}
@Test
void listingRowsReportAttendanceAndSource() {
EventLead a = eventLead(1L, 501L);
a.setAttendedAt(java.time.LocalDateTime.of(2027, 1, 20, 9, 30));
a.setSource("INVITE");
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(), any()))
.thenReturn(new PageImpl<>(List.<Object[]>of(new Object[]{a, lead(501L, "Aisyah")}), PageRequest.of(0, 20), 1));
when(eventLeadInterestRepository.findByIdEventLeadIdIn(anyCollection())).thenReturn(List.of());
EventLeadDetail d = service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, null, 0, 20)).getContent().get(0);
assertThat(d.attendedAt()).isEqualTo(java.time.LocalDateTime.of(2027, 1, 20, 9, 30));
assertThat(d.source()).isEqualTo("INVITE");
}
@Test
void detailReportsNoAttendanceAndDefaultSource() {
EventLead e = eventLead(1L, 501L);
when(eventLeadRepository.findByUuidAndCompanyId(7L, COMPANY)).thenReturn(java.util.Optional.of(e));
when(leadRepository.findByUuidAndCompanyId(501L, COMPANY)).thenReturn(java.util.Optional.of(lead(501L, "Aisyah")));
when(eventLeadInterestRepository.findByIdEventLeadId(1L)).thenReturn(List.of());
EventLeadDetail d = service.findByUuid(COMPANY, 7L);
assertThat(d.attendedAt()).isNull();
assertThat(d.source()).isEqualTo("STAFF");
}
@Test
void emptyPageSkipsTheInterestQuery() {
when(eventLeadRepository.search(eq(COMPANY), eq(EVENT), any(), any(), any(), any(), any(), any(), any())).thenReturn(Page.empty());
assertThat(service.search(new EventLeadSearchRequest(COMPANY, EVENT, null, null, null, null, null, null, 0, 20)).getContent()).isEmpty();
verify(eventLeadInterestRepository, never()).findByIdEventLeadIdIn(anyCollection());
}
@@ -96,18 +96,18 @@ class LeadCompanyScopeTest {
@Test
void eventLeadSearchWithoutCompanyPassesNullMeaningAll() {
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(Pageable.class)))
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(), any(Pageable.class)))
.thenReturn(Page.empty());
eventLeadService.search(new EventLeadSearchRequest(null, 9L, null, null, null, null, null, 0, 20));
verify(eventLeadRepository).search(eq(null), eq(9L), any(), any(), any(), any(), any(), any(Pageable.class));
eventLeadService.search(new EventLeadSearchRequest(null, 9L, null, null, null, null, null, null, 0, 20));
verify(eventLeadRepository).search(eq(null), eq(9L), any(), any(), any(), any(), any(), any(), any(Pageable.class));
}
@Test
void eventLeadSearchWithCompanyStillFilters() {
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(Pageable.class)))
when(eventLeadRepository.search(any(), anyLong(), any(), any(), any(), any(), any(), any(), any(Pageable.class)))
.thenReturn(Page.empty());
eventLeadService.search(new EventLeadSearchRequest(COMPANY, 9L, null, null, null, null, null, 0, 20));
verify(eventLeadRepository).search(eq(COMPANY), eq(9L), any(), any(), any(), any(), any(), any(Pageable.class));
eventLeadService.search(new EventLeadSearchRequest(COMPANY, 9L, null, null, null, null, null, null, 0, 20));
verify(eventLeadRepository).search(eq(COMPANY), eq(9L), any(), any(), any(), any(), any(), any(), any(Pageable.class));
}
// --- detail ---