Skip to content

Commit

Permalink
Executing the HamcrestWrapper in a integration test
Browse files Browse the repository at this point in the history
- need to add a hamcrest dependency for main code
- switched the HamcrestWrapper from wrapping a Matcher to wrapping a BeMatcher
- interestingly I had to declare an explicite return type to violationFree to make it work.
  • Loading branch information
schauder committed Jan 1, 2014
1 parent 035ca88 commit bca0288
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Expand Up @@ -107,7 +107,8 @@ dependencies {

testCompile 'junit:junit:4.11'
compile 'org.scalatest:scalatest_2.10:2.0'

compile 'org.hamcrest:hamcrest-all:1.3'

//javafx
compile files(getJavaFXPath(javafxLib))
}
2 changes: 1 addition & 1 deletion src/main/scala/de/schauderhaft/degraph/check/Check.scala
Expand Up @@ -44,7 +44,7 @@ object Check {
* 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] {
val violationFree: BeMatcher[ConstraintBuilder] = new BeMatcher[ConstraintBuilder] {
def apply(constraintBuilder: ConstraintBuilder) = {
val conf = constraintBuilder.configuration
val g = conf.createGraph()
Expand Down
@@ -1,6 +1,6 @@
package de.schauderhaft.degraph.hamcrest

import org.scalatest.matchers.{ Matcher => SMatcher }
import org.scalatest.matchers.{ BeMatcher => SMatcher }
import org.hamcrest.Matcher
import org.hamcrest.TypeSafeMatcher
import org.hamcrest.Description
Expand Down
Expand Up @@ -2,8 +2,12 @@

import de.schauderhaft.degraph.configuration.NamedPattern;
import de.schauderhaft.degraph.check.Check;
import de.schauderhaft.degraph.hamcrest.HamcrestWrapper;

import org.junit.Test;
import org.scalatest.Matchers;

import scala.annotation.meta.beanGetter;
import static org.hamcrest.core.Is.*;

import static org.junit.Assert.assertThat;
Expand Down Expand Up @@ -56,6 +60,6 @@ public void degraphHonoursItsConstraintsJavaStyle() {
new NamedPattern("internal",
"de.schauderhaft.**"),
new NamedPattern("external", "**")),
is(Check.violationFree()));
is(new HamcrestWrapper<ConstraintBuilder>(Check.violationFree())));
}
}
Expand Up @@ -4,7 +4,7 @@ import org.scalatest.Matchers._
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.{ Matcher => SMatcher }
import org.scalatest.matchers.{ BeMatcher => SMatcher }
import org.hamcrest.{ Matcher => HMatcher }
import org.scalatest.matchers.MatchResult
import org.scalatest.prop.PropertyChecks
Expand Down

0 comments on commit bca0288

Please sign in to comment.