Skip to content
Permalink
Browse files

format source with scalafmt

  • Loading branch information...
Auto Format authored and patriknw committed Mar 11, 2019
1 parent 0f40491 commit ce404e4f53ac3d164115850d6ee670f036d400f2
Showing 1,669 changed files with 43,441 additions and 35,637 deletions.
@@ -17,17 +17,20 @@ import scala.compat.java8.OptionConverters._
/**
* Representation of a Log Event issued by a [[akka.actor.typed.Behavior]]
*/
final case class CapturedLogEvent(
logLevel: LogLevel,
message: String,
cause: Option[Throwable],
marker: Option[LogMarker],
mdc: Map[String, Any]) {
final case class CapturedLogEvent(logLevel: LogLevel,
message: String,
cause: Option[Throwable],
marker: Option[LogMarker],
mdc: Map[String, Any]) {

/**
* Constructor for Java API
*/
def this(logLevel: LogLevel, message: String, errorCause: Optional[Throwable], marker: Optional[LogMarker], mdc: java.util.Map[String, Any]) {
def this(logLevel: LogLevel,
message: String,
errorCause: Optional[Throwable],
marker: Optional[LogMarker],
mdc: java.util.Map[String, Any]) {
this(logLevel, message, errorCause.asScala, marker.asScala, mdc.asScala.toMap)
}

@@ -76,9 +79,7 @@ object CapturedLogEvent {
case _ => None
}

def apply(
logLevel: LogLevel,
message: String): CapturedLogEvent = {
def apply(logLevel: LogLevel, message: String): CapturedLogEvent = {
CapturedLogEvent(logLevel, message, None, None, Map.empty[String, Any])
}

@@ -87,12 +88,11 @@ object CapturedLogEvent {
* INTERNAL API
*/
@InternalApi
private[akka] def apply(
logLevel: LogLevel,
message: String,
errorCause: OptionVal[Throwable],
logMarker: OptionVal[LogMarker],
mdc: Map[String, Any]): CapturedLogEvent = {
private[akka] def apply(logLevel: LogLevel,
message: String,
errorCause: OptionVal[Throwable],
logMarker: OptionVal[LogMarker],
mdc: Map[String, Any]): CapturedLogEvent = {
new CapturedLogEvent(logLevel, message, toOption(errorCause), toOption(logMarker), mdc)
}
}
@@ -25,17 +25,20 @@ import scala.concurrent.duration.FiniteDuration
abstract class Effect private[akka] ()

object Effect {

/**
* The behavior spawned a named child with the given behavior (and optionally specific props)
*/
final class Spawned[T](val behavior: Behavior[T], val childName: String, val props: Props, val ref: ActorRef[T])
extends Effect with Product3[Behavior[T], String, Props] with Serializable {
extends Effect
with Product3[Behavior[T], String, Props]
with Serializable {

override def equals(other: Any) = other match {
case o: Spawned[_] =>
this.behavior == o.behavior &&
this.childName == o.childName &&
this.props == o.props
this.childName == o.childName &&
this.props == o.props
case _ => false
}
override def hashCode: Int = (behavior.## * 31 + childName.##) * 31 + props.##
@@ -49,15 +52,18 @@ object Effect {
}

object Spawned {
def apply[T](behavior: Behavior[T], childName: String, props: Props = Props.empty): Spawned[T] = new Spawned(behavior, childName, props, null)
def apply[T](behavior: Behavior[T], childName: String, props: Props = Props.empty): Spawned[T] =
new Spawned(behavior, childName, props, null)
def unapply[T](s: Spawned[T]): Option[(Behavior[T], String, Props)] = Some((s.behavior, s.childName, s.props))
}

/**
* The behavior spawned an anonymous child with the given behavior (and optionally specific props)
*/
final class SpawnedAnonymous[T](val behavior: Behavior[T], val props: Props, val ref: ActorRef[T])
extends Effect with Product2[Behavior[T], Props] with Serializable {
extends Effect
with Product2[Behavior[T], Props]
with Serializable {

override def equals(other: Any) = other match {
case o: SpawnedAnonymous[_] => this.behavior == o.behavior && this.props == o.props
@@ -73,7 +79,8 @@ object Effect {
}

object SpawnedAnonymous {
def apply[T](behavior: Behavior[T], props: Props = Props.empty): SpawnedAnonymous[T] = new SpawnedAnonymous(behavior, props, null)
def apply[T](behavior: Behavior[T], props: Props = Props.empty): SpawnedAnonymous[T] =
new SpawnedAnonymous(behavior, props, null)
def unapply[T](s: SpawnedAnonymous[T]): Option[(Behavior[T], Props)] = Some((s.behavior, s.props))
}

@@ -83,7 +90,9 @@ object Effect {
*/
@InternalApi
private[akka] final class SpawnedAdapter[T](val name: String, val ref: ActorRef[T])
extends Effect with Product1[String] with Serializable {
extends Effect
with Product1[String]
with Serializable {

override def equals(other: Any) = other match {
case o: SpawnedAdapter[_] => this.name == o.name
@@ -113,7 +122,9 @@ object Effect {
*/
@InternalApi
private[akka] final class SpawnedAnonymousAdapter[T](val ref: ActorRef[T])
extends Effect with Product with Serializable {
extends Effect
with Product
with Serializable {

override def equals(other: Any): Boolean = other match {
case _: SpawnedAnonymousAdapter[_] => true
@@ -142,6 +153,7 @@ object Effect {
* The behavior create a message adapter for the messages of type clazz
*/
final case class MessageAdapter[A, T](messageClass: Class[A], adapt: A => T) extends Effect {

/**
* JAVA API
*/
@@ -167,6 +179,7 @@ object Effect {
* The behavior set a new receive timeout, with `message` as timeout notification
*/
final case class ReceiveTimeoutSet[T](d: FiniteDuration, message: T) extends Effect {

/**
* Java API
*/
@@ -195,4 +208,3 @@ object Effect {
*/
sealed abstract class NoEffects extends Effect
}

@@ -10,4 +10,3 @@ import scala.util.control.NoStackTrace
* A predefined exception that can be used in tests. It doesn't include a stack trace.
*/
final case class TestException(message: String) extends RuntimeException(message) with NoStackTrace

@@ -12,6 +12,7 @@ import akka.util.Timeout
import akka.actor.typed.ActorSystem

object TestKitSettings {

/**
* Reads configuration settings from `akka.actor.testkit.typed` section.
*/
@@ -43,15 +44,19 @@ final class TestKitSettings(val config: Config) {

import akka.util.Helpers._

val TestTimeFactor = config.getDouble("timefactor").
requiring(tf => !tf.isInfinite && tf > 0, "timefactor must be positive finite double")
val TestTimeFactor = config
.getDouble("timefactor")
.requiring(tf => !tf.isInfinite && tf > 0, "timefactor must be positive finite double")

/** dilated with `TestTimeFactor` */
val SingleExpectDefaultTimeout: FiniteDuration = dilated(config.getMillisDuration("single-expect-default"))

/** dilated with `TestTimeFactor` */
val ExpectNoMessageDefaultTimeout: FiniteDuration = dilated(config.getMillisDuration("expect-no-message-default"))

/** dilated with `TestTimeFactor` */
val DefaultTimeout: Timeout = Timeout(dilated(config.getMillisDuration("default-timeout")))

/** dilated with `TestTimeFactor` */
val DefaultActorSystemShutdownTimeout: FiniteDuration = dilated(config.getMillisDuration("system-shutdown-default"))

@@ -7,7 +7,19 @@ package akka.actor.testkit.typed.internal
import java.util.concurrent.{ CompletionStage, ThreadFactory }

import akka.actor.typed.internal.ActorRefImpl
import akka.actor.typed.{ ActorRef, ActorSystem, Behavior, DispatcherSelector, Dispatchers, Extension, ExtensionId, Logger, Props, Settings, Terminated }
import akka.actor.typed.{
ActorRef,
ActorSystem,
Behavior,
DispatcherSelector,
Dispatchers,
Extension,
ExtensionId,
Logger,
Props,
Settings,
Terminated
}
import akka.annotation.InternalApi
import akka.util.Timeout
import akka.{ actor => untyped }
@@ -22,13 +34,17 @@ import akka.actor.typed.internal.InternalRecipientRef
* INTERNAL API
*/
@InternalApi private[akka] final class ActorSystemStub(val name: String)
extends ActorSystem[Nothing] with ActorRef[Nothing] with ActorRefImpl[Nothing] with InternalRecipientRef[Nothing] {
extends ActorSystem[Nothing]
with ActorRef[Nothing]
with ActorRefImpl[Nothing]
with InternalRecipientRef[Nothing] {

override val path: untyped.ActorPath = untyped.RootActorPath(untyped.Address("akka", name)) / "user"

override val settings: Settings = new Settings(getClass.getClassLoader, ConfigFactory.empty, name)

override def tell(message: Nothing): Unit = throw new UnsupportedOperationException("must not send message to ActorSystemStub")
override def tell(message: Nothing): Unit =
throw new UnsupportedOperationException("must not send message to ActorSystemStub")

// impl ActorRefImpl
override def isLocal: Boolean = true
@@ -72,7 +88,8 @@ import akka.actor.typed.internal.InternalRecipientRef

override def printTree: String = "no tree for ActorSystemStub"

def systemActorOf[U](behavior: Behavior[U], name: String, props: Props)(implicit timeout: Timeout): Future[ActorRef[U]] = {
def systemActorOf[U](behavior: Behavior[U], name: String, props: Props)(
implicit timeout: Timeout): Future[ActorRef[U]] = {
Future.failed(new UnsupportedOperationException("ActorSystemStub cannot create system actors"))
}

@@ -24,8 +24,8 @@ import scala.util.control.NonFatal
*/
@InternalApi
private[akka] final class BehaviorTestKitImpl[T](_path: ActorPath, _initialBehavior: Behavior[T])
extends akka.actor.testkit.typed.javadsl.BehaviorTestKit[T]
with akka.actor.testkit.typed.scaladsl.BehaviorTestKit[T] {
extends akka.actor.testkit.typed.javadsl.BehaviorTestKit[T]
with akka.actor.testkit.typed.scaladsl.BehaviorTestKit[T] {

// really this should be private, make so when we port out tests that need it
private[akka] val context = new EffectfulActorContext[T](_path)
@@ -79,9 +79,10 @@ private[akka] final class BehaviorTestKitImpl[T](_path: ActorPath, _initialBehav
def expectEffectClass[E <: Effect](effectClass: Class[E]): E = {
context.effectQueue.poll() match {
case null if effectClass.isAssignableFrom(NoEffects.getClass) => effectClass.cast(NoEffects)
case null => throw new AssertionError(s"expected: effect type ${effectClass.getName} but no effects were recorded")
case null =>
throw new AssertionError(s"expected: effect type ${effectClass.getName} but no effects were recorded")
case effect if effectClass.isAssignableFrom(effect.getClass) => effect.asInstanceOf[E]
case other => throw new AssertionError(s"expected: effect class ${effectClass.getName} but found $other")
case other => throw new AssertionError(s"expected: effect class ${effectClass.getName} but found $other")
}
}

@@ -19,7 +19,9 @@ import akka.actor.typed.internal.InternalRecipientRef
* INTERNAL API
*/
@InternalApi private[akka] final class DebugRef[T](override val path: untyped.ActorPath, override val isLocal: Boolean)
extends ActorRef[T] with ActorRefImpl[T] with InternalRecipientRef[T] {
extends ActorRef[T]
with ActorRefImpl[T]
with InternalRecipientRef[T] {

private val q = new ConcurrentLinkedQueue[Either[SystemMessage, T]]

@@ -83,4 +83,3 @@ import scala.compat.java8.FunctionConverters._
super.scheduleOnce(delay, target, message)
}
}

0 comments on commit ce404e4

Please sign in to comment.
You can’t perform that action at this time.