Skip to content

Commit a803578

Browse files
committed
test: verify empty collection rule ids
1 parent 7aa3298 commit a803578

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

sandbox_common_core/src/test/java/org/sandbox/jdt/triggerpattern/test/BundledHintRuleBehaviorTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*******************************************************************************/
1414
package org.sandbox.jdt.triggerpattern.test;
1515

16+
import static org.junit.jupiter.api.Assertions.assertEquals;
1617
import static org.junit.jupiter.api.Assertions.assertTrue;
1718

1819
import org.junit.jupiter.api.BeforeEach;
@@ -77,6 +78,21 @@ void collectionsKeepsSafeEmptyCollectionFactoryReplacements() throws Exception {
7778
"class Test { Object m() { return java.util.Set.of(); } }"); //$NON-NLS-1$
7879
}
7980

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+
8096
@Test
8197
void collectionsRespectsJava9SourceVersionGuard() throws Exception {
8298
HintFile hintFile = loadBundledHint("collections.sandbox-hint"); //$NON-NLS-1$

0 commit comments

Comments
 (0)