Reputation: 34071
I have a function, that has the following definition:
def expectMsgPF[T](max: Duration = Duration.Undefined, hint: String = "")(f: PartialFunction[Any, T]): T = {
When I call it as follows:
val res1 = listener1.expectMsgPF(1.second)
Is res1
a function?
I would like to write as follow:
val res1 = listener1.expectMsgPF(1.second) _
val res2 = listener2.expectMsgPF(1.second)
Then("it should contain `Kafka and SAP are offline`")
res1 {
case status: ServerStatus =>
status.health should be(ServersOffline)
}
But it does not work.
Upvotes: 2
Views: 54
Reputation: 48420
To make res1 { case status: ServerStatus => status.health should be(ServersOffline) }
work, try helping the compiler out by providing type parameter T
to expectMsgPF[T]
like so
val res1 = listener1.expectMsgPF[Assertion](1.second) _
This makes res1
indeed a function of the type
PartialFunction[Any, Assertion] => Assertion
Upvotes: 3