Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 5 commits
  • 41 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 28, 2013
@schauder added initellij files to gitignore ed51445
@schauder Mirgrated to Scala 2.10
Upgraded the scala version in the gradle build script together with all the referenced scala libs
Fixed  broken stuff:
Collections were gone,
FunSuite trait is gone,

Fixed some deprecations (val in for comprehensions)
beb8ca7
@schauder Fixed various warnings about the deprecated ShouldMatcher 01638e8
Commits on Dec 29, 2013
@schauder added java api for allow and allowDirect 3ccab4e
@schauder added Java API support of anyOf and oneOf
Had to create a seperate object since varargs doesn't seem to work on companion objects for case clases or something
38158e5
Showing with 1,457 additions and 1,436 deletions.
  1. +4 −1 .gitignore
  2. +5 −5 build.gradle
  3. +37 −37 src/main/scala/de/schauderhaft/degraph/check/Check.scala
  4. +2 −2 src/main/scala/de/schauderhaft/degraph/check/ConstraintBuilder.scala
  5. +86 −80 src/main/scala/de/schauderhaft/degraph/check/constraints.scala
  6. +21 −2 src/test/java/de/schauderhaft/degraph/check/JavaCheckApiTest.java
  7. +68 −68 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/AnalyzerTest.scala
  8. +13 −13 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/ConvertTest.scala
  9. +25 −25 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/IncludeExcludeFilterTest.scala
  10. +20 −22 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/NoSelfReferenceTest.scala
  11. +186 −186 src/test/scala/de/schauderhaft/degraph/check/CheckTest.scala
  12. +10 −10 src/test/scala/de/schauderhaft/degraph/check/ConstraintBuilderTest.scala
  13. +47 −47 src/test/scala/de/schauderhaft/degraph/check/CycleFreeTest.scala
  14. +15 −15 src/test/scala/de/schauderhaft/degraph/check/DependencyTest.scala
  15. +41 −41 src/test/scala/de/schauderhaft/degraph/check/DirectLayeringConstraintTest.scala
  16. +43 −43 src/test/scala/de/schauderhaft/degraph/check/LayeringConstraintTest.scala
  17. +18 −18 src/test/scala/de/schauderhaft/degraph/check/MultiElementLenientLayerConstraintTest.scala
  18. +32 −32 src/test/scala/de/schauderhaft/degraph/check/MultiElementStrictLayerConstraintTest.scala
  19. +46 −48 src/test/scala/de/schauderhaft/degraph/configuration/CommandLineParserTest.scala
  20. +2 −2 src/test/scala/de/schauderhaft/degraph/configuration/ConfigurationConstraintTest.scala
  21. +65 −64 src/test/scala/de/schauderhaft/degraph/configuration/ConfigurationParserTest.scala
  22. +113 −113 src/test/scala/de/schauderhaft/degraph/configuration/ConfigurationTest.scala
  23. +10 −10 src/test/scala/de/schauderhaft/degraph/configuration/ConstraintViolationTest.scala
  24. +11 −11 src/test/scala/de/schauderhaft/degraph/configuration/SlicerTest.scala
  25. +28 −28 src/test/scala/de/schauderhaft/degraph/graph/GraphSliceTest.scala
  26. +106 −106 src/test/scala/de/schauderhaft/degraph/graph/GraphTest.scala
  27. +62 −62 src/test/scala/de/schauderhaft/degraph/graph/SliceNodeFinderTest.scala
  28. +16 −16 src/test/scala/de/schauderhaft/degraph/slicer/CombinedSlicerTest.scala
  29. +18 −20 src/test/scala/de/schauderhaft/degraph/slicer/InternalClassCategorizerTest.scala
  30. +13 −13 src/test/scala/de/schauderhaft/degraph/slicer/MultiCategorizerTest.scala
  31. +10 −10 src/test/scala/de/schauderhaft/degraph/slicer/NamedPatternMatchingCategorizerTest.scala
  32. +11 −13 src/test/scala/de/schauderhaft/degraph/slicer/PackageCategorizerTest.scala
  33. +28 −28 src/test/scala/de/schauderhaft/degraph/slicer/ParallelCategorizerTest.scala
  34. +67 −67 src/test/scala/de/schauderhaft/degraph/slicer/PatternMatcherTest.scala
  35. +11 −11 src/test/scala/de/schauderhaft/degraph/slicer/PatternMatchingCategorizerTest.scala
  36. +13 −13 src/test/scala/de/schauderhaft/degraph/slicer/PatternMatchingFilterTest.scala
  37. +12 −12 src/test/scala/de/schauderhaft/degraph/writer/EdgeStyleTest.scala
  38. +27 −27 src/test/scala/de/schauderhaft/degraph/writer/LabelingTest.scala
  39. +17 −17 src/test/scala/de/schauderhaft/degraph/writer/PredicateStylerTest.scala
  40. +48 −48 src/test/scala/de/schauderhaft/degraph/writer/SlicePredicateTest.scala
  41. +50 −50 src/test/scala/de/schauderhaft/degraph/writer/WriterTest.scala
