test(dashboard): add empty-queue guard and boundary tests for contributor cap

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-19 18:54:06 +02:00
committed by marcel
parent 812053cd6b
commit a3a9ad0471
2 changed files with 33 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ public class TranscriptionQueueService {
}
private List<TranscriptionQueueItemDTO> enrichWithContributors(List<TranscriptionQueueProjection> projections) {
if (projections.isEmpty()) return List.of();
List<UUID> ids = projections.stream().map(TranscriptionQueueProjection::getId).toList();
Map<UUID, List<ActivityActorDTO>> contributorMap = auditLogQueryService.findContributorsPerDocument(ids);
return projections.stream()

View File

@@ -53,6 +53,38 @@ class TranscriptionQueueServiceTest {
assertThat(result.get(0).annotationCount()).isEqualTo(0);
}
@Test
void getSegmentationQueue_returnsEmptyList_whenQueueIsEmpty() {
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of());
List<TranscriptionQueueItemDTO> result = service.getSegmentationQueue();
assertThat(result).isEmpty();
verifyNoInteractions(auditLogQueryService);
}
@Test
void getSegmentationQueue_returnsAllFive_andHasMoreFalse_whenExactlyFiveContributors() {
UUID docId = UUID.randomUUID();
TranscriptionQueueProjection proj = mockQueueProjection(docId, "Brief", null, 0, 0, 0);
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of(proj));
List<ActivityActorDTO> fiveActors = List.of(
new ActivityActorDTO("A1", "#111", "Alice One"),
new ActivityActorDTO("A2", "#222", "Alice Two"),
new ActivityActorDTO("A3", "#333", "Alice Three"),
new ActivityActorDTO("A4", "#444", "Alice Four"),
new ActivityActorDTO("A5", "#555", "Alice Five")
);
when(auditLogQueryService.findContributorsPerDocument(List.of(docId)))
.thenReturn(Map.of(docId, fiveActors));
List<TranscriptionQueueItemDTO> result = service.getSegmentationQueue();
assertThat(result.get(0).contributors()).hasSize(5);
assertThat(result.get(0).hasMoreContributors()).isFalse();
}
@Test
void getSegmentationQueue_mapsDocumentDateWhenPresent() {
LocalDate date = LocalDate.of(1920, 6, 15);