Don't use stubbed functions in InvokerSupervisionTests. (#3826)

`stubFunctions` don't seem to play nicely with retry logic because the `verify` handler will be attached more than once. Switching to a manual stub should help here.

Fixes #3809
diff --git a/tests/src/test/scala/common/LoggedFunction.scala b/tests/src/test/scala/common/LoggedFunction.scala
index e8b7261..9c338db 100644
--- a/tests/src/test/scala/common/LoggedFunction.scala
+++ b/tests/src/test/scala/common/LoggedFunction.scala
@@ -83,10 +83,11 @@
 }
 
 object LoggedFunction {
-  def apply[A1, B](body: (A1) => B) = new LoggedFunction1(body)
-  def apply[A1, A2, B](body: (A1, A2) => B) = new LoggedFunction2(body)
-  def apply[A1, A2, A3, B](body: (A1, A2, A3) => B) = new LoggedFunction3(body)
-  def apply[A1, A2, A3, A4, B](body: (A1, A2, A3, A4) => B) = new LoggedFunction4(body)
-  def apply[A1, A2, A3, A4, A5, B](body: (A1, A2, A3, A4, A5) => B) = new LoggedFunction5(body)
-  def apply[A1, A2, A3, A4, A5, A6, B](body: (A1, A2, A3, A4, A5, A6) => B) = new LoggedFunction6(body)
+  def apply[A1, B](body: (A1) => B) = new LoggedFunction1[A1, B](body)
+  def apply[A1, A2, B](body: (A1, A2) => B) = new LoggedFunction2[A1, A2, B](body)
+  def apply[A1, A2, A3, B](body: (A1, A2, A3) => B) = new LoggedFunction3[A1, A2, A3, B](body)
+  def apply[A1, A2, A3, A4, B](body: (A1, A2, A3, A4) => B) = new LoggedFunction4[A1, A2, A3, A4, B](body)
+  def apply[A1, A2, A3, A4, A5, B](body: (A1, A2, A3, A4, A5) => B) = new LoggedFunction5[A1, A2, A3, A4, A5, B](body)
+  def apply[A1, A2, A3, A4, A5, A6, B](body: (A1, A2, A3, A4, A5, A6) => B) =
+    new LoggedFunction6[A1, A2, A3, A4, A5, A6, B](body)
 }
diff --git a/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala b/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
index 2605058..8e11417 100644
--- a/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
+++ b/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
@@ -42,7 +42,7 @@
 import akka.testkit.TestKit
 import akka.testkit.TestProbe
 import akka.util.Timeout
-import common.StreamLogging
+import common.{LoggedFunction, StreamLogging}
 import whisk.common.TransactionId
 import whisk.core.WhiskConfig
 import whisk.core.connector.ActivationMessage
@@ -175,7 +175,9 @@
     val invokerName = s"invoker${invokerInstance.toInt}"
     val childFactory = (f: ActorRefFactory, instance: InvokerInstanceId) => invoker.ref
 
-    val sendActivationToInvoker = stubFunction[ActivationMessage, InvokerInstanceId, Future[RecordMetadata]]
+    val sendActivationToInvoker = LoggedFunction { (a: ActivationMessage, b: InvokerInstanceId) =>
+      Future.successful(new RecordMetadata(new TopicPartition(invokerName, 0), 0L, 0L, 0L, Long.box(0L), 0, 0))
+    }
 
     val supervisor = system.actorOf(InvokerPool.props(childFactory, sendActivationToInvoker, pC))
 
@@ -196,18 +198,10 @@
       content = None)
     val msg = ActivationRequest(activationMessage, invokerInstance)
 
-    sendActivationToInvoker
-      .when(activationMessage, invokerInstance)
-      .returns(
-        Future.successful(new RecordMetadata(new TopicPartition(invokerName, 0), 0L, 0L, 0L, Long.box(0L), 0, 0)))
-
     supervisor ! msg
 
     // Verify, that MessageProducer will receive a call to send the message
-    retry(
-      sendActivationToInvoker.verify(activationMessage, invokerInstance).once,
-      N = 3,
-      waitBeforeRetry = Some(500.milliseconds))
+    retry(sendActivationToInvoker.calls should have size 1, N = 3, waitBeforeRetry = Some(500.milliseconds))
   }
 
   behavior of "InvokerActor"