Extract CountAttendeesByEventUseCase to decouple controller from repository

The EventController was directly accessing RsvpRepository (an outbound port)
to count attendees, bypassing the application layer. Introduce a dedicated
inbound port and implement it in RsvpService. Remove the now-unused Clock
dependency from RsvpService.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 12:04:51 +01:00
parent a625e34fe4
commit fc77248c38
4 changed files with 28 additions and 19 deletions

View File

@@ -12,8 +12,6 @@ import de.fete.domain.model.OrganizerToken;
import de.fete.domain.model.Rsvp;
import de.fete.domain.port.out.EventRepository;
import de.fete.domain.port.out.RsvpRepository;
import java.time.Clock;
import java.time.Instant;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.ZoneId;
@@ -30,9 +28,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
class RsvpServiceTest {
private static final ZoneId ZONE = ZoneId.of("Europe/Berlin");
private static final Instant FIXED_INSTANT =
LocalDate.of(2026, 3, 5).atStartOfDay(ZONE).toInstant();
private static final Clock FIXED_CLOCK = Clock.fixed(FIXED_INSTANT, ZONE);
@Mock
private EventRepository eventRepository;
@@ -44,7 +39,7 @@ class RsvpServiceTest {
@BeforeEach
void setUp() {
rsvpService = new RsvpService(eventRepository, rsvpRepository, FIXED_CLOCK);
rsvpService = new RsvpService(eventRepository, rsvpRepository);
}
@Test
@@ -109,7 +104,7 @@ class RsvpServiceTest {
event.setDateTime(OffsetDateTime.of(2026, 6, 15, 20, 0, 0, 0, ZoneOffset.ofHours(2)));
event.setTimezone(ZONE);
event.setExpiryDate(LocalDate.of(2026, 7, 15));
event.setCreatedAt(OffsetDateTime.now(FIXED_CLOCK));
event.setCreatedAt(OffsetDateTime.now());
return event;
}
}