feat(transcription): expose hasBlocks on TranscriptionBlockQueryService (#697)
Domain-service wrapper over existsByDocumentId so other domains can ask "does this document have any transcription blocks?" without reaching into the repository. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,10 @@ public class TranscriptionBlockQueryService {
|
||||
|
||||
private final TranscriptionBlockRepository blockRepository;
|
||||
|
||||
public boolean hasBlocks(UUID documentId) {
|
||||
return blockRepository.existsByDocumentId(documentId);
|
||||
}
|
||||
|
||||
public Map<UUID, Integer> getCompletionStats(List<UUID> documentIds) {
|
||||
if (documentIds.isEmpty()) return Map.of();
|
||||
Map<UUID, Integer> result = new HashMap<>();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.raddatz.familienarchiv.document.transcription;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TranscriptionBlockQueryServiceTest {
|
||||
|
||||
@Mock TranscriptionBlockRepository blockRepository;
|
||||
@InjectMocks TranscriptionBlockQueryService queryService;
|
||||
|
||||
@Test
|
||||
void hasBlocks_returns_true_when_a_block_exists() {
|
||||
UUID documentId = UUID.randomUUID();
|
||||
when(blockRepository.existsByDocumentId(documentId)).thenReturn(true);
|
||||
|
||||
assertThat(queryService.hasBlocks(documentId)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void hasBlocks_returns_false_when_no_block_exists() {
|
||||
UUID documentId = UUID.randomUUID();
|
||||
when(blockRepository.existsByDocumentId(documentId)).thenReturn(false);
|
||||
|
||||
assertThat(queryService.hasBlocks(documentId)).isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user