Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit bf17c45

Browse files
committed
Adds tests for default import grouping.
1 parent 7347958 commit bf17c45

File tree

1 file changed

+219
-0
lines changed

1 file changed

+219
-0
lines changed

src/test/scala/scala/tools/refactoring/tests/implementations/imports/OrganizeImportsGroupsTest.scala

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,223 @@ class OrganizeImportsGroupsTest extends OrganizeImportsBaseTest {
161161
}
162162
"""
163163
} applyRefactoring organize(List("javava", "sca"))
164+
165+
@Test
166+
def defaultGroupInTheMiddleVersion1() = new FileSet {
167+
source becomes
168+
"""
169+
import org.xml.sax.Attributes
170+
171+
import java.util.AbstractList
172+
import java.util.BitSet
173+
import scala.io.Source
174+
175+
import scala.collection.mutable.HashMap
176+
import scala.collection.mutable.ListBuffer
177+
178+
trait Temp {
179+
// we need some code that use the imports
180+
val x: (ListBuffer[Int], HashMap[String, Int])
181+
val y: (AbstractList[Int], BitSet)
182+
val z: (Attributes, Source)
183+
}
184+
"""
185+
} applyRefactoring organize(List("org.xml", "*", "scala.collection"))
186+
187+
@Test
188+
def defaultGroupInTheMiddleVersion2() = new FileSet {
189+
source becomes
190+
"""
191+
import org.xml.sax.Attributes
192+
193+
import java.util.AbstractList
194+
import java.util.BitSet
195+
196+
import scala.io.Source
197+
198+
import scala.collection.mutable.HashMap
199+
import scala.collection.mutable.ListBuffer
200+
201+
trait Temp {
202+
// we need some code that use the imports
203+
val x: (ListBuffer[Int], HashMap[String, Int])
204+
val y: (AbstractList[Int], BitSet)
205+
val z: (Attributes, Source)
206+
}
207+
"""
208+
} applyRefactoring organize(List("org.xml", "java", "*", "scala.collection"))
209+
210+
@Test
211+
def defaultGroupInTheMiddleButEmpty() = new FileSet {
212+
source becomes
213+
"""
214+
import org.xml.sax.Attributes
215+
216+
import java.util.AbstractList
217+
import java.util.BitSet
218+
219+
import scala.io.Source
220+
import scala.collection.mutable.HashMap
221+
import scala.collection.mutable.ListBuffer
222+
223+
trait Temp {
224+
// we need some code that use the imports
225+
val x: (ListBuffer[Int], HashMap[String, Int])
226+
val y: (AbstractList[Int], BitSet)
227+
val z: (Attributes, Source)
228+
}
229+
"""
230+
} applyRefactoring organize(List("org", "java", "*", "scala"))
231+
232+
@Test
233+
def defaultGroupInTheBeginningVersion1() = new FileSet {
234+
source becomes
235+
"""
236+
import java.util.AbstractList
237+
import java.util.BitSet
238+
import scala.io.Source
239+
240+
import org.xml.sax.Attributes
241+
242+
import scala.collection.mutable.HashMap
243+
import scala.collection.mutable.ListBuffer
244+
245+
trait Temp {
246+
// we need some code that use the imports
247+
val x: (ListBuffer[Int], HashMap[String, Int])
248+
val y: (AbstractList[Int], BitSet)
249+
val z: (Attributes, Source)
250+
}
251+
"""
252+
} applyRefactoring organize(List("*", "org.xml", "scala.collection"))
253+
254+
@Test
255+
def defaultGroupInTheBeginningVersion2() = new FileSet {
256+
source becomes
257+
"""
258+
import org.xml.sax.Attributes
259+
260+
import scala.collection.mutable.HashMap
261+
import scala.collection.mutable.ListBuffer
262+
import scala.io.Source
263+
264+
import java.util.AbstractList
265+
import java.util.BitSet
266+
267+
trait Temp {
268+
// we need some code that use the imports
269+
val x: (ListBuffer[Int], HashMap[String, Int])
270+
val y: (AbstractList[Int], BitSet)
271+
val z: (Attributes, Source)
272+
}
273+
"""
274+
} applyRefactoring organize(List("*", "scala", "java"))
275+
276+
@Test
277+
def defaultGroupInTheBeginningButEmpty() = new FileSet {
278+
source becomes
279+
"""
280+
import org.xml.sax.Attributes
281+
282+
import scala.collection.mutable.HashMap
283+
import scala.collection.mutable.ListBuffer
284+
import scala.io.Source
285+
286+
import java.util.AbstractList
287+
import java.util.BitSet
288+
289+
trait Temp {
290+
// we need some code that use the imports
291+
val x: (ListBuffer[Int], HashMap[String, Int])
292+
val y: (AbstractList[Int], BitSet)
293+
val z: (Attributes, Source)
294+
}
295+
"""
296+
} applyRefactoring organize(List("*", "org", "scala", "java"))
297+
298+
@Test
299+
def noGroupingIsDefaultGrouping() = new FileSet {
300+
source becomes
301+
"""
302+
import java.util.AbstractList
303+
import java.util.BitSet
304+
import org.xml.sax.Attributes
305+
import scala.collection.mutable.HashMap
306+
import scala.collection.mutable.ListBuffer
307+
import scala.io.Source
308+
309+
trait Temp {
310+
// we need some code that use the imports
311+
val x: (ListBuffer[Int], HashMap[String, Int])
312+
val y: (AbstractList[Int], BitSet)
313+
val z: (Attributes, Source)
314+
}
315+
"""
316+
} applyRefactoring organize(List("*"))
317+
318+
@Test
319+
def defaultGroupInTheEndVersion1() = new FileSet {
320+
source becomes
321+
"""
322+
import org.xml.sax.Attributes
323+
324+
import scala.collection.mutable.HashMap
325+
import scala.collection.mutable.ListBuffer
326+
import scala.io.Source
327+
328+
import java.util.AbstractList
329+
import java.util.BitSet
330+
331+
trait Temp {
332+
// we need some code that use the imports
333+
val x: (ListBuffer[Int], HashMap[String, Int])
334+
val y: (AbstractList[Int], BitSet)
335+
val z: (Attributes, Source)
336+
}
337+
"""
338+
} applyRefactoring organize(List("org", "scala", "*"))
339+
340+
@Test
341+
def defaultGroupInTheEndVersion2() = new FileSet {
342+
source becomes
343+
"""
344+
import scala.collection.mutable.HashMap
345+
import scala.collection.mutable.ListBuffer
346+
import scala.io.Source
347+
348+
import java.util.AbstractList
349+
import java.util.BitSet
350+
351+
import org.xml.sax.Attributes
352+
353+
trait Temp {
354+
// we need some code that use the imports
355+
val x: (ListBuffer[Int], HashMap[String, Int])
356+
val y: (AbstractList[Int], BitSet)
357+
val z: (Attributes, Source)
358+
}
359+
"""
360+
} applyRefactoring organize(List("scala", "java", "*"))
361+
362+
@Test
363+
def defaultGroupInTheEndButEmpty() = new FileSet {
364+
source becomes
365+
"""
366+
import org.xml.sax.Attributes
367+
368+
import scala.collection.mutable.HashMap
369+
import scala.collection.mutable.ListBuffer
370+
import scala.io.Source
371+
372+
import java.util.AbstractList
373+
import java.util.BitSet
374+
375+
trait Temp {
376+
// we need some code that use the imports
377+
val x: (ListBuffer[Int], HashMap[String, Int])
378+
val y: (AbstractList[Int], BitSet)
379+
val z: (Attributes, Source)
380+
}
381+
"""
382+
} applyRefactoring organize(List("org", "scala", "java", "*"))
164383
}

0 commit comments

Comments
 (0)