fix: invite registration on an event day does not mark attendance
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
fbbc5d0980
commit
c6d94fea67
3 files changed
+83
-2
No files matched your search
+79
@@ -0,0 +1,79 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.model.Event;
|
||||
import com.solvway.services.counter.model.EventLead;
|
||||
import com.solvway.services.counter.model.Lead;
|
||||
import com.solvway.services.counter.repo.EventGuestRepository;
|
||||
import com.solvway.services.counter.repo.EventLeadInterestRepository;
|
||||
import com.solvway.services.counter.repo.EventLeadRepository;
|
||||
import com.solvway.services.counter.repo.EventLeadStatusChangeRepository;
|
||||
import com.solvway.services.counter.repo.EventRepository;
|
||||
import com.solvway.services.counter.repo.LeadRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.AdditionalAnswers.returnsFirstArg;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Spec "Attendance at capture": staff capture, walk-in QR and check-in capture on the event days set attended.
|
||||
* An invite link is personal and can be opened anywhere, so registering by invite never does: the guest checks in.
|
||||
*/
|
||||
class InviteRegistrationAttendanceTest {
|
||||
|
||||
private static final long EVENT = 1000L;
|
||||
private final EventLeadRepository eventLeads = mock(EventLeadRepository.class);
|
||||
private RegistrationService registration;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
LeadRepository leads = mock(LeadRepository.class);
|
||||
EventRepository events = mock(EventRepository.class);
|
||||
Event today = new Event();
|
||||
today.setDateStart(LocalDateTime.now().minusHours(1));
|
||||
today.setDateEnd(LocalDateTime.now().plusDays(1));
|
||||
when(events.findByUuid(EVENT)).thenReturn(Optional.of(today));
|
||||
when(leads.saveAndFlush(any(Lead.class))).then(returnsFirstArg());
|
||||
when(eventLeads.saveAndFlush(any(EventLead.class))).then(i -> {
|
||||
EventLead e = i.getArgument(0);
|
||||
e.setId(1L);
|
||||
return e;
|
||||
});
|
||||
GuestLinker linker = new GuestLinker(mock(EventGuestRepository.class));
|
||||
EventLeadService eventLeadService = new EventLeadService(leads, eventLeads, mock(EventLeadInterestRepository.class),
|
||||
mock(EventLeadStatusChangeRepository.class), events, linker);
|
||||
registration = new RegistrationService(new TransactionTemplate(mock(PlatformTransactionManager.class)),
|
||||
leads, eventLeads, eventLeadService, linker);
|
||||
}
|
||||
|
||||
private EventLead saved() {
|
||||
ArgumentCaptor<EventLead> c = ArgumentCaptor.forClass(EventLead.class);
|
||||
verify(eventLeads).saveAndFlush(c.capture());
|
||||
return c.getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void inviteRegistrationOnAnEventDayIsNotAttended() {
|
||||
registration.register(new RegistrationService.RegisterRequest(42L, EVENT, 7L, "Tan", "+60125550101", null, null, null,
|
||||
List.of(), null, null, false, "INVITE", null));
|
||||
assertThat(saved().getAttendedAt()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void qrRegistrationOnAnEventDayIsAttended() {
|
||||
registration.register(new RegistrationService.RegisterRequest(42L, EVENT, 7L, "Tan", "+60125550101", null, null, null,
|
||||
List.of(), null, null));
|
||||
assertThat(saved().getAttendedAt()).isNotNull();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user