feat(search): add TagService.findByNameContaining for NL tag resolution
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,10 @@ public class TagService {
|
|||||||
return enrichWithRelatives(matched);
|
return enrichWithRelatives(matched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Tag> findByNameContaining(String fragment) {
|
||||||
|
return tagRepository.findByNameContainingIgnoreCase(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
public Tag getById(UUID id) {
|
public Tag getById(UUID id) {
|
||||||
return tagRepository.findById(id)
|
return tagRepository.findById(id)
|
||||||
.orElseThrow(() -> DomainException.notFound(ErrorCode.TAG_NOT_FOUND, "Tag not found: " + id));
|
.orElseThrow(() -> DomainException.notFound(ErrorCode.TAG_NOT_FOUND, "Tag not found: " + id));
|
||||||
|
|||||||
@@ -666,4 +666,17 @@ class TagServiceTest {
|
|||||||
// verify findAllById was called at least twice: once for extras, once inside resolveEffectiveColors
|
// verify findAllById was called at least twice: once for extras, once inside resolveEffectiveColors
|
||||||
verify(tagRepository, atLeastOnce()).findAllById(any());
|
verify(tagRepository, atLeastOnce()).findAllById(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── findByNameContaining ─────────────────────────────────────────────────
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void findByNameContaining_delegatesToRepository() {
|
||||||
|
Tag krieg = Tag.builder().id(UUID.randomUUID()).name("Krieg").build();
|
||||||
|
when(tagRepository.findByNameContainingIgnoreCase("krieg")).thenReturn(List.of(krieg));
|
||||||
|
|
||||||
|
List<Tag> result = tagService.findByNameContaining("krieg");
|
||||||
|
|
||||||
|
assertThat(result).containsExactly(krieg);
|
||||||
|
verify(tagRepository).findByNameContainingIgnoreCase("krieg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user