|
13 | 13 | *******************************************************************************/ |
14 | 14 | package org.sandbox.jdt.triggerpattern.test; |
15 | 15 |
|
| 16 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
16 | 17 | import static org.junit.jupiter.api.Assertions.assertTrue; |
17 | 18 |
|
18 | 19 | import org.junit.jupiter.api.BeforeEach; |
@@ -77,6 +78,21 @@ void collectionsKeepsSafeEmptyCollectionFactoryReplacements() throws Exception { |
77 | 78 | "class Test { Object m() { return java.util.Set.of(); } }"); //$NON-NLS-1$ |
78 | 79 | } |
79 | 80 |
|
| 81 | + @Test |
| 82 | + void collectionsUsesStableRuleIdsForEmptyCollectionFactories() throws Exception { |
| 83 | + HintFile hintFile = loadBundledHint("collections.sandbox-hint"); //$NON-NLS-1$ |
| 84 | + |
| 85 | + assertEquals("collections.empty-list.to-list-of", //$NON-NLS-1$ |
| 86 | + process(hintFile, "class Test { Object m() { return java.util.Collections.emptyList(); } }") //$NON-NLS-1$ |
| 87 | + .get(0).rule().getRuleId()); |
| 88 | + assertEquals("collections.empty-map.to-map-of", //$NON-NLS-1$ |
| 89 | + process(hintFile, "class Test { Object m() { return java.util.Collections.emptyMap(); } }") //$NON-NLS-1$ |
| 90 | + .get(0).rule().getRuleId()); |
| 91 | + assertEquals("collections.empty-set.to-set-of", //$NON-NLS-1$ |
| 92 | + process(hintFile, "class Test { Object m() { return java.util.Collections.emptySet(); } }") //$NON-NLS-1$ |
| 93 | + .get(0).rule().getRuleId()); |
| 94 | + } |
| 95 | + |
80 | 96 | @Test |
81 | 97 | void collectionsRespectsJava9SourceVersionGuard() throws Exception { |
82 | 98 | HintFile hintFile = loadBundledHint("collections.sandbox-hint"); //$NON-NLS-1$ |
|
0 commit comments