test(search): add sender name FTS coverage and combined filter test
- should_find_document_by_sender_name — symmetric with existing receiver test - fts_combined_with_status_filter_excludes_non_matching_status — verifies hasIds(rankedIds).and(hasStatus(...)) two-phase search works together Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,12 +16,16 @@ import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
|
||||
import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
import static org.raddatz.familienarchiv.repository.DocumentSpecifications.hasIds;
|
||||
import static org.raddatz.familienarchiv.repository.DocumentSpecifications.hasStatus;
|
||||
|
||||
@DataJpaTest
|
||||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
|
||||
@@ -193,6 +197,24 @@ class DocumentFtsTest {
|
||||
assertThat(ids).contains(doc.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_find_document_by_sender_name() {
|
||||
Person sender = personRepository.saveAndFlush(
|
||||
Person.builder().firstName("Walter").lastName("Raddatz").build());
|
||||
Document doc = documentRepository.saveAndFlush(Document.builder()
|
||||
.title("Brief")
|
||||
.originalFilename("brief.pdf")
|
||||
.status(DocumentStatus.UPLOADED)
|
||||
.sender(sender)
|
||||
.build());
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
List<UUID> ids = documentRepository.findRankedIdsByFts("Raddatz");
|
||||
|
||||
assertThat(ids).contains(doc.getId());
|
||||
}
|
||||
|
||||
// ─── Weight D: tag names ───────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
@@ -212,6 +234,29 @@ class DocumentFtsTest {
|
||||
assertThat(ids).hasSize(1);
|
||||
}
|
||||
|
||||
// ─── Combined FTS + Specification filter ──────────────────────────────────
|
||||
|
||||
@Test
|
||||
void fts_combined_with_status_filter_excludes_non_matching_status() {
|
||||
documentRepository.saveAndFlush(document("Grundbuch")); // UPLOADED
|
||||
documentRepository.saveAndFlush(Document.builder()
|
||||
.title("Grundbuch")
|
||||
.originalFilename("grundbuch_ph.pdf")
|
||||
.status(DocumentStatus.PLACEHOLDER)
|
||||
.build());
|
||||
em.flush();
|
||||
em.clear();
|
||||
|
||||
List<UUID> rankedIds = documentRepository.findRankedIdsByFts("Grundbuch");
|
||||
Specification<Document> spec = Specification.where(hasIds(rankedIds))
|
||||
.and(hasStatus(DocumentStatus.UPLOADED));
|
||||
|
||||
List<Document> result = documentRepository.findAll(spec);
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).getStatus()).isEqualTo(DocumentStatus.UPLOADED);
|
||||
}
|
||||
|
||||
// ─── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private Document document(String title) {
|
||||
|
||||
Reference in New Issue
Block a user