1616package org .openrewrite .java .migrate .guava ;
1717
1818import org .junit .jupiter .api .Test ;
19+ import org .junitpioneer .jupiter .ExpectedToFail ;
20+ import org .junitpioneer .jupiter .Issue ;
1921import org .openrewrite .DocumentExample ;
2022import org .openrewrite .InMemoryExecutionContext ;
2123import org .openrewrite .java .JavaParser ;
@@ -103,6 +105,8 @@ public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNul
103105 );
104106 }
105107
108+ @ ExpectedToFail ("Sets.filter has special handling for sorted sets which now gets lost" )
109+ @ Issue ("https://github.com/openrewrite/rewrite-migrate-java/pull/898#discussion_r2461706208" )
106110 @ Test
107111 void replaceSetsFilterIndirectlyUsingSortedSet () {
108112 //language=java
@@ -121,22 +125,8 @@ public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNul
121125 return Sets.filter(indirectSet, isNotNull);
122126 }
123127 }
124- """ ,
125- """
126- import java.util.Set;
127- import java.util.SortedSet;
128- import java.util.TreeSet;
129- import java.util.stream.Collectors;
130-
131- import com.google.common.base.Predicate;
132-
133- class Test {
134- public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNull) {
135- Set<Object> indirectSet = set;
136- return indirectSet.stream().filter(isNotNull).collect(Collectors.toCollection(TreeSet::new));
137- }
138- }
139128 """
129+ // This now gets converted, but skips past a `instanceof SortedSet` check that keeps it a sorted set
140130 )
141131 );
142132 }
0 commit comments