mdedetrich commented on code in PR #58: URL: https://github.com/apache/incubator-pekko/pull/58#discussion_r1027622639
########## akka-actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/scaladsl/TestProbe.scala: ########## @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2017-2022 Lightbend Inc. <https://www.lightbend.com> + */ + +package org.apache.pekko.actor.testkit.typed.scaladsl + +import scala.collection.immutable +import scala.concurrent.duration._ +import scala.reflect.ClassTag + +import org.apache.pekko +import pekko.actor.testkit.typed.FishingOutcome +import pekko.actor.testkit.typed.TestKitSettings +import pekko.actor.testkit.typed.internal.TestProbeImpl +import pekko.actor.typed.ActorRef +import pekko.actor.typed.ActorSystem +import pekko.actor.typed.RecipientRef +import pekko.actor.typed.internal.InternalRecipientRef +import pekko.annotation.DoNotInherit +import pekko.annotation.InternalApi + +object FishingOutcomes { + + /** + * Complete fishing and return all messages up until this + */ + val complete: FishingOutcome = FishingOutcome.Complete + + /** + * Consume this message, collect it into the result, and continue with the next message + */ + val continue: FishingOutcome = FishingOutcome.Continue + + /** + * Consume this message, but do not collect it into the result, and continue with the next message + */ + val continueAndIgnore: FishingOutcome = FishingOutcome.ContinueAndIgnore + + /** + * Fail fishing with a custom error message + */ + def fail(message: String): FishingOutcome = FishingOutcome.Fail(message) +} + +object TestProbe { + def apply[M]()(implicit system: ActorSystem[_]): TestProbe[M] = + apply(name = "testProbe") + + def apply[M](name: String)(implicit system: ActorSystem[_]): TestProbe[M] = + new TestProbeImpl[M](name, system) + +} + +/** + * Create instances through the factories in the [[TestProbe]] companion. + * + * A test probe is essentially a queryable mailbox which can be used in place of an actor and the received + * messages can then be asserted + * + * Not for user extension + */ +@DoNotInherit trait TestProbe[M] extends RecipientRef[M] { this: InternalRecipientRef[M] => + + implicit protected def settings: TestKitSettings + + /** + * ActorRef for this TestProbe + */ + def ref: ActorRef[M] + + /** + * Obtain time remaining for execution of the innermost enclosing `within` + * block or missing that it returns the properly dilated default for this + * case from settings (key "akka.actor.testkit.typed.single-expect-default"). Review Comment: Yes, this will be done in a future PR, this PR is only about package change (and its already big enough). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For additional commands, e-mail: notifications-h...@pekko.apache.org