Add FunctionConverters, FutureConverters and ObjectConverters
This commit is contained in:
parent
dfa0b0ded1
commit
07df607192
70 changed files with 1041 additions and 339 deletions
|
|
@ -15,13 +15,12 @@ package org.apache.pekko.actor.testkit.typed
|
|||
|
||||
import java.util.Optional
|
||||
|
||||
import scala.compat.java8.OptionConverters._
|
||||
|
||||
import org.slf4j.Marker
|
||||
import org.slf4j.event.Level
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.util.OptionConverters._
|
||||
import pekko.util.OptionVal
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +39,7 @@ final case class CapturedLogEvent(level: Level, message: String, cause: Option[T
|
|||
errorCause: Optional[Throwable],
|
||||
marker: Optional[Marker],
|
||||
mdc: java.util.Map[String, Any]) =
|
||||
this(level, message, errorCause.asScala, marker.asScala)
|
||||
this(level, message, errorCause.toScala, marker.toScala)
|
||||
|
||||
/**
|
||||
* Constructor for Java API
|
||||
|
|
@ -66,9 +65,9 @@ final case class CapturedLogEvent(level: Level, message: String, cause: Option[T
|
|||
def this(level: Level, message: String, errorCause: Throwable, marker: Marker) =
|
||||
this(level, message, Some(errorCause), Some(marker))
|
||||
|
||||
def getErrorCause: Optional[Throwable] = cause.asJava
|
||||
def getErrorCause: Optional[Throwable] = cause.toJava
|
||||
|
||||
def getMarker: Optional[Marker] = marker.asJava
|
||||
def getMarker: Optional[Marker] = marker.toJava
|
||||
}
|
||||
|
||||
object CapturedLogEvent {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
package org.apache.pekko.actor.testkit.typed
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.actor.typed.{ ActorRef, Behavior, Props }
|
||||
import pekko.annotation.{ DoNotInherit, InternalApi }
|
||||
import pekko.util.FunctionConverters._
|
||||
import pekko.util.JavaDurationConverters._
|
||||
import pekko.util.unused
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@ package org.apache.pekko.actor.testkit.typed
|
|||
|
||||
import java.util.Optional
|
||||
|
||||
import scala.compat.java8.OptionConverters._
|
||||
|
||||
import org.slf4j.Marker
|
||||
import org.slf4j.event.Level
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.util.ccompat.JavaConverters._
|
||||
import pekko.util.OptionConverters._
|
||||
|
||||
object LoggingEvent {
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ object LoggingEvent {
|
|||
marker: Optional[Marker],
|
||||
throwable: Optional[Throwable],
|
||||
mdc: java.util.Map[String, String]) =
|
||||
apply(level, loggerName, threadName, message, timeStamp, marker.asScala, throwable.asScala, mdc.asScala.toMap)
|
||||
apply(level, loggerName, threadName, message, timeStamp, marker.toScala, throwable.toScala, mdc.asScala.toMap)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,13 +69,13 @@ final case class LoggingEvent(
|
|||
* Java API
|
||||
*/
|
||||
def getMarker: Optional[Marker] =
|
||||
marker.asJava
|
||||
marker.toJava
|
||||
|
||||
/**
|
||||
* Java API
|
||||
*/
|
||||
def getThrowable: Optional[Throwable] =
|
||||
throwable.asJava
|
||||
throwable.toJava
|
||||
|
||||
/**
|
||||
* Java API
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
package org.apache.pekko.actor.testkit.typed.internal
|
||||
|
||||
import java.util.concurrent.{ CompletionStage, ThreadFactory }
|
||||
import scala.compat.java8.FutureConverters
|
||||
import scala.concurrent._
|
||||
import scala.annotation.nowarn
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
|
@ -38,6 +37,7 @@ import pekko.actor.typed.internal.ActorRefImpl
|
|||
import pekko.actor.typed.internal.InternalRecipientRef
|
||||
import pekko.actor.typed.receptionist.Receptionist
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.util.FutureConverters
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
|
|
@ -108,7 +108,7 @@ import pekko.annotation.InternalApi
|
|||
private val terminationPromise = Promise[Done]()
|
||||
override def terminate(): Unit = terminationPromise.trySuccess(Done)
|
||||
override def whenTerminated: Future[Done] = terminationPromise.future
|
||||
override def getWhenTerminated: CompletionStage[Done] = FutureConverters.toJava(whenTerminated)
|
||||
override def getWhenTerminated: CompletionStage[Done] = FutureConverters.asJava(whenTerminated)
|
||||
override val startTime: Long = System.currentTimeMillis()
|
||||
override def uptime: Long = System.currentTimeMillis() - startTime
|
||||
override def threadFactory: java.util.concurrent.ThreadFactory = new ThreadFactory {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue