|
49 | 49 | import org.jetbrains.annotations.NotNull;
|
50 | 50 |
|
51 | 51 | import java.util.*;
|
| 52 | +import java.util.stream.Collectors; |
| 53 | + |
| 54 | +import static java.util.function.Function.identity; |
52 | 55 |
|
53 | 56 | /**
|
54 | 57 | * @author Daniel Espendiller <[email protected]>
|
@@ -87,6 +90,30 @@ public void assertCompletionNotContains(String filename, String configureByText,
|
87 | 90 | assertFalse(myFixture.getLookupElementStrings().containsAll(Arrays.asList(lookupStrings)));
|
88 | 91 | }
|
89 | 92 |
|
| 93 | + |
| 94 | + public void assertCompletionResultsAreUnique( |
| 95 | + @NotNull LanguageFileType languageFileType, |
| 96 | + @NotNull String configureByText, |
| 97 | + @NotNull String... lookupStrings |
| 98 | + ) { |
| 99 | + myFixture.configureByText(languageFileType, configureByText); |
| 100 | + myFixture.completeBasic(); |
| 101 | + |
| 102 | + var results = myFixture.getLookupElementStrings(); |
| 103 | + if (results != null) { |
| 104 | + var duplicates = results.stream() |
| 105 | + .filter(result -> Arrays.asList(lookupStrings).contains(result)) |
| 106 | + .collect(Collectors.groupingBy(identity())) |
| 107 | + .entrySet() |
| 108 | + .stream() |
| 109 | + .filter(result -> result.getValue().size() > 1) |
| 110 | + .map(Map.Entry::getKey) |
| 111 | + .collect(Collectors.toList()); |
| 112 | + |
| 113 | + assertTrue("The following results are duplicated: " + String.join(", ", duplicates), duplicates.isEmpty()); |
| 114 | + } |
| 115 | + } |
| 116 | + |
90 | 117 | public void assertCompletionNotContains(LanguageFileType languageFileType, String configureByText, String... lookupStrings) {
|
91 | 118 |
|
92 | 119 | myFixture.configureByText(languageFileType, configureByText);
|
|
0 commit comments