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

Commit

Permalink
Adds tests for default import grouping.
Browse files Browse the repository at this point in the history
  • Loading branch information
wpopielarski committed Aug 14, 2017
1 parent 7347958 commit bf17c45
Showing 1 changed file with 219 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,223 @@ class OrganizeImportsGroupsTest extends OrganizeImportsBaseTest {
}
"""
} applyRefactoring organize(List("javava", "sca"))

@Test
def defaultGroupInTheMiddleVersion1() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import java.util.AbstractList
import java.util.BitSet
import scala.io.Source
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("org.xml", "*", "scala.collection"))

@Test
def defaultGroupInTheMiddleVersion2() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import java.util.AbstractList
import java.util.BitSet
import scala.io.Source
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("org.xml", "java", "*", "scala.collection"))

@Test
def defaultGroupInTheMiddleButEmpty() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import java.util.AbstractList
import java.util.BitSet
import scala.io.Source
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("org", "java", "*", "scala"))

@Test
def defaultGroupInTheBeginningVersion1() = new FileSet {
source becomes
"""
import java.util.AbstractList
import java.util.BitSet
import scala.io.Source
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("*", "org.xml", "scala.collection"))

@Test
def defaultGroupInTheBeginningVersion2() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
import java.util.AbstractList
import java.util.BitSet
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("*", "scala", "java"))

@Test
def defaultGroupInTheBeginningButEmpty() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
import java.util.AbstractList
import java.util.BitSet
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("*", "org", "scala", "java"))

@Test
def noGroupingIsDefaultGrouping() = new FileSet {
source becomes
"""
import java.util.AbstractList
import java.util.BitSet
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("*"))

@Test
def defaultGroupInTheEndVersion1() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
import java.util.AbstractList
import java.util.BitSet
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("org", "scala", "*"))

@Test
def defaultGroupInTheEndVersion2() = new FileSet {
source becomes
"""
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
import java.util.AbstractList
import java.util.BitSet
import org.xml.sax.Attributes
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("scala", "java", "*"))

@Test
def defaultGroupInTheEndButEmpty() = new FileSet {
source becomes
"""
import org.xml.sax.Attributes
import scala.collection.mutable.HashMap
import scala.collection.mutable.ListBuffer
import scala.io.Source
import java.util.AbstractList
import java.util.BitSet
trait Temp {
// we need some code that use the imports
val x: (ListBuffer[Int], HashMap[String, Int])
val y: (AbstractList[Int], BitSet)
val z: (Attributes, Source)
}
"""
} applyRefactoring organize(List("org", "scala", "java", "*"))
}

0 comments on commit bf17c45

Please sign in to comment.