Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ public void testSorted() throws Exception {
NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInForeground(null, fQuery1);
AbstractTextSearchResult result= (AbstractTextSearchResult) fQuery1.getSearchResult();
int originalMatchCount= result.getMatchCount();
List<Match> allMatches= new ArrayList<>(originalMatchCount);
List<Match> allMatches= new ArrayList<>(result.getMatchCount());
int originalMatchCount= 0;

// first, collect all matches
Object[] elements= result.getElements();
for (Object element : elements) {
int sizeBefore= allMatches.size();
Match[] matches = result.getMatches(element);
Collections.addAll(allMatches, matches);
originalMatchCount += matches.length;
int sizeAfter= allMatches.size();
assertEquals(sizeBefore + matches.length, sizeAfter, "Failed to add matches:" +
Arrays.stream(matches).map(Match::toString).collect(Collectors.joining(System.lineSeparator())));
Expand All @@ -80,7 +81,7 @@ public void testSorted() throws Exception {
assertEquals(sizeBefore + 1, sizeAfter, "Failed to add match:" + match);
}

assertEquals(result.getMatchCount(), originalMatchCount, "Test that all matches have been added again");
assertEquals(originalMatchCount, result.getMatchCount(), "Test that all matches have been added again");

// now check that they're ordered by position.
for (Object element : elements) {
Expand Down
Loading