Skip to content

Commit d7453aa

Browse files
Maintenance: CrossEncoderReranker - Add comprehensive tests and improve code quality
This commit adds comprehensive test coverage for CrossEncoderReranker implementations and fixes a code quality issue in NoopCrossEncoderReranker. Changes made: - Replace deprecated Collectors.toList() with .toList() in NoopCrossEncoderReranker - Add 11 comprehensive unit tests for NoopCrossEncoderReranker covering: * Score-based sorting (descending order) * Equal scores handling * Edge cases (empty list, single candidate, null/blank query) * Negative and zero scores * Large score values * Many candidates - Add 15 comprehensive unit tests for NaverCrossEncoderReranker covering: * Successful API reranking * Partial document citation * Fallback scenarios (no citations, API errors, invalid JSON) * Null/blank query handling * Empty candidates handling * API key validation * Request body and headers verification * Document structure validation All tests pass successfully and maintain consistency with existing test patterns in the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 312323d commit d7453aa

File tree

3 files changed

+606
-2
lines changed

3 files changed

+606
-2
lines changed

src/main/java/spring/memewikibe/infrastructure/ai/NoopCrossEncoderReranker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import java.util.Comparator;
66
import java.util.List;
7-
import java.util.stream.Collectors;
87

98
/**
109
* Default no-op Cross-Encoder reranker that preserves prior order by score.
@@ -16,6 +15,6 @@ public List<Long> rerank(String query, List<Candidate> candidates) {
1615
return candidates.stream()
1716
.sorted(Comparator.comparingDouble(Candidate::priorScore).reversed())
1817
.map(Candidate::id)
19-
.collect(Collectors.toList());
18+
.toList();
2019
}
2120
}

0 commit comments

Comments
 (0)