feat(services-counter): capture, match, list and edit event leads
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
b75d636886
commit
48507979bd
20 files changed
+1183
-1
No files matched your search
+71
@@ -0,0 +1,71 @@
|
||||
package com.solvway.services.counter.controller;
|
||||
|
||||
import com.solvway.services.counter.dto.EventLeadCaptureRequest;
|
||||
import com.solvway.services.counter.dto.EventLeadDetail;
|
||||
import com.solvway.services.counter.dto.EventLeadSearchRequest;
|
||||
import com.solvway.services.counter.dto.EventLeadUpdateRequest;
|
||||
import com.solvway.services.counter.dto.LeadMatch;
|
||||
import com.solvway.services.counter.dto.LeadMatchRequest;
|
||||
import com.solvway.services.counter.service.EventLeadService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** EventLeadController delegates to the service and returns its result. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class EventLeadControllerTest {
|
||||
|
||||
@Mock private EventLeadService service;
|
||||
|
||||
@Test
|
||||
void findMatchesDelegates() {
|
||||
LeadMatchRequest req = new LeadMatchRequest(42L, 1L, "+60123456789", null);
|
||||
List<LeadMatch> out = List.of(new LeadMatch(2L, "Aisyah", "+60123456789", null, null, null, null));
|
||||
when(service.findMatches(req)).thenReturn(out);
|
||||
|
||||
assertThat(new EventLeadController(service).findMatches(req)).isSameAs(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void captureReturnsTheCapturedEventLead() {
|
||||
EventLeadCaptureRequest req = mock(EventLeadCaptureRequest.class);
|
||||
EventLeadDetail out = mock(EventLeadDetail.class);
|
||||
when(service.capture(req)).thenReturn(out);
|
||||
|
||||
assertThat(new EventLeadController(service).capture(req)).isSameAs(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByUuidDelegates() {
|
||||
EventLeadDetail out = mock(EventLeadDetail.class);
|
||||
when(service.findByUuid(42L, 9L)).thenReturn(out);
|
||||
|
||||
assertThat(new EventLeadController(service).findByUuid(42L, 9L)).isSameAs(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void findByEventDelegates() {
|
||||
EventLeadSearchRequest req = new EventLeadSearchRequest(42L, 1L, null, null, null, null, null, 0, 20);
|
||||
Page<EventLeadDetail> out = Page.empty();
|
||||
when(service.search(req)).thenReturn(out);
|
||||
|
||||
assertThat(new EventLeadController(service).findByEvent(req)).isSameAs(out);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDelegates() {
|
||||
EventLeadUpdateRequest req = mock(EventLeadUpdateRequest.class);
|
||||
EventLeadDetail out = mock(EventLeadDetail.class);
|
||||
when(service.update(req)).thenReturn(out);
|
||||
|
||||
assertThat(new EventLeadController(service).update(req)).isSameAs(out);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user