I have an Actor, which publish different kind of messages at different events and junit has been written for that using TestKit.
I want to consume message with "specific word" only and skip the rest. Below code consumes all the message but I want to check all and only consume message with specific word, rest to ignore.
while (testKit.msgAvailable()) {
testKit.expectMsgClass(Message.class);
}
How I may do? I could see a method "fishForSpecificMessage()" but not getting how I could do compare the string at Function parameter or provide the implementation for it.
Please help with some example.
The Java API for
fishForSpecificMethod
appears basically broken: it makes sense in the Scala API, where it takes a partial function, but since the Java API takes a total function, the underlying implementation (which is the Scala API) prevents the Java API from meeting its contract.In Java, the most natural thing is probably going to be along the lines of