XmlMatchers are very powerful, but i'm not able to use it as argument matcher. How can i modify the matcher to be not for Seq[Node]?
trait Connector {
def send(envelope: Node):Elem
}
Write a test with scalatest, using mockito and xmlMatchers traits:
import org.scalatest.junit.AssertionsForJUnit
import org.junit.Test
import org.specs2.mock.Mockito
import scala.xml.Node
import org.specs2.matcher.ThrownExpectations
import org.specs2.matcher.XmlMatchers
class MyClientTest extends AssertionsForJUnit with Mockito with ThrownExpectations with XmlMatchers {
@Test def oclQuery_oclExpression_queryRequestWithOclElement {
//arrange
val connector=mock[Connector]
val testee=MyClient.create(connector)
//act
testee.oclQuery("oclexpr", <Response/> )
//assert
there was one(connector).send( argThat(\\("ocl")) )
}
}
compile error: type mismatch; found : Seq[scala.xml.Node] required: scala.xml.Node
How can i convert the XmlMatcher for \("ocl") to a single node, so the argThat can match the required Node argument?
You need to "adapt" the matcher to take the argument type:
there was one(connector).send(argThat(\\("ocl") ^^ ((_:Node).toSeq)))