|
|
|
|
@@ -10,7 +10,6 @@ import org.raddatz.familienarchiv.audit.ActivityActorDTO;
|
|
|
|
|
import org.raddatz.familienarchiv.audit.AuditLogQueryService;
|
|
|
|
|
import org.raddatz.familienarchiv.dto.TranscriptionQueueItemDTO;
|
|
|
|
|
import org.raddatz.familienarchiv.dto.TranscriptionWeeklyStatsDTO;
|
|
|
|
|
import org.raddatz.familienarchiv.repository.DocumentRepository;
|
|
|
|
|
import org.raddatz.familienarchiv.repository.TranscriptionQueueProjection;
|
|
|
|
|
import org.raddatz.familienarchiv.repository.TranscriptionWeeklyStatsProjection;
|
|
|
|
|
|
|
|
|
|
@@ -26,7 +25,7 @@ import static org.mockito.Mockito.*;
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
|
class TranscriptionQueueServiceTest {
|
|
|
|
|
|
|
|
|
|
@Mock DocumentRepository documentRepository;
|
|
|
|
|
@Mock DocumentService documentService;
|
|
|
|
|
@Mock AuditLogQueryService auditLogQueryService;
|
|
|
|
|
@InjectMocks TranscriptionQueueService service;
|
|
|
|
|
|
|
|
|
|
@@ -41,11 +40,11 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
void getSegmentationQueue_delegatesToRepositoryWithDefaultSize() {
|
|
|
|
|
UUID id = UUID.randomUUID();
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(id, "Brief von 1920", null, 0, 0, 0);
|
|
|
|
|
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<TranscriptionQueueItemDTO> result = service.getSegmentationQueue();
|
|
|
|
|
|
|
|
|
|
verify(documentRepository).findSegmentationQueue(5);
|
|
|
|
|
verify(documentService).findSegmentationQueue(5);
|
|
|
|
|
assertThat(result).hasSize(1);
|
|
|
|
|
assertThat(result.get(0).id()).isEqualTo(id);
|
|
|
|
|
assertThat(result.get(0).title()).isEqualTo("Brief von 1920");
|
|
|
|
|
@@ -55,7 +54,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void getSegmentationQueue_returnsEmptyList_whenQueueIsEmpty() {
|
|
|
|
|
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of());
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of());
|
|
|
|
|
|
|
|
|
|
List<TranscriptionQueueItemDTO> result = service.getSegmentationQueue();
|
|
|
|
|
|
|
|
|
|
@@ -67,7 +66,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
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));
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<ActivityActorDTO> fiveActors = List.of(
|
|
|
|
|
new ActivityActorDTO("A1", "#111", "Alice One"),
|
|
|
|
|
@@ -89,7 +88,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
void getSegmentationQueue_mapsDocumentDateWhenPresent() {
|
|
|
|
|
LocalDate date = LocalDate.of(1920, 6, 15);
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(UUID.randomUUID(), "Brief", date, 0, 0, 0);
|
|
|
|
|
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<TranscriptionQueueItemDTO> result = service.getSegmentationQueue();
|
|
|
|
|
|
|
|
|
|
@@ -102,11 +101,11 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
void getTranscriptionQueue_delegatesToRepositoryWithDefaultSize() {
|
|
|
|
|
UUID id = UUID.randomUUID();
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(id, "Tagebuch", LocalDate.of(1943, 1, 1), 3, 1, 0);
|
|
|
|
|
when(documentRepository.findTranscriptionQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findTranscriptionQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<TranscriptionQueueItemDTO> result = service.getTranscriptionQueue();
|
|
|
|
|
|
|
|
|
|
verify(documentRepository).findTranscriptionQueue(5);
|
|
|
|
|
verify(documentService).findTranscriptionQueue(5);
|
|
|
|
|
assertThat(result).hasSize(1);
|
|
|
|
|
assertThat(result.get(0).annotationCount()).isEqualTo(3);
|
|
|
|
|
assertThat(result.get(0).textedBlockCount()).isEqualTo(1);
|
|
|
|
|
@@ -118,11 +117,11 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
@Test
|
|
|
|
|
void getReadyToReadQueue_delegatesToRepositoryWithDefaultSize() {
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(UUID.randomUUID(), "Urkunde", null, 4, 4, 4);
|
|
|
|
|
when(documentRepository.findReadyToReadQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findReadyToReadQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<TranscriptionQueueItemDTO> result = service.getReadyToReadQueue();
|
|
|
|
|
|
|
|
|
|
verify(documentRepository).findReadyToReadQueue(5);
|
|
|
|
|
verify(documentService).findReadyToReadQueue(5);
|
|
|
|
|
assertThat(result).hasSize(1);
|
|
|
|
|
assertThat(result.get(0).reviewedBlockCount()).isEqualTo(4);
|
|
|
|
|
}
|
|
|
|
|
@@ -132,7 +131,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
@Test
|
|
|
|
|
void getWeeklyStats_mapsProjectionToDTO() {
|
|
|
|
|
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(3L, 7L);
|
|
|
|
|
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
|
|
|
|
when(documentService.findWeeklyStats()).thenReturn(proj);
|
|
|
|
|
|
|
|
|
|
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
|
|
|
|
|
|
|
|
|
@@ -143,7 +142,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
@Test
|
|
|
|
|
void getWeeklyStats_returnsZeros_whenAllCountsAreZero() {
|
|
|
|
|
TranscriptionWeeklyStatsProjection proj = mockStatsProjection(0L, 0L);
|
|
|
|
|
when(documentRepository.findWeeklyStats()).thenReturn(proj);
|
|
|
|
|
when(documentService.findWeeklyStats()).thenReturn(proj);
|
|
|
|
|
|
|
|
|
|
TranscriptionWeeklyStatsDTO result = service.getWeeklyStats();
|
|
|
|
|
|
|
|
|
|
@@ -157,7 +156,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
void getSegmentationQueue_includesContributors_whenAuditDataPresent() {
|
|
|
|
|
UUID docId = UUID.randomUUID();
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(docId, "Brief", null, 0, 0, 0);
|
|
|
|
|
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
ActivityActorDTO actor = new ActivityActorDTO("MR", "#a6dad8", "Max Raddatz");
|
|
|
|
|
when(auditLogQueryService.findContributorsPerDocument(List.of(docId)))
|
|
|
|
|
@@ -173,7 +172,7 @@ class TranscriptionQueueServiceTest {
|
|
|
|
|
void getSegmentationQueue_capsContributorsAtFive_andSetsHasMoreFlag() {
|
|
|
|
|
UUID docId = UUID.randomUUID();
|
|
|
|
|
TranscriptionQueueProjection proj = mockQueueProjection(docId, "Brief", null, 0, 0, 0);
|
|
|
|
|
when(documentRepository.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
when(documentService.findSegmentationQueue(5)).thenReturn(List.of(proj));
|
|
|
|
|
|
|
|
|
|
List<ActivityActorDTO> sixActors = List.of(
|
|
|
|
|
new ActivityActorDTO("A1", "#111", "Alice One"),
|
|
|
|
|
|