From 985b31f71f44a725253bb184e4751a99fa66b753 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 2 Jun 2026 20:40:42 +0200 Subject: [PATCH] feat(document): remove conversation service methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delete getConversationFiltered (the endpoint's only caller is gone) and the dead 2-arg getConversation(personA, personB) which had zero callers, along with both getConversationFiltered test blocks. The hasSender/ hasReceiver specifications stay — document search still uses them. Co-Authored-By: Claude Opus 4.8 --- .../document/DocumentService.java | 25 ------ .../document/DocumentServiceTest.java | 76 ------------------- 2 files changed, 101 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java b/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java index 0aa824e5..66b10da0 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java @@ -918,22 +918,6 @@ public class DocumentService { .orElse(""); } - // 2. SPEZIALITÄT: Der Schriftwechsel - // Findet alle Briefe ZWISCHEN zwei Personen (egal wer Sender/Empfänger war) - public List getConversation(UUID personA, UUID personB) { - - // Fall 1: A schreibt an B - Specification aToB = Specification.where(hasSender(personA)).and(hasReceiver(personB)); - - // Fall 2: B schreibt an A - Specification bToA = Specification.where(hasSender(personB)).and(hasReceiver(personA)); - - // Wir wollen (A->B) ODER (B->A) - Specification conversation = aToB.or(bToA); - - return documentRepository.findAll(conversation, Sort.by(Sort.Direction.ASC, "documentDate")); - } - @Transactional public void updateScriptType(UUID documentId, ScriptType scriptType) { Document doc = getDocumentById(documentId); @@ -992,15 +976,6 @@ public class DocumentService { return documentRepository.findByReceiversId(receiverId); } - public List getConversationFiltered(UUID senderId, UUID receiverId, LocalDate from, LocalDate to, Sort sort) { - LocalDate dateFrom = (from != null) ? from : LocalDate.parse("0000-01-01"); - LocalDate dateTo = (to != null) ? to : LocalDate.now(); - if (receiverId == null) { - return documentRepository.findSinglePersonCorrespondence(senderId, dateFrom, dateTo, sort); - } - return documentRepository.findConversation(senderId, receiverId, dateFrom, dateTo, sort); - } - public long getIncompleteCount() { return documentRepository.countByMetadataCompleteFalse(); } diff --git a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java index 0ed058a8..a1ff86bf 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java @@ -1128,53 +1128,6 @@ class DocumentServiceTest { .isEqualTo("19650332_Mueller_Hans"); } - // ─── getConversationFiltered ─────────────────────────────────────────────── - - @Test - void getConversationFiltered_passesGivenDates_whenFromAndToAreProvided() { - UUID senderId = UUID.randomUUID(); - UUID receiverId = UUID.randomUUID(); - LocalDate from = LocalDate.of(1940, 1, 1); - LocalDate to = LocalDate.of(1960, 12, 31); - Sort sort = Sort.by(Sort.Direction.ASC, "documentDate"); - when(documentRepository.findConversation(senderId, receiverId, from, to, sort)) - .thenReturn(List.of()); - - documentService.getConversationFiltered(senderId, receiverId, from, to, sort); - - verify(documentRepository).findConversation(senderId, receiverId, from, to, sort); - } - - @Test - void getConversationFiltered_usesMinDateForFrom_whenFromIsNull() { - UUID senderId = UUID.randomUUID(); - UUID receiverId = UUID.randomUUID(); - Sort sort = Sort.by(Sort.Direction.ASC, "documentDate"); - when(documentRepository.findConversation(eq(senderId), eq(receiverId), any(LocalDate.class), any(LocalDate.class), eq(sort))) - .thenReturn(List.of()); - - documentService.getConversationFiltered(senderId, receiverId, null, null, sort); - - ArgumentCaptor fromCaptor = ArgumentCaptor.forClass(LocalDate.class); - verify(documentRepository).findConversation(eq(senderId), eq(receiverId), fromCaptor.capture(), any(LocalDate.class), eq(sort)); - assertThat(fromCaptor.getValue()).isEqualTo(LocalDate.parse("0000-01-01")); - } - - @Test - void getConversationFiltered_usesTodayForTo_whenToIsNull() { - UUID senderId = UUID.randomUUID(); - UUID receiverId = UUID.randomUUID(); - Sort sort = Sort.by(Sort.Direction.ASC, "documentDate"); - when(documentRepository.findConversation(eq(senderId), eq(receiverId), any(LocalDate.class), any(LocalDate.class), eq(sort))) - .thenReturn(List.of()); - - documentService.getConversationFiltered(senderId, receiverId, null, null, sort); - - ArgumentCaptor toCaptor = ArgumentCaptor.forClass(LocalDate.class); - verify(documentRepository).findConversation(eq(senderId), eq(receiverId), any(LocalDate.class), toCaptor.capture(), eq(sort)); - assertThat(toCaptor.getValue()).isEqualTo(LocalDate.now()); - } - // ─── updateDocumentTags — empty tag in list ─────────────────────────────── @Test @@ -1760,35 +1713,6 @@ class DocumentServiceTest { .isEqualTo(Sort.by(Sort.Direction.DESC, "updatedAt")); } - // ─── getConversationFiltered (single-person mode) ───────────────────────── - - @Test - void getConversationFiltered_callsSinglePersonQuery_whenReceiverIdIsNull() { - UUID personId = UUID.randomUUID(); - Sort sort = Sort.by(Sort.Direction.DESC, "documentDate"); - when(documentRepository.findSinglePersonCorrespondence(eq(personId), any(), any(), eq(sort))) - .thenReturn(List.of()); - - documentService.getConversationFiltered(personId, null, null, null, sort); - - verify(documentRepository).findSinglePersonCorrespondence(eq(personId), any(), any(), eq(sort)); - verify(documentRepository, never()).findConversation(any(), any(), any(), any(), any()); - } - - @Test - void getConversationFiltered_callsBilateralQuery_whenReceiverIdIsSet() { - UUID senderId = UUID.randomUUID(); - UUID receiverId = UUID.randomUUID(); - Sort sort = Sort.by(Sort.Direction.DESC, "documentDate"); - when(documentRepository.findConversation(eq(senderId), eq(receiverId), any(), any(), eq(sort))) - .thenReturn(List.of()); - - documentService.getConversationFiltered(senderId, receiverId, null, null, sort); - - verify(documentRepository).findConversation(eq(senderId), eq(receiverId), any(), any(), eq(sort)); - verify(documentRepository, never()).findSinglePersonCorrespondence(any(), any(), any(), any()); - } - // ─── searchDocuments — SENDER sort includes documents with null sender ───── @Test