View
5 .gitignore
@@ -1,7 +1,10 @@
bin/
+out/
build/
*.graphml
.*
caches/
native/
-wrapper/
+wrapper/
+*.iml
+
View
10 build.gradle
@@ -91,22 +91,22 @@ def getJavaFXPath(def javafxLib) {
dependencies {
// Libraries needed to run the scala tools
- scalaTools 'org.scala-lang:scala-compiler:2.9.2'
+ scalaTools 'org.scala-lang:scala-compiler:2.10.3'
// Libraries needed for scala api
- compile 'org.scala-lang:scala-library:2.9.2'
+ compile 'org.scala-lang:scala-library:2.10.3'
compile 'com.jeantessier:dependencyfinder:1.2.1-beta4'
compile 'oro:oro:2.0.8'
compile 'com.google.guava:guava:14.0.1'
compile 'log4j:log4j:1.2.17'
- compile 'org.rogach:scallop_2.9.2:0.8.1'
+ compile 'org.rogach:scallop_2.10:0.9.4'
- compile 'com.assembla.scala-incubator:graph-core_2.9.2:1.6.2'
+ compile 'com.assembla.scala-incubator:graph-core_2.10:1.7.0'
testCompile 'junit:junit:4.11'
- compile 'org.scalatest:scalatest_2.9.2:1.9.1'
+ compile 'org.scalatest:scalatest_2.10:2.0'
//javafx
compile files(getJavaFXPath(javafxLib))
View
74 src/main/scala/de/schauderhaft/degraph/check/Check.scala
@@ -8,7 +8,7 @@ import de.schauderhaft.degraph.model.Node
import org.scalatest.matchers.BeMatcher
import org.scalatest.matchers.MatchResult
import de.schauderhaft.degraph.graph.Graph
-import org.scalatest.matchers.ShouldMatchers._
+import org.scalatest.Matchers._
import de.schauderhaft.degraph.configuration.ConstraintViolation
/**
@@ -28,50 +28,50 @@ import de.schauderhaft.degraph.configuration.ConstraintViolation
*/
object Check {
- /**
- * a Configuration object containing the current classpath.
- *
- * Intended as a starting point for analyzing the application that is currently running.
- *
- * Note in a typical maven like setup it will also include the test classes as well as all libraries, which might not be desirable.
- * Manipulate the configuration to only contain the classpath elements required or use include and exclude filters for limiting the analyzed classes.
- */
- val classpath = ConstraintBuilder(new Configuration(
- classpath = Option(System.getProperty("java.class.path")),
- analyzer = Analyzer), "package")
+ /**
+ * a Configuration object containing the current classpath.
+ *
+ * Intended as a starting point for analyzing the application that is currently running.
+ *
+ * Note in a typical maven like setup it will also include the test classes as well as all libraries, which might not be desirable.
+ * Manipulate the configuration to only contain the classpath elements required or use include and exclude filters for limiting the analyzed classes.
+ */
+ val classpath = ConstraintBuilder(new Configuration(
+ classpath = Option(System.getProperty("java.class.path")),
+ analyzer = Analyzer), "package")
- /**
- * a matcher for Configurations testing if the classes specified in the configuration
- * adhere to the dependency constraints configured in the configuration.
- */
- val violationFree = new BeMatcher[ConstraintBuilder] {
- def apply(constraintBuilder: ConstraintBuilder) = {
- val conf = constraintBuilder.configuration
- val g = conf.createGraph()
+ /**
+ * a matcher for Configurations testing if the classes specified in the configuration
+ * adhere to the dependency constraints configured in the configuration.
+ */
+ val violationFree = new BeMatcher[ConstraintBuilder] {
+ def apply(constraintBuilder: ConstraintBuilder) = {
+ val conf = constraintBuilder.configuration
+ val g = conf.createGraph()
- def checkForViolations: Set[ConstraintViolation] = {
- for {
- c <- conf.constraint
- v <- c.violations(g)
- } yield v
- }
+ def checkForViolations: Set[ConstraintViolation] = {
+ for {
+ c <- conf.constraint
+ v <- c.violations(g)
+ } yield v
+ }
- val violations = checkForViolations
+ val violations = checkForViolations
- val matches = violations.isEmpty
+ val matches = violations.isEmpty
- val failureMessage = "%s yields the following constraint violations: %s".format(conf, violations.mkString("%n").format())
- val negativeFailureMessage = "%s does not yield any violations of the constraints.".format(conf)
+ val failureMessage = "%s yields the following constraint violations: %s".format(conf, violations.mkString("%n").format())
+ val negativeFailureMessage = "%s does not yield any violations of the constraints.".format(conf)
- new MatchResult(matches, failureMessage, negativeFailureMessage)
- }
+ new MatchResult(matches, failureMessage, negativeFailureMessage)
}
+ }
- private def sliceNode(edge: (Node, Node)) = {
- val (n1, n2) = edge
- n1.types == n2.types && n1.types.head != "Class"
- }
+ private def sliceNode(edge: (Node, Node)) = {
+ val (n1, n2) = edge
+ n1.types == n2.types && n1.types.head != "Class"
+ }
- private def lowerCaseFirstLetter(s: String) = s.head.toLower + s.tail
+ private def lowerCaseFirstLetter(s: String) = s.head.toLower + s.tail
}
View
4 src/main/scala/de/schauderhaft/degraph/check/ConstraintBuilder.scala
@@ -35,7 +35,7 @@ case class ConstraintBuilder(
*
* see also #allowDirect
*/
- def allow(slices: AnyRef*): ConstraintBuilder =
+ @varargs def allow(slices: AnyRef*): ConstraintBuilder =
modifyConfig(slices.toIndexedSeq, LayeringConstraint)
/**
@@ -45,7 +45,7 @@ case class ConstraintBuilder(
*
* see also #allow
*/
- def allowDirect(slices: AnyRef*): ConstraintBuilder =
+ @varargs def allowDirect(slices: AnyRef*): ConstraintBuilder =
modifyConfig(slices.toIndexedSeq, DirectLayeringConstraint)
@varargs def withSlicing(sliceType: String, sls: AnyRef*) = {
View
166 src/main/scala/de/schauderhaft/degraph/check/constraints.scala
@@ -10,99 +10,105 @@ import scalax.collection.mutable.{ Graph => SGraph }
import de.schauderhaft.degraph.configuration.Configuration
import de.schauderhaft.degraph.configuration.Constraint
import de.schauderhaft.degraph.configuration.ConstraintViolation
+import scala.annotation.varargs
/**
* provides a DSLish method of creating Layer instances
*/
object Layer {
- def anyOf(es: String*) = LenientLayer(es: _*)
- def oneOf(es: String*) = StrictLayer(es: _*)
+ @varargs def anyOf(es: String*) = LenientLayer(es: _*)
+ @varargs def oneOf(es: String*) = StrictLayer(es: _*)
+}
+
+object JLayer {
+ @varargs def anyOf(es: String*) = LenientLayer(es: _*)
+ @varargs def oneOf(es: String*) = StrictLayer(es: _*)
}
/**
* one or more slices making up an architectural layer, i.e. a group of slices all constraint in the same way.
*/
sealed trait Layer {
- def contains(elem: String): Boolean
- def denyDependenciesWithinLayer: Boolean
+ def contains(elem: String): Boolean
+ def denyDependenciesWithinLayer: Boolean
}
abstract class SimpleLayer(es: String*) extends Layer {
- private[this] val eSet = es.toSet
- def contains(elem: String): Boolean = eSet.contains(elem)
+ private[this] val eSet = es.toSet
+ def contains(elem: String): Boolean = eSet.contains(elem)
}
/**
* a layer where the elements of that layer may depend on each other
*/
case class LenientLayer(es: String*) extends SimpleLayer(es: _*) {
- val denyDependenciesWithinLayer = false
+ val denyDependenciesWithinLayer = false
}
/**
* a layer where the elements of that may NOT depend on each other
*/
case class StrictLayer(es: String*) extends SimpleLayer(es: _*) {
- val denyDependenciesWithinLayer = true
+ val denyDependenciesWithinLayer = true
}
/**
* a constraint that applies only to a certain sliceType.
*
*/
trait SlicedConstraint extends Constraint {
- def sliceType: String
-
- /**
- * a predicate determining if a given node pair violates this constraint.
- *
- * Will get called with nodes from the slice type of this constraint
- */
- def isViolatedBy(n1: Node, n2: Node): Boolean
-
- protected def slices: IndexedSeq[Layer]
- protected def indexOf(n: Node) = n match {
- case sn: SimpleNode => slices.indexWhere(_.contains(sn.name))
- case _ => throw new IllegalStateException("Sorry, I thought this would never happen, please report a bug including the callstack")
- }
-
- protected def constraitContainsBothNodes(i: Int, j: Int) =
- i >= 0 && j >= 0
-
- /**
- * implemented in such a way that all dependencies of the specified slice type will be iterated and @link isViolatedBy called for each dependency
- */
- def violations(ss: SliceSource): Set[ConstraintViolation] = {
- val sg = ss.slice(sliceType)
- val deps =
- (for {
- eT <- sg.edges.toSeq
- val e = eT.value
- if (isViolatedBy(e._1, e._2))
- } yield (e._1.value, e._2.value))
-
- if (deps.isEmpty)
- Set()
- else
- Set(ConstraintViolation(sliceType, shortString, deps: _*))
-
- }
-
- private def layersToString(ls: Collection[String], start: String, end: String) =
- if (ls.size == 1) ls.head
- else ls.mkString(start, ", ", end)
-
- protected val arrow: String
-
- def shortString =
- (for {
- l <- slices
- s = l match {
- case LenientLayer(es @ _*) => layersToString(es, "(", ")")
- case StrictLayer(es @ _*) => layersToString(es, "[", "]")
- case _ => l.toString()
- }
- } yield s).mkString(" %s ".format(arrow))
+ def sliceType: String
+
+ /**
+ * a predicate determining if a given node pair violates this constraint.
+ *
+ * Will get called with nodes from the slice type of this constraint
+ */
+ def isViolatedBy(n1: Node, n2: Node): Boolean
+
+ protected def slices: IndexedSeq[Layer]
+ protected def indexOf(n: Node) = n match {
+ case sn: SimpleNode => slices.indexWhere(_.contains(sn.name))
+ case _ => throw new IllegalStateException("Sorry, I thought this would never happen, please report a bug including the callstack")
+ }
+
+ protected def constraitContainsBothNodes(i: Int, j: Int) =
+ i >= 0 && j >= 0
+
+ /**
+ * implemented in such a way that all dependencies of the specified slice type will be iterated and @link isViolatedBy called for each dependency
+ */
+ def violations(ss: SliceSource): Set[ConstraintViolation] = {
+ val sg = ss.slice(sliceType)
+ val deps =
+ (for {
+ eT <- sg.edges.toSeq
+ e = eT.value
+ if (isViolatedBy(e._1, e._2))
+ } yield (e._1.value, e._2.value))
+
+ if (deps.isEmpty)
+ Set()
+ else
+ Set(ConstraintViolation(sliceType, shortString, deps: _*))
+
+ }
+
+ private def layersToString(ls: Iterable[String], start: String, end: String) =
+ if (ls.size == 1) ls.head
+ else ls.mkString(start, ", ", end)
+
+ protected val arrow: String
+
+ def shortString =
+ (for {
+ l <- slices
+ s = l match {
+ case LenientLayer(es @ _*) => layersToString(es, "(", ")")
+ case StrictLayer(es @ _*) => layersToString(es, "[", "]")
+ case _ => l.toString()
+ }
+ } yield s).mkString(" %s ".format(arrow))
}
@@ -112,31 +118,31 @@ trait SlicedConstraint extends Constraint {
* Dependencies from and to slices not represented by a layer aren't constraint by this constraint
*/
case class LayeringConstraint(sliceType: String, slices: IndexedSeq[Layer]) extends SlicedConstraint {
- def isViolatedBy(n1: Node, n2: Node) = {
- val i1 = indexOf(n1)
- val i2 = indexOf(n2)
- constraitContainsBothNodes(i1, i2) &&
- (i1 > i2 ||
- (n1 != n2 && i1 == i2 && slices(i1).denyDependenciesWithinLayer))
- }
-
- val arrow = "->"
+ def isViolatedBy(n1: Node, n2: Node) = {
+ val i1 = indexOf(n1)
+ val i2 = indexOf(n2)
+ constraitContainsBothNodes(i1, i2) &&
+ (i1 > i2 ||
+ (n1 != n2 && i1 == i2 && slices(i1).denyDependenciesWithinLayer))
+ }
+
+ val arrow = "->"
}
/**
* each layer (A) mentioned in this constraint may only depend on a layer (B) when A comes directly before B
*/
case class DirectLayeringConstraint(sliceType: String, slices: IndexedSeq[Layer]) extends SlicedConstraint {
- def isViolatedBy(n1: Node, n2: Node) = {
- val i1 = indexOf(n1)
- val i2 = indexOf(n2)
- (constraitContainsBothNodes(i1, i2) &&
- (i1 > i2 ||
- i2 - i1 > 1 || (n1 != n2 && i1 == i2 && slices(i1).denyDependenciesWithinLayer))) ||
- (i1 < 0 && i2 > 0) ||
- (i1 >= 0 && i1 < slices.size - 1 && i2 < 0)
- }
-
- val arrow = "=>"
+ def isViolatedBy(n1: Node, n2: Node) = {
+ val i1 = indexOf(n1)
+ val i2 = indexOf(n2)
+ (constraitContainsBothNodes(i1, i2) &&
+ (i1 > i2 ||
+ i2 - i1 > 1 || (n1 != n2 && i1 == i2 && slices(i1).denyDependenciesWithinLayer))) ||
+ (i1 < 0 && i2 > 0) ||
+ (i1 >= 0 && i1 < slices.size - 1 && i2 < 0)
+ }
+
+ val arrow = "=>"
}
View
23 src/test/java/de/schauderhaft/degraph/check/JavaCheckApiTest.java
@@ -1,8 +1,7 @@
package de.schauderhaft.degraph.check;
-import static de.schauderhaft.degraph.check.Check.classpath;
-
import org.junit.Test;
+import static de.schauderhaft.degraph.check.Check.classpath;
public class JavaCheckApiTest {
@@ -15,4 +14,24 @@ public void canAccessClasspathConfigurationBuilder() {
public void canDefineSlices() {
classpath().withSlicing("blah", "whatever");
}
+
+ @Test
+ public void canUseAllow() {
+ classpath().withSlicing("blah", "whatever").allow("a", "b", "c");
+ }
+
+ @Test
+ public void canUseAllowDirect() {
+ classpath().withSlicing("blah", "whatever").allowDirect("a", "b", "c");
+ }
+
+ @Test
+ public void canUseAnyOf() {
+ JLayer.anyOf("b", "c", "d");
+ }
+
+ @Test
+ public void canUseOneOf() {
+ JLayer.oneOf("b", "c", "d");
+ }
}
View
136 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/AnalyzerTest.scala
@@ -5,7 +5,7 @@ import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.MatchResult
import org.scalatest.matchers.Matcher
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import de.schauderhaft.degraph.graph.Graph
import de.schauderhaft.degraph.model.SimpleNode
import de.schauderhaft.degraph.model.SimpleNode._
@@ -14,84 +14,84 @@ import org.scalatest.junit.JUnitRunner
import de.schauderhaft.degraph.model.Node
@RunWith(classOf[JUnitRunner])
-class AnalyzerTest extends FunSuite with ShouldMatchers {
- private val testClassFolder = System.getProperty("java.class.path")
- println(testClassFolder)
- private val graph = Analyzer.analyze(testClassFolder, x => x, _ => true)
- def stringNodes = graph.topNodes.map(_.toString)
- def nodeByString(name: String) = graph.topNodes.find(
- x => x match {
- case n: SimpleNode => n.name == name
- case _ => false
- })
+class AnalyzerTest extends FunSuite {
+ private val testClassFolder = System.getProperty("java.class.path")
+ println(testClassFolder)
+ private val graph = Analyzer.analyze(testClassFolder, x => x, _ => true)
+ def stringNodes = graph.topNodes.map(_.toString)
+ def nodeByString(name: String) = graph.topNodes.find(
+ x => x match {
+ case n: SimpleNode => n.name == name
+ case _ => false
+ })
- test("Selftest: nodeByString works") {
- nodeByString("java.lang.String").get should be(classNode("java.lang.String"))
- }
+ test("Selftest: nodeByString works") {
+ nodeByString("java.lang.String").get should be(classNode("java.lang.String"))
+ }
- test("Selftest: example classes got analyzed") {
- nodeByString("de.schauderhaft.degraph.examples.SubClass") should not be (None)
- }
+ test("Selftest: example classes got analyzed") {
+ nodeByString("de.schauderhaft.degraph.examples.SubClass") should not be (None)
+ }
- test("Dependency from cub to superclass is found") {
- graph should connect("de.schauderhaft.degraph.examples.SubClass" -> "de.schauderhaft.degraph.examples.SuperClass")
- }
+ test("Dependency from cub to superclass is found") {
+ graph should connect("de.schauderhaft.degraph.examples.SubClass" -> "de.schauderhaft.degraph.examples.SuperClass")
+ }
- test("Dependency from class to usage in constructor is found") {
- graph should connect("de.schauderhaft.degraph.examples.User" -> "de.schauderhaft.degraph.examples.Token")
- }
+ test("Dependency from class to usage in constructor is found") {
+ graph should connect("de.schauderhaft.degraph.examples.User" -> "de.schauderhaft.degraph.examples.Token")
+ }
- test("Dependency from class to member class is found") {
- graph should connect("de.schauderhaft.degraph.examples.OtherUser" -> "de.schauderhaft.degraph.examples.Token")
- }
+ test("Dependency from class to member class is found") {
+ graph should connect("de.schauderhaft.degraph.examples.OtherUser" -> "de.schauderhaft.degraph.examples.Token")
+ }
- test("Dependency from class to annotation") {
- graph should connect("de.schauderhaft.degraph.examples.UsesAnnotation" -> "org.junit.runner.RunWith")
- }
+ test("Dependency from class to annotation") {
+ graph should connect("de.schauderhaft.degraph.examples.UsesAnnotation" -> "org.junit.runner.RunWith")
+ }
- test("Dependency from class to class used in annotation") {
- graph should connect("de.schauderhaft.degraph.examples.UsesAnnotation" -> "de.schauderhaft.degraph.examples.MyRunner")
- }
+ test("Dependency from class to class used in annotation") {
+ graph should connect("de.schauderhaft.degraph.examples.UsesAnnotation" -> "de.schauderhaft.degraph.examples.MyRunner")
+ }
- test("Dependency from class to class used as an array") {
- graph should connect("de.schauderhaft.degraph.examples.DependsOnArray" -> "java.lang.String")
- }
+ test("Dependency from class to class used as an array") {
+ graph should connect("de.schauderhaft.degraph.examples.DependsOnArray" -> "java.lang.String")
+ }
- test("Dependency from class to class used only inside a method") {
- graph should connect("de.schauderhaft.degraph.examples.UsageInMethod" -> "java.lang.String")
- graph should connect("de.schauderhaft.degraph.examples.UsageInMethod" -> "java.lang.System")
- }
+ test("Dependency from class to class used only inside a method") {
+ graph should connect("de.schauderhaft.degraph.examples.UsageInMethod" -> "java.lang.String")
+ graph should connect("de.schauderhaft.degraph.examples.UsageInMethod" -> "java.lang.System")
+ }
- test("No self references") {
- for (
- n <- graph.topNodes;
- n2 <- graph.connectionsOf(n)
- ) n should not be n2
- }
+ test("No self references") {
+ for (
+ n <- graph.topNodes;
+ n2 <- graph.connectionsOf(n)
+ ) n should not be n2
+ }
- private def connect(connection: (String, String)) = {
- val (from, to) = connection
- new Matcher[Graph] {
- override def apply(graph: Graph) = {
- var messages = List[String]()
- val toNode = nodeByString(to)
- if (toNode.isEmpty)
- messages = "there is no node %s in the graph %s".format(to, graph) :: messages
- val fromNode = nodeByString(from)
- if (fromNode.isEmpty)
- messages = "there is no node %s in the graph %s".format(from, graph) :: messages
- else {
- val connections = graph.connectionsOf(fromNode.get)
- if (messages.isEmpty && !connections.contains(toNode.get))
- messages = "there is no connection from %s to %s in %s. The only connections are %s".format(from, to, graph, connections) :: messages
- }
- new MatchResult(
- !toNode.isEmpty
- && !fromNode.isEmpty
- && graph.connectionsOf(fromNode.get).contains(toNode.get),
- messages.mkString(","),
- "There is a connection from %s to %s in %s".format(from, to, graph))
- }
+ private def connect(connection: (String, String)) = {
+ val (from, to) = connection
+ new Matcher[Graph] {
+ override def apply(graph: Graph) = {
+ var messages = List[String]()
+ val toNode = nodeByString(to)
+ if (toNode.isEmpty)
+ messages = "there is no node %s in the graph %s".format(to, graph) :: messages
+ val fromNode = nodeByString(from)
+ if (fromNode.isEmpty)
+ messages = "there is no node %s in the graph %s".format(from, graph) :: messages
+ else {
+ val connections = graph.connectionsOf(fromNode.get)
+ if (messages.isEmpty && !connections.contains(toNode.get))
+ messages = "there is no connection from %s to %s in %s. The only connections are %s".format(from, to, graph, connections) :: messages
}
+ new MatchResult(
+ !toNode.isEmpty
+ && !fromNode.isEmpty
+ && graph.connectionsOf(fromNode.get).contains(toNode.get),
+ messages.mkString(","),
+ "There is a connection from %s to %s in %s".format(from, to, graph))
+ }
}
+ }
}
View
26 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/ConvertTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.analysis.dependencyFinder
import org.scalatest.FunSuite
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import com.jeantessier.dependency.ClassNode
@@ -10,20 +10,20 @@ import de.schauderhaft.degraph.model.SimpleNode
import de.schauderhaft.degraph.model.SimpleNode._
@RunWith(classOf[JUnitRunner])
-class ConverterTest extends FunSuite with ShouldMatchers {
- def pack(name: String) = new PackageNode(name, true)
- def clazz(packName: String, name: String) = new ClassNode(pack(packName), name, true)
+class ConverterTest extends FunSuite {
+ def pack(name: String) = new PackageNode(name, true)
+ def clazz(packName: String, name: String) = new ClassNode(pack(packName), name, true)
- test("class in default package get converted to class with name only") {
- Convert(clazz("", "Classname")) should be(classNode("Classname"))
- }
+ test("class in default package get converted to class with name only") {
+ Convert(clazz("", "Classname")) should be(classNode("Classname"))
+ }
- test("class in other package ignores the package, since the ClassNode contains the full name") {
- Convert(clazz("other", "some.Classname")) should be(classNode("some.Classname"))
- }
+ test("class in other package ignores the package, since the ClassNode contains the full name") {
+ Convert(clazz("other", "some.Classname")) should be(classNode("some.Classname"))
+ }
- test("package gets converted to package name") {
- Convert(pack("package")) should be(packageNode("package"))
- }
+ test("package gets converted to package name") {
+ Convert(pack("package")) should be(packageNode("package"))
+ }
}
View
50 ...st/scala/de/schauderhaft/degraph/analysis/dependencyFinder/IncludeExcludeFilterTest.scala
@@ -9,30 +9,30 @@ import de.schauderhaft.degraph.graph.NodeTestUtil.n
@RunWith(classOf[JUnitRunner])
class IncludeExcludeFilterTest extends FunSuite {
- import org.scalatest.matchers.ShouldMatchers._
-
- val alwaysTrue = (_: AnyRef) => true
- val alwaysFalse = (_: AnyRef) => false
-
- test("true whithout filter") {
- new IncludeExcludeFilter(
- Set(), Set())(n("x")) should be(true)
- }
-
- test("true when any include filter returns true") {
- new IncludeExcludeFilter(
- Set(alwaysFalse, alwaysTrue, alwaysFalse), Set())(n("x")) should be(true)
- }
-
- test("false when all include filters returns false") {
- new IncludeExcludeFilter(
- Set(alwaysFalse, alwaysFalse, alwaysFalse), Set())(n("x")) should be(false)
- }
-
- test("false when any exclude filter returns true") {
- new IncludeExcludeFilter(
- Set(),
- Set(alwaysFalse, alwaysTrue, alwaysFalse))(n("x")) should be(false)
- }
+ import org.scalatest.Matchers._
+
+ val alwaysTrue = (_: AnyRef) => true
+ val alwaysFalse = (_: AnyRef) => false
+
+ test("true whithout filter") {
+ new IncludeExcludeFilter(
+ Set(), Set())(n("x")) should be(true)
+ }
+
+ test("true when any include filter returns true") {
+ new IncludeExcludeFilter(
+ Set(alwaysFalse, alwaysTrue, alwaysFalse), Set())(n("x")) should be(true)
+ }
+
+ test("false when all include filters returns false") {
+ new IncludeExcludeFilter(
+ Set(alwaysFalse, alwaysFalse, alwaysFalse), Set())(n("x")) should be(false)
+ }
+
+ test("false when any exclude filter returns true") {
+ new IncludeExcludeFilter(
+ Set(),
+ Set(alwaysFalse, alwaysTrue, alwaysFalse))(n("x")) should be(false)
+ }
}
View
42 src/test/scala/de/schauderhaft/degraph/analysis/dependencyFinder/NoSelfReferenceTest.scala
@@ -8,35 +8,33 @@ import de.schauderhaft.degraph.slicer.ListCategory
import de.schauderhaft.degraph.model.SimpleNode
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers.be
-import org.scalatest.matchers.ShouldMatchers.convertToAnyShouldWrapper
+import org.scalatest.Matchers._
@RunWith(classOf[JUnitRunner])
class NoSelfReferenceTest extends FunSuite {
- import org.scalatest.matchers.ShouldMatchers._
- def n(s: String) = SimpleNode(s, s)
+ def n(s: String) = SimpleNode(s, s)
- test("returns true for unrelated objects") {
- new NoSelfReference()(n("a"), n("b")) should be(true)
- }
+ test("returns true for unrelated objects") {
+ new NoSelfReference()(n("a"), n("b")) should be(true)
+ }
- test("returns false for identical objects") {
- new NoSelfReference()(n("a"), n("a")) should be(false)
- }
+ test("returns false for identical objects") {
+ new NoSelfReference()(n("a"), n("a")) should be(false)
+ }
- test("returns false if second object is contained in Categories of first instance") {
- new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("a"), n("c")) should be(false)
- }
- test("returns false if first object is con9tained in Categories of second instance") {
- new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("c"), n("a")) should be(false)
- }
+ test("returns false if second object is contained in Categories of first instance") {
+ new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("a"), n("c")) should be(false)
+ }
+ test("returns false if first object is con9tained in Categories of second instance") {
+ new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("c"), n("a")) should be(false)
+ }
- test("returns true for unrelated objects with categories") {
- new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("a"), n("x")) should be(true)
- }
+ test("returns true for unrelated objects with categories") {
+ new NoSelfReference(ListCategory(n("a"), n("b"), n("c"), n("d")))(n("a"), n("x")) should be(true)
+ }
- test("returns true for unrelated objects with common categorY") {
- new NoSelfReference(combine(ListCategory(n("a"), n("b")), ListCategory(n("x"), n("b"))))(n("a"), n("x")) should be(true)
- }
+ test("returns true for unrelated objects with common categorY") {
+ new NoSelfReference(combine(ListCategory(n("a"), n("b")), ListCategory(n("x"), n("b"))))(n("a"), n("x")) should be(true)
+ }
}
View
372 src/test/scala/de/schauderhaft/degraph/check/CheckTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.check
import org.junit.runner.RunWith
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scalatest.OptionValues._
@@ -13,209 +13,209 @@ import de.schauderhaft.degraph.model.Node
import de.schauderhaft.degraph.configuration.CycleFree
@RunWith(classOf[JUnitRunner])
-class CheckTest extends FunSuite with ShouldMatchers {
- val mod = "mod"
+class CheckTest extends FunSuite {
+ val mod = "mod"
- test("configuration contains the classpath") {
- Check.classpath.configuration.classpath.value should include("log4j")
- }
-
- private def mockConfig(conns: Traversable[(Node, Node)]) = {
- val graph = new Graph()
+ test("configuration contains the classpath") {
+ Check.classpath.configuration.classpath.value should include("log4j")
+ }
- for ((a, b) <- conns) graph.connect(a, b)
+ private def mockConfig(conns: Traversable[(Node, Node)]) = {
+ val graph = new Graph()
- val analyzer = new AnalyzerLike {
- def analyze(
- sourceFolder: String,
- categorizer: Node => Node,
- filter: Node => Boolean): Graph = graph
- }
-
- new ConstraintBuilder(
- new Configuration(
- classpath = Some("x"),
- analyzer = analyzer))
- }
+ for ((a, b) <- conns) graph.connect(a, b)
- def ascending(st: String, includeEqual: Boolean = true) = for {
- x <- 'a' to 'c'
- y <- 'a' to 'c'
- if (x < y || x == y && includeEqual)
- } yield (SimpleNode(st, x.toString), SimpleNode(st, y.toString))
-
- def descending(st: String) = for {
- x <- 'a' to 'c'
- y <- 'a' to 'c'
- if (x > y)
- } yield (SimpleNode(st, x.toString), SimpleNode(st, y.toString))
-
- test("matcher accepts violation free graph for simple layering") {
- val conf = mockConfig(ascending(mod)).withSlicing(mod).allow("a", "b", "c")
- val matchResult = Check.violationFree(conf)
- matchResult.matches should be(true)
- matchResult.negatedFailureMessage should be(conf.configuration + " does not yield any violations of the constraints.")
- }
-
- for (illegalCon <- descending(mod))
- test("matcher detects violations for simple layering %s".format(illegalCon)) {
- val conf = mockConfig(Set(illegalCon)).withSlicing(mod).allow("a", "b", "c")
- val matchResult = Check.violationFree(conf)
- matchResult.matches should be(false)
- matchResult.failureMessage should be((
- "%s yields the following constraint violations: [%s](a -> b -> c):%n " + illegalCon._1.name + " -> " + illegalCon._2.name).format(conf.configuration, mod))
- }
-
- for (illegalCon <- descending(mod))
- test("matcher detects cycles %s".format(illegalCon)) {
- val conf = mockConfig(ascending(mod) :+ illegalCon).withSlicing(mod).allow("a", "b", "c")
- Check.violationFree(conf).matches should be(false)
- }
-
- for {
- c <- 'a' to 'c'
- con <- Set(
- (SimpleNode(mod, "a"), SimpleNode("x", c.toString)),
- (SimpleNode("x", c.toString), SimpleNode(mod, "a")))
- } test("constraint ignores connection to and from other slices %s".format(con)) {
- val conf = mockConfig(Set(con)).withSlicing(mod).allow("a", "b", "c")
- Check.violationFree(conf).matches should be(true)
+ val analyzer = new AnalyzerLike {
+ def analyze(
+ sourceFolder: String,
+ categorizer: Node => Node,
+ filter: Node => Boolean): Graph = graph
}
- for {
- c <- 'a' to 'c'
- con <- Set(
- (SimpleNode("x", "a"), SimpleNode("x", c.toString)),
- (SimpleNode("x", c.toString), SimpleNode("x", "a")))
- } test("constraint ignores connections in other slices %s".format(con)) {
- val conf = mockConfig(Set(con)).withSlicing(mod).allow("a", "b", "c")
- Check.violationFree(conf).matches should be(true)
+ new ConstraintBuilder(
+ new Configuration(
+ classpath = Some("x"),
+ analyzer = analyzer))
+ }
+
+ def ascending(st: String, includeEqual: Boolean = true) = for {
+ x <- 'a' to 'c'
+ y <- 'a' to 'c'
+ if (x < y || x == y && includeEqual)
+ } yield (SimpleNode(st, x.toString), SimpleNode(st, y.toString))
+
+ def descending(st: String) = for {
+ x <- 'a' to 'c'
+ y <- 'a' to 'c'
+ if (x > y)
+ } yield (SimpleNode(st, x.toString), SimpleNode(st, y.toString))
+
+ test("matcher accepts violation free graph for simple layering") {
+ val conf = mockConfig(ascending(mod)).withSlicing(mod).allow("a", "b", "c")
+ val matchResult = Check.violationFree(conf)
+ matchResult.matches should be(true)
+ matchResult.negatedFailureMessage should be(conf.configuration + " does not yield any violations of the constraints.")
+ }
+
+ for (illegalCon <- descending(mod))
+ test("matcher detects violations for simple layering %s".format(illegalCon)) {
+ val conf = mockConfig(Set(illegalCon)).withSlicing(mod).allow("a", "b", "c")
+ val matchResult = Check.violationFree(conf)
+ matchResult.matches should be(false)
+ matchResult.failureMessage should be((
+ "%s yields the following constraint violations: [%s](a -> b -> c):%n " + illegalCon._1.name + " -> " + illegalCon._2.name).format(conf.configuration, mod))
}
- test("works without constraints") {
- val conf = mockConfig(ascending(mod))
- Check.violationFree(conf).matches should be(true)
+ for (illegalCon <- descending(mod))
+ test("matcher detects cycles %s".format(illegalCon)) {
+ val conf = mockConfig(ascending(mod) :+ illegalCon).withSlicing(mod).allow("a", "b", "c")
+ Check.violationFree(conf).matches should be(false)
}
- for {
- c1 <- 'a' to 'c'
- c2 <- 'a' to 'c'
- val con = (SimpleNode(mod, c1.toString), SimpleNode(mod, c2.toString))
- } test("accepts unspecified dependencies %s ".format((c1, c2))) {
- val conf = mockConfig(Set(con)).withSlicing(mod).allow("x", "b", "y")
+ for {
+ c <- 'a' to 'c'
+ con <- Set(
+ (SimpleNode(mod, "a"), SimpleNode("x", c.toString)),
+ (SimpleNode("x", c.toString), SimpleNode(mod, "a")))
+ } test("constraint ignores connection to and from other slices %s".format(con)) {
+ val conf = mockConfig(Set(con)).withSlicing(mod).allow("a", "b", "c")
+ Check.violationFree(conf).matches should be(true)
+ }
+
+ for {
+ c <- 'a' to 'c'
+ con <- Set(
+ (SimpleNode("x", "a"), SimpleNode("x", c.toString)),
+ (SimpleNode("x", c.toString), SimpleNode("x", "a")))
+ } test("constraint ignores connections in other slices %s".format(con)) {
+ val conf = mockConfig(Set(con)).withSlicing(mod).allow("a", "b", "c")
+ Check.violationFree(conf).matches should be(true)
+ }
+
+ test("works without constraints") {
+ val conf = mockConfig(ascending(mod))
+ Check.violationFree(conf).matches should be(true)
+ }
+
+ for {
+ c1 <- 'a' to 'c'
+ c2 <- 'a' to 'c'
+ con = (SimpleNode(mod, c1.toString), SimpleNode(mod, c2.toString))
+ } test("accepts unspecified dependencies %s ".format((c1, c2))) {
+ val conf = mockConfig(Set(con)).withSlicing(mod).allow("x", "b", "y")
+ Check.violationFree(conf).matches should be(true)
+ }
+
+ for {
+ con <- ascending(mod, false) ++ descending(mod)
+ } test("multiple constraints both get checked %s".format(con)) {
+ val conf = mockConfig(Set(con)).
+ withSlicing(mod).allow("a", "b", "c").
+ withSlicing(mod).allow("c", "b", "a")
+ Check.violationFree(conf).matches should be(false)
+ }
+
+ for (i <- 0 to 4)
+ test("allowDirect allows direct dependencies between layers, including unspecified %d".format(i)) {
+ def n(c: Char) = SimpleNode(mod, c.toString)
+ val chars = 'a' to 'f'
+ val deps = Set(
+ (n(chars(i)), n(chars(i + 1))),
+ (n(chars(i)), n(chars(i))))
+ val conf = mockConfig(
+ deps).
+ withSlicing(mod).allowDirect("b", "c", "d")
+ withClue(deps) {
Check.violationFree(conf).matches should be(true)
+ }
}
- for {
- con <- ascending(mod, false) ++ descending(mod)
- } test("multiple constraints both get checked %s".format(con)) {
- val conf = mockConfig(Set(con)).
- withSlicing(mod).allow("a", "b", "c").
- withSlicing(mod).allow("c", "b", "a")
+ for (i <- 1 to 2)
+ test("allowDirect disallows inverse dependencies %d".format(i)) {
+ def n(c: Char) = SimpleNode(mod, c.toString)
+ val chars = 'b' to 'd'
+ val deps = Set(
+ (n(chars(i)), n(chars(i - 1))))
+ val conf = mockConfig(
+ deps).
+ withSlicing(mod).allowDirect("b", "c", "d")
+ withClue(deps) {
Check.violationFree(conf).matches should be(false)
+ }
}
- for (i <- 0 to 4)
- test("allowDirect allows direct dependencies between layers, including unspecified %d".format(i)) {
- def n(c: Char) = SimpleNode(mod, c.toString)
- val chars = 'a' to 'f'
- val deps = Set(
- (n(chars(i)), n(chars(i + 1))),
- (n(chars(i)), n(chars(i))))
- val conf = mockConfig(
- deps).
- withSlicing(mod).allowDirect("b", "c", "d")
- withClue(deps) {
- Check.violationFree(conf).matches should be(true)
- }
- }
-
- for (i <- 1 to 2)
- test("allowDirect disallows inverse dependencies %d".format(i)) {
- def n(c: Char) = SimpleNode(mod, c.toString)
- val chars = 'b' to 'd'
- val deps = Set(
- (n(chars(i)), n(chars(i - 1))))
- val conf = mockConfig(
- deps).
- withSlicing(mod).allowDirect("b", "c", "d")
- withClue(deps) {
- Check.violationFree(conf).matches should be(false)
- }
- }
-
- for (i <- 0 to 2)
- test("allowDirect disallows dependencies skipping layers, including unspecified %d".format(i)) {
- def n(c: Char) = SimpleNode(mod, c.toString)
- val chars = 'a' to 'e'
- val deps = Set(
- (n(chars(i)), n(chars(i + 2))))
- val conf = mockConfig(
- deps).
- withSlicing(mod).allowDirect("b", "c", "d")
- withClue(deps) {
- Check.violationFree(conf).matches should be(false)
- }
- }
-
- test("any in group for LayeringConstraint") {
- import Layer._
- ConstraintBuilder(Configuration(constraint = Set())).
- withSlicing("x").
- allow("a", anyOf("b", "c", "d"), "e").
- configuration.
- constraint.head should be(
- LayeringConstraint(
- "x",
- IndexedSeq(
- LenientLayer("a"),
- LenientLayer("b", "c", "d"),
- LenientLayer("e"))))
- }
-
- test("any in group for DirectLayeringConstraint") {
- import Layer._
- ConstraintBuilder(Configuration(constraint = Set())).
- withSlicing("x").
- allowDirect("a", anyOf("b", "c", "d"), "e").
- configuration.
- constraint.head should be(
- DirectLayeringConstraint(
- "x",
- IndexedSeq(
- LenientLayer("a"),
- LenientLayer("b", "c", "d"),
- LenientLayer("e"))))
- }
- test("oneOf in group for LayeringConstraint") {
- import Layer._
- ConstraintBuilder(Configuration(constraint = Set())).
- withSlicing("x").
- allow("a", oneOf("b", "c", "d"), "e").
- configuration.
- constraint.head should be(
- LayeringConstraint(
- "x",
- IndexedSeq(
- LenientLayer("a"),
- StrictLayer("b", "c", "d"),
- LenientLayer("e"))))
+ for (i <- 0 to 2)
+ test("allowDirect disallows dependencies skipping layers, including unspecified %d".format(i)) {
+ def n(c: Char) = SimpleNode(mod, c.toString)
+ val chars = 'a' to 'e'
+ val deps = Set(
+ (n(chars(i)), n(chars(i + 2))))
+ val conf = mockConfig(
+ deps).
+ withSlicing(mod).allowDirect("b", "c", "d")
+ withClue(deps) {
+ Check.violationFree(conf).matches should be(false)
+ }
}
- test("oneOf in group for DirectLayeringConstraint") {
- import Layer._
- ConstraintBuilder(Configuration(constraint = Set())).
- withSlicing("x").
- allowDirect("a", oneOf("b", "c", "d"), "e").
- configuration.
- constraint.head should be(
- DirectLayeringConstraint(
- "x",
- IndexedSeq(
- LenientLayer("a"),
- StrictLayer("b", "c", "d"),
- LenientLayer("e"))))
- }
+ test("any in group for LayeringConstraint") {
+ import Layer._
+ ConstraintBuilder(Configuration(constraint = Set())).
+ withSlicing("x").
+ allow("a", anyOf("b", "c", "d"), "e").
+ configuration.
+ constraint.head should be(
+ LayeringConstraint(
+ "x",
+ IndexedSeq(
+ LenientLayer("a"),
+ LenientLayer("b", "c", "d"),
+ LenientLayer("e"))))
+ }
+
+ test("any in group for DirectLayeringConstraint") {
+ import Layer._
+ ConstraintBuilder(Configuration(constraint = Set())).
+ withSlicing("x").
+ allowDirect("a", anyOf("b", "c", "d"), "e").
+ configuration.
+ constraint.head should be(
+ DirectLayeringConstraint(
+ "x",
+ IndexedSeq(
+ LenientLayer("a"),
+ LenientLayer("b", "c", "d"),
+ LenientLayer("e"))))
+ }
+ test("oneOf in group for LayeringConstraint") {
+ import Layer._
+ ConstraintBuilder(Configuration(constraint = Set())).
+ withSlicing("x").
+ allow("a", oneOf("b", "c", "d"), "e").
+ configuration.
+ constraint.head should be(
+ LayeringConstraint(
+ "x",
+ IndexedSeq(
+ LenientLayer("a"),
+ StrictLayer("b", "c", "d"),
+ LenientLayer("e"))))
+ }
+
+ test("oneOf in group for DirectLayeringConstraint") {
+ import Layer._
+ ConstraintBuilder(Configuration(constraint = Set())).
+ withSlicing("x").
+ allowDirect("a", oneOf("b", "c", "d"), "e").
+ configuration.
+ constraint.head should be(
+ DirectLayeringConstraint(
+ "x",
+ IndexedSeq(
+ LenientLayer("a"),
+ StrictLayer("b", "c", "d"),
+ LenientLayer("e"))))
+ }
}
View
20 src/test/scala/de/schauderhaft/degraph/check/ConstraintBuilderTest.scala
@@ -2,21 +2,21 @@ package de.schauderhaft.degraph.check
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.scalatest.FunSuite
import de.schauderhaft.degraph.configuration.UnnamedPattern
import de.schauderhaft.degraph.configuration.NamedPattern
@RunWith(classOf[JUnitRunner])
-class ConstraintBuilderTest extends FunSuite with ShouldMatchers {
+class ConstraintBuilderTest extends FunSuite {
- test("simple Pattern ends up In Configuration") {
- val conf = ConstraintBuilder().withSlicing("x", "a.(*).**").configuration
- conf.categories should be(Map("x" -> Seq(UnnamedPattern("a.(*).**"))))
- }
- test("named Pattern ends up In Configuration") {
- val conf = ConstraintBuilder().withSlicing("type", ("name", "pattern")).configuration
- conf.categories should be(Map("type" -> Seq(NamedPattern("name", "pattern"))))
- }
+ test("simple Pattern ends up In Configuration") {
+ val conf = ConstraintBuilder().withSlicing("x", "a.(*).**").configuration
+ conf.categories should be(Map("x" -> Seq(UnnamedPattern("a.(*).**"))))
+ }
+ test("named Pattern ends up In Configuration") {
+ val conf = ConstraintBuilder().withSlicing("type", ("name", "pattern")).configuration
+ conf.categories should be(Map("type" -> Seq(NamedPattern("name", "pattern"))))
+ }
}
View
94 src/test/scala/de/schauderhaft/degraph/check/CycleFreeTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.check
import org.junit.runner.RunWith
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import de.schauderhaft.degraph.graph.NodeTestUtil.n
@@ -17,59 +17,59 @@ import org.scalatest.junit.JUnitRunner
import de.schauderhaft.degraph.configuration.CycleFree
@RunWith(classOf[JUnitRunner])
-class CycleFreeTest extends FunSuite with ShouldMatchers {
- import ConstraintViolationTestUtil._
+class CycleFreeTest extends FunSuite {
+ import ConstraintViolationTestUtil._
- test("an empty graph has no cycles") {
- val g = new Graph()
- CycleFree.violations(g) should be(Set())
- }
+ test("an empty graph has no cycles") {
+ val g = new Graph()
+ CycleFree.violations(g) should be(Set())
+ }
- test("a graph with two cyclic dependent nodes without slices does not report those as cycles") {
- val g = new Graph()
- g.connect(n("a"), n("b"))
- g.connect(n("b"), n("a"))
- CycleFree.violations(g) should be(Set())
- }
+ test("a graph with two cyclic dependent nodes without slices does not report those as cycles") {
+ val g = new Graph()
+ g.connect(n("a"), n("b"))
+ g.connect(n("b"), n("a"))
+ CycleFree.violations(g) should be(Set())
+ }
- test("a graph with a cyclic dependency between two packages returns dependencies between those packages as cyclic") {
- val g = new Graph(PackageCategorizer)
- g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
- g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
- g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
+ test("a graph with a cyclic dependency between two packages returns dependencies between those packages as cyclic") {
+ val g = new Graph(PackageCategorizer)
+ g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
+ g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
+ g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
- dependenciesIn(CycleFree.violations(g)) should be(Set(
- (packageNode("de.p1"), packageNode("de.p2")),
- (packageNode("de.p2"), packageNode("de.p3")),
- (packageNode("de.p3"), packageNode("de.p1"))))
- }
+ dependenciesIn(CycleFree.violations(g)) should be(Set(
+ (packageNode("de.p1"), packageNode("de.p2")),
+ (packageNode("de.p2"), packageNode("de.p3")),
+ (packageNode("de.p3"), packageNode("de.p1"))))
+ }
- test("detecting package cycles works with combined slices") {
- val g = new Graph(new ParallelCategorizer(PackageCategorizer, _ => SimpleNode("tld", "de")))
- g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
- g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
- g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
+ test("detecting package cycles works with combined slices") {
+ val g = new Graph(new ParallelCategorizer(PackageCategorizer, _ => SimpleNode("tld", "de")))
+ g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
+ g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
+ g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
- dependenciesIn(CycleFree.violations(g)) should be(Set(
- (packageNode("de.p1"), packageNode("de.p2")),
- (packageNode("de.p2"), packageNode("de.p3")),
- (packageNode("de.p3"), packageNode("de.p1"))))
- }
+ dependenciesIn(CycleFree.violations(g)) should be(Set(
+ (packageNode("de.p1"), packageNode("de.p2")),
+ (packageNode("de.p2"), packageNode("de.p3")),
+ (packageNode("de.p3"), packageNode("de.p1"))))
+ }
- test("a graph with a cyclic dependency between two sets of packages returns dependencies between those packages as cyclic") {
- val g = new Graph(PackageCategorizer)
- g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
- g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
- g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
- g.connect(classNode("com.p1.A1"), classNode("com.p2.B2"))
- g.connect(classNode("com.p2.B1"), classNode("com.p1.C2"))
+ test("a graph with a cyclic dependency between two sets of packages returns dependencies between those packages as cyclic") {
+ val g = new Graph(PackageCategorizer)
+ g.connect(classNode("de.p1.A1"), classNode("de.p2.B2"))
+ g.connect(classNode("de.p2.B1"), classNode("de.p3.C2"))
+ g.connect(classNode("de.p3.C1"), classNode("de.p1.A2"))
+ g.connect(classNode("com.p1.A1"), classNode("com.p2.B2"))
+ g.connect(classNode("com.p2.B1"), classNode("com.p1.C2"))
- dependenciesIn(CycleFree.violations(g)) should be(Set(
- (packageNode("de.p1"), packageNode("de.p2")),
- (packageNode("de.p2"), packageNode("de.p3")),
- (packageNode("de.p3"), packageNode("de.p1")),
- (packageNode("com.p2"), packageNode("com.p1")),
- (packageNode("com.p1"), packageNode("com.p2"))))
- }
+ dependenciesIn(CycleFree.violations(g)) should be(Set(
+ (packageNode("de.p1"), packageNode("de.p2")),
+ (packageNode("de.p2"), packageNode("de.p3")),
+ (packageNode("de.p3"), packageNode("de.p1")),
+ (packageNode("com.p2"), packageNode("com.p1")),
+ (packageNode("com.p1"), packageNode("com.p2"))))
+ }
}
View
30 src/test/scala/de/schauderhaft/degraph/check/DependencyTest.scala
@@ -2,26 +2,26 @@ package de.schauderhaft.degraph.check
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.scalatest.FunSuite
import Check._
@RunWith(classOf[JUnitRunner])
-class DependencyTest extends FunSuite with ShouldMatchers {
+class DependencyTest extends FunSuite {
- test("Degraph honors its constraints") {
- classpath.including("de.schauderhaft.**").
- withSlicing("part", "de.schauderhaft.*.(*).**").
- withSlicing("lib", "de.schauderhaft.**(Test)",
- ("main", "de.schauderhaft.*.**")).
- withSlicing("internalExternal", ("internal", "de.schauderhaft.**"), ("external", "**")) should be(violationFree)
- }
+ test("Degraph honors its constraints") {
+ classpath.including("de.schauderhaft.**").
+ withSlicing("part", "de.schauderhaft.*.(*).**").
+ withSlicing("lib", "de.schauderhaft.**(Test)",
+ ("main", "de.schauderhaft.*.**")).
+ withSlicing("internalExternal", ("internal", "de.schauderhaft.**"), ("external", "**")) should be(violationFree)
+ }
- test("Check identifies cycles in log4j") {
- classpath.including("org.apache.log4j.**") should not be (violationFree)
- }
+ test("Check identifies cycles in log4j") {
+ classpath.including("org.apache.log4j.**") should not be (violationFree)
+ }
- test("Degraph has no cycles") {
- classpath.including("de.schauderhaft.**") should be(violationFree)
- }
+ test("Degraph has no cycles") {
+ classpath.including("de.schauderhaft.**") should be(violationFree)
+ }
}
View
82 src/test/scala/de/schauderhaft/degraph/check/DirectLayeringConstraintTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.check
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import de.schauderhaft.degraph.model.SimpleNode
@@ -10,55 +10,55 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
object ConstraintViolationTestUtil {
- def dependenciesIn(v: Set[ConstraintViolation]) = v.flatMap(_.dependencies.toSet)
+ def dependenciesIn(v: Set[ConstraintViolation]) = v.flatMap(_.dependencies.toSet)
}
@RunWith(classOf[JUnitRunner])
-class DirectLayeringConstraintTest extends FunSuite with ShouldMatchers {
- import ConstraintViolationTestUtil._
+class DirectLayeringConstraintTest extends FunSuite {
+ import ConstraintViolationTestUtil._
- val c = DirectLayeringConstraint("t", IndexedSeq(LenientLayer("a"), LenientLayer("b"), LenientLayer("c")))
+ val c = DirectLayeringConstraint("t", IndexedSeq(LenientLayer("a"), LenientLayer("b"), LenientLayer("c")))
- test("simple violation free graph returns empty Set of violations") {
- c.violations(MockSliceSource("t", "a" -> "b", "b" -> "c")) should be(Set())
- }
+ test("simple violation free graph returns empty Set of violations") {
+ c.violations(MockSliceSource("t", "a" -> "b", "b" -> "c")) should be(Set())
+ }
- test("it's not ok to skip layers") {
- dependenciesIn(c.violations(MockSliceSource("t", "a" -> "c"))) should be(
- Set((SimpleNode("t", "a"), SimpleNode("t", "c"))))
- }
+ test("it's not ok to skip layers") {
+ dependenciesIn(c.violations(MockSliceSource("t", "a" -> "c"))) should be(
+ Set((SimpleNode("t", "a"), SimpleNode("t", "c"))))
+ }
- test("reverse dependency is reported as a violation") {
- dependenciesIn(c.violations(MockSliceSource("t", "b" -> "a"))) should
- be(Set((SimpleNode("t", "b"), SimpleNode("t", "a"))))
- }
- test("dependencies in other layers are ignored") {
- c.violations(MockSliceSource("x", "b" -> "a")) should be(Set())
- }
+ test("reverse dependency is reported as a violation") {
+ dependenciesIn(c.violations(MockSliceSource("t", "b" -> "a"))) should
+ be(Set((SimpleNode("t", "b"), SimpleNode("t", "a"))))
+ }
+ test("dependencies in other layers are ignored") {
+ c.violations(MockSliceSource("x", "b" -> "a")) should be(Set())
+ }
- test("dependency to unknown is ok when from last") {
- c.violations(MockSliceSource("t", "c" -> "x")) should be(Set())
- }
+ test("dependency to unknown is ok when from last") {
+ c.violations(MockSliceSource("t", "c" -> "x")) should be(Set())
+ }
- test("dependency from unknown is ok when to first") {
- c.violations(MockSliceSource("t", "x" -> "a")) should be(Set())
- }
- test("dependency to unknown is not ok when from middle") {
- dependenciesIn(c.violations(MockSliceSource("t", "b" -> "x"))) should
- be(Set((SimpleNode("t", "b"), SimpleNode("t", "x"))))
- }
+ test("dependency from unknown is ok when to first") {
+ c.violations(MockSliceSource("t", "x" -> "a")) should be(Set())
+ }
+ test("dependency to unknown is not ok when from middle") {
+ dependenciesIn(c.violations(MockSliceSource("t", "b" -> "x"))) should
+ be(Set((SimpleNode("t", "b"), SimpleNode("t", "x"))))
+ }
- test("dependency from unknown is not ok when to middle") {
- dependenciesIn(c.violations(MockSliceSource("t", "x" -> "b"))) should
- be(Set((SimpleNode("t", "x"), SimpleNode("t", "b"))))
- }
+ test("dependency from unknown is not ok when to middle") {
+ dependenciesIn(c.violations(MockSliceSource("t", "x" -> "b"))) should
+ be(Set((SimpleNode("t", "x"), SimpleNode("t", "b"))))
+ }
- test("shortString with single element layers") {
- DirectLayeringConstraint("type", IndexedSeq(StrictLayer("a"), LenientLayer("b"))).
- shortString should be("a => b")
- }
- test("shortString with multi element layers") {
- DirectLayeringConstraint("type", IndexedSeq(StrictLayer("a", "x"), LenientLayer("b", "y"))).
- shortString should be("[a, x] => (b, y)")
- }
+ test("shortString with single element layers") {
+ DirectLayeringConstraint("type", IndexedSeq(StrictLayer("a"), LenientLayer("b"))).
+ shortString should be("a => b")
+ }
+ test("shortString with multi element layers") {
+ DirectLayeringConstraint("type", IndexedSeq(StrictLayer("a", "x"), LenientLayer("b", "y"))).
+ shortString should be("[a, x] => (b, y)")
+ }
}
View
86 src/test/scala/de/schauderhaft/degraph/check/LayeringConstraintTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.check
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import de.schauderhaft.degraph.model.SimpleNode
@@ -10,46 +10,46 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class LayeringConstraintTest extends FunSuite with ShouldMatchers {
- val c = LayeringConstraint("t", IndexedSeq(LenientLayer("a"), LenientLayer("b"), LenientLayer("c")))
-
- test("simple violation free graph returns empty Set of violations") {
- c.violations(MockSliceSource("t", "a" -> "b", "b" -> "c")) should be(Set())
- }
-
- test("it's ok to skip layers") {
- c.violations(MockSliceSource("t", "a" -> "c")) should be(Set())
- }
-
- test("reverse dependency is reported as a violation") {
- dependenciesIn(c.violations(MockSliceSource("t", "b" -> "a"))) should
- be(Set((SimpleNode("t", "b"), SimpleNode("t", "a"))))
- }
- test("dependencies in other layers are ignored") {
- c.violations(MockSliceSource("x", "b" -> "a")) should be(Set())
- }
-
- test("dependency to unknown is ok when from last") {
- c.violations(MockSliceSource("t", "c" -> "x")) should be(Set())
- }
-
- test("dependency from unknown is ok when to first") {
- c.violations(MockSliceSource("t", "x" -> "a")) should be(Set())
- }
- test("dependency to unknown is ok when from middle") {
- c.violations(MockSliceSource("t", "b" -> "x")) should be(Set())
- }
-
- test("dependency from unknown is ok when to middle") {
- c.violations(MockSliceSource("t", "x" -> "b")) should be(Set())
- }
-
- test("shortString with single element layers") {
- LayeringConstraint("type", IndexedSeq(StrictLayer("a"), LenientLayer("b"))).
- shortString should be("a -> b")
- }
- test("shortString with multi element layers") {
- LayeringConstraint("type", IndexedSeq(StrictLayer("a", "x"), LenientLayer("b", "y"))).
- shortString should be("[a, x] -> (b, y)")
- }
+class LayeringConstraintTest extends FunSuite {
+ val c = LayeringConstraint("t", IndexedSeq(LenientLayer("a"), LenientLayer("b"), LenientLayer("c")))
+
+ test("simple violation free graph returns empty Set of violations") {
+ c.violations(MockSliceSource("t", "a" -> "b", "b" -> "c")) should be(Set())
+ }
+
+ test("it's ok to skip layers") {
+ c.violations(MockSliceSource("t", "a" -> "c")) should be(Set())
+ }
+
+ test("reverse dependency is reported as a violation") {
+ dependenciesIn(c.violations(MockSliceSource("t", "b" -> "a"))) should
+ be(Set((SimpleNode("t", "b"), SimpleNode("t", "a"))))
+ }
+ test("dependencies in other layers are ignored") {
+ c.violations(MockSliceSource("x", "b" -> "a")) should be(Set())
+ }
+
+ test("dependency to unknown is ok when from last") {
+ c.violations(MockSliceSource("t", "c" -> "x")) should be(Set())
+ }
+
+ test("dependency from unknown is ok when to first") {
+ c.violations(MockSliceSource("t", "x" -> "a")) should be(Set())
+ }
+ test("dependency to unknown is ok when from middle") {
+ c.violations(MockSliceSource("t", "b" -> "x")) should be(Set())
+ }
+
+ test("dependency from unknown is ok when to middle") {
+ c.violations(MockSliceSource("t", "x" -> "b")) should be(Set())
+ }
+
+ test("shortString with single element layers") {
+ LayeringConstraint("type", IndexedSeq(StrictLayer("a"), LenientLayer("b"))).
+ shortString should be("a -> b")
+ }
+ test("shortString with multi element layers") {
+ LayeringConstraint("type", IndexedSeq(StrictLayer("a", "x"), LenientLayer("b", "y"))).
+ shortString should be("[a, x] -> (b, y)")
+ }
}
View
36 src/test/scala/de/schauderhaft/degraph/check/MultiElementLenientLayerConstraintTest.scala
@@ -1,32 +1,32 @@
package de.schauderhaft.degraph.check
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class MultiElementLenientLayerConstraintTest extends FunSuite with ShouldMatchers {
- val paramTupel = ("t", IndexedSeq(LenientLayer("a"), LenientLayer("b", "c", "d"), LenientLayer("e")))
- val cons = Seq(LayeringConstraint.tupled(paramTupel),
- DirectLayeringConstraint.tupled(paramTupel))
+class MultiElementLenientLayerConstraintTest extends FunSuite {
+ val paramTupel = ("t", IndexedSeq(LenientLayer("a"), LenientLayer("b", "c", "d"), LenientLayer("e")))
+ val cons = Seq(LayeringConstraint.tupled(paramTupel),
+ DirectLayeringConstraint.tupled(paramTupel))
- for (c <- cons) {
- test("dependencies into a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "a" -> "b", "a" -> "d")) should be(Set())
- }
+ for (c <- cons) {
+ test("dependencies into a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "a" -> "b", "a" -> "d")) should be(Set())
+ }
- test("dependencies from a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "b" -> "e", "d" -> "e")) should be(Set())
- }
- test("dependencies within a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "b" -> "c", "b" -> "d")) should be(Set())
- }
+ test("dependencies from a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "b" -> "e", "d" -> "e")) should be(Set())
+ }
+ test("dependencies within a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "b" -> "c", "b" -> "d")) should be(Set())
+ }
- test("self dependencies within a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "b" -> "b")) should be(Set())
- }
+ test("self dependencies within a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "b" -> "b")) should be(Set())
}
+ }
}
View
64 src/test/scala/de/schauderhaft/degraph/check/MultiElementStrictLayerConstraintTest.scala
@@ -1,7 +1,7 @@
package de.schauderhaft.degraph.check
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import de.schauderhaft.degraph.model.SimpleNode
@@ -10,36 +10,36 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class MultiElementStrictLayerConstraintTest extends FunSuite with ShouldMatchers {
- import ConstraintViolationTestUtil._
-
- val paramTupel = ("t", IndexedSeq(StrictLayer("a"), StrictLayer("b", "c", "d"), StrictLayer("e")))
- val cons = Seq(LayeringConstraint.tupled(paramTupel),
- DirectLayeringConstraint.tupled(paramTupel))
-
- for (c <- cons) {
- test("dependencies into a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "a" -> "b", "a" -> "d")) should be(Set())
- }
-
- test("dependencies from a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "b" -> "e", "d" -> "e")) should be(Set())
- }
-
- test("dependencies within a multielement layer are not ok %s".format(c.getClass())) {
- dependenciesIn(c.violations(MockSliceSource("t", "b" -> "c", "b" -> "d"))) should be(Set(
- (SimpleNode("t", "b"), SimpleNode("t", "c")),
- (SimpleNode("t", "b"), SimpleNode("t", "d"))))
- }
-
- test("inverse dependencies within a multielement layer are not ok %s".format(c.getClass())) {
- dependenciesIn(c.violations(MockSliceSource("t", "c" -> "b", "d" -> "b"))) should be(Set(
- (SimpleNode("t", "c"), SimpleNode("t", "b")),
- (SimpleNode("t", "d"), SimpleNode("t", "b"))))
- }
-
- test("self dependencies within a multielement layer are ok %s".format(c.getClass())) {
- c.violations(MockSliceSource("t", "b" -> "b")) should be(Set())
- }
+class MultiElementStrictLayerConstraintTest extends FunSuite {
+ import ConstraintViolationTestUtil._
+
+ val paramTupel = ("t", IndexedSeq(StrictLayer("a"), StrictLayer("b", "c", "d"), StrictLayer("e")))
+ val cons = Seq(LayeringConstraint.tupled(paramTupel),
+ DirectLayeringConstraint.tupled(paramTupel))
+
+ for (c <- cons) {
+ test("dependencies into a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "a" -> "b", "a" -> "d")) should be(Set())
+ }
+
+ test("dependencies from a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "b" -> "e", "d" -> "e")) should be(Set())
+ }
+
+ test("dependencies within a multielement layer are not ok %s".format(c.getClass())) {
+ dependenciesIn(c.violations(MockSliceSource("t", "b" -> "c", "b" -> "d"))) should be(Set(
+ (SimpleNode("t", "b"), SimpleNode("t", "c")),
+ (SimpleNode("t", "b"), SimpleNode("t", "d"))))
+ }
+
+ test("inverse dependencies within a multielement layer are not ok %s".format(c.getClass())) {
+ dependenciesIn(c.violations(MockSliceSource("t", "c" -> "b", "d" -> "b"))) should be(Set(
+ (SimpleNode("t", "c"), SimpleNode("t", "b")),
+ (SimpleNode("t", "d"), SimpleNode("t", "b"))))
+ }
+
+ test("self dependencies within a multielement layer are ok %s".format(c.getClass())) {
+ c.violations(MockSliceSource("t", "b" -> "b")) should be(Set())
}
+ }
}
View
94 src/test/scala/de/schauderhaft/degraph/configuration/CommandLineParserTest.scala
@@ -3,65 +3,63 @@ package de.schauderhaft.degraph.configuration
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers.convertToListShouldWrapper
-import org.scalatest.matchers.ShouldMatchers.convertToStringShouldWrapper
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class CommandLineParserTest extends FunSuite {
- import org.scalatest.matchers.ShouldMatchers._
+ import org.scalatest.Matchers._
- test("default outputfile is 'output.graphml'") {
- val config = CommandLineParser.parse(Array[String]())
- config.initialize { case e => }
- config.output() should be("output.graphml")
- }
+ test("default outputfile is 'output.graphml'") {
+ val config = CommandLineParser.parse(Array[String]())
+ config.initialize { case e => }
+ config.output() should be("output.graphml")
+ }
- test("the string after -o is considered the output file name") {
- val config = CommandLineParser.parse(Array("-o", "ExampleFile"))
- config.initialize { case e => }
- config.output() should be("ExampleFile")
- }
+ test("the string after -o is considered the output file name") {
+ val config = CommandLineParser.parse(Array("-o", "ExampleFile"))
+ config.initialize { case e => }
+ config.output() should be("ExampleFile")
+ }
- test("default input is empty") {
- val config = CommandLineParser.parse(Array[String]())
- config.initialize { case e => }
- config.classpath() should be(".")
- }
+ test("default input is empty") {
+ val config = CommandLineParser.parse(Array[String]())
+ config.initialize { case e => }
+ config.classpath() should be(".")
+ }
- test("the string after -c is considered the input classpath") {
- val config = CommandLineParser.parse(Array("-c", "input;blah.jar"))
- config.initialize { case e => }
- config.classpath() should be("input;blah.jar")
- }
+ test("the string after -c is considered the input classpath") {
+ val config = CommandLineParser.parse(Array("-c", "input;blah.jar"))
+ config.initialize { case e => }
+ config.classpath() should be("input;blah.jar")
+ }
- test("default exclude filter is empty") {
- val config = CommandLineParser.parse(Array[String]())
- config.initialize { case e => }
- config.excludeFilter() should be(List())
- }
- test("the strings after -e s are considered the exclude filter") {
- val config = CommandLineParser.parse(Array("-e", "filter"))
- config.initialize { case e => }
- config.excludeFilter() should be(List("filter"))
- }
+ test("default exclude filter is empty") {
+ val config = CommandLineParser.parse(Array[String]())
+ config.initialize { case e => }
+ config.excludeFilter() should be(List())
+ }
+ test("the strings after -e s are considered the exclude filter") {
+ val config = CommandLineParser.parse(Array("-e", "filter"))
+ config.initialize { case e => }
+ config.excludeFilter() should be(List("filter"))
+ }
- test("default include filter is empty") {
- val config = CommandLineParser.parse(Array[String]())
- config.initialize { case e => }
- config.includeFilter() should be(List())
- }
- test("the strings after -i s are considered the exclude filter") {
- val config = CommandLineParser.parse(Array[String]("-i", "filter"))
- config.initialize { case e => }
- config.includeFilter() should be(List("filter"))
- }
+ test("default include filter is empty") {
+ val config = CommandLineParser.parse(Array[String]())
+ config.initialize { case e => }
+ config.includeFilter() should be(List())
+ }
+ test("the strings after -i s are considered the exclude filter") {
+ val config = CommandLineParser.parse(Array[String]("-i", "filter"))
+ config.initialize { case e => }
+ config.includeFilter() should be(List("filter"))
+ }
- test("the strings after -f are considered the configurationFile") {
- val config = CommandLineParser.parse(Array[String]("-f", "file"))
- config.initialize { case e => }
- config.file.get should be(Some("file"))
- }
+ test("the strings after -f are considered the configurationFile") {
+ val config = CommandLineParser.parse(Array[String]("-f", "file"))
+ config.initialize { case e => }
+ config.file.get should be(Some("file"))
+ }
}
View
4 src/test/scala/de/schauderhaft/degraph/configuration/ConfigurationConstraintTest.scala
@@ -1,11 +1,11 @@
package de.schauderhaft.degraph.configuration
import org.junit.runner.RunWith
-import org.scalatest.matchers.ShouldMatchers
+import org.scalatest.Matchers._
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class ConfigurationConstraintTest extends FunSuite with ShouldMatchers {
+class ConfigurationConstraintTest extends FunSuite {
}
View
129 src/test/scala/de/schauderhaft/degraph/configuration/ConfigurationParserTest.scala
@@ -3,82 +3,83 @@ package de.schauderhaft.degraph.configuration
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
-import org.scalatest.matchers.ShouldMatchers.{ include => _, _ }
+import org.scalatest.Matchers.{ include => _, _ }
+import org.scalatest.FunSuiteLike
@RunWith(classOf[JUnitRunner])
-class ConfigurationParserTest extends ConfigurationParser with FunSuite {
- test("empty file creates empty configuration") {
- parse("") should be(Configuration(None, Seq(), Seq(), Map(), None))
- }
- test("file with just comments creates empty configuration") {
- parse("# comment"