Skip to content

Commit

Permalink
Convert from scaladsl to javadsl via .asJava
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-sa-schroeder committed Oct 30, 2018
1 parent 82b235a commit 6a406b7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ object JmsConsumer {
private def toConsumerControl(scalaControl: scaladsl.JmsConsumerControl) = new JmsConsumerControl {

override def connectorState(): Source[JmsConnectorState, NotUsed] =
transformConnectorState(scalaControl.connectorState)
scalaControl.connectorState.map(_.asJava).asJava

override def shutdown(): Unit = scalaControl.shutdown()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ object JmsProducer {
private def toProducerStatus(scalaStatus: scaladsl.JmsProducerStatus) = new JmsProducerStatus {

override def connectorState: Source[JmsConnectorState, NotUsed] =
transformConnectorState(scalaStatus.connectorState)
scalaStatus.connectorState.map(_.asJava).asJava
}

}
28 changes: 0 additions & 28 deletions jms/src/main/scala/akka/stream/alpakka/jms/javadsl/package.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package akka.stream.alpakka.jms.scaladsl
import akka.NotUsed
import akka.stream.KillSwitch
import akka.stream.scaladsl.Source
import akka.stream.alpakka.jms.javadsl
import akka.stream.alpakka.jms.scaladsl.JmsConnectorState._

trait JmsProducerStatus {

Expand All @@ -27,7 +29,17 @@ trait JmsConsumerControl extends KillSwitch {

}

sealed trait JmsConnectorState
sealed trait JmsConnectorState {
final def asJava: javadsl.JmsConnectorState = this match {
case Disconnected => javadsl.JmsConnectorState.Disconnected
case Connecting(_) => javadsl.JmsConnectorState.Connecting
case Connected => javadsl.JmsConnectorState.Connected
case Completing => javadsl.JmsConnectorState.Completing
case Completed => javadsl.JmsConnectorState.Completed
case Failing(_) => javadsl.JmsConnectorState.Failing
case Failed(_) => javadsl.JmsConnectorState.Failed
}
}

object JmsConnectorState {
case object Disconnected extends JmsConnectorState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@ class JmsConnectionStatusSpec extends JmsSpec {
import ctx._
val connectAttempts = new AtomicInteger()
when(connection.setExceptionListener(any[ExceptionListener]())).thenAnswer(new Answer[Unit]() {
override def answer(invocation: InvocationOnMock): Unit = {
println("invoked")
override def answer(invocation: InvocationOnMock): Unit =
if (connectAttempts.getAndIncrement() == 0) throw new JMSException("connect error") else ()
}
})

val jmsSink = textSink(JmsProducerSettings(factory).withQueue("test"))
Expand Down

0 comments on commit 6a406b7

Please sign in to comment.