Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
Added test .asJava
Browse files Browse the repository at this point in the history
Opened up Mono.apply and Flux.apply for converting java to scala
Upgrade scala version to 2.11.11
  • Loading branch information
sinwe committed Nov 15, 2017
1 parent 030effb commit faad6f9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=0.3.1-SNAPSHOT
scalaVersions=2.11.9
scalaVersions=2.11.11
2 changes: 1 addition & 1 deletion src/main/scala/reactor/core/scala/publisher/Flux.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3984,7 +3984,7 @@ class Flux[T] private[publisher](private[publisher] val jFlux: JFlux[T]) extends

object Flux {

private[publisher] def apply[T](jFlux: JFlux[T]): Flux[T] = new Flux[T](jFlux)
def apply[T](jFlux: JFlux[T]): Flux[T] = new Flux[T](jFlux)

/**
* Build a [[Flux]] whose data are generated by the combination of the most recent published values from all
Expand Down
10 changes: 10 additions & 0 deletions src/main/scala/reactor/core/scala/publisher/Mono.scala
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ class Mono[T] private(private val jMono: JMono[T]) extends Publisher[T] with Map
)
}

/**
* Add behavior triggered when the [[Mono]] emits a data successfully.
*
* <p>
* <img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.0.RC1/src/docs/marble/doonnext.png" alt="">
* <p>
*
* @param onNext the callback to call on [[Subscriber.onNext]]
* @return a new [[Mono]]
*/
final def doOnNext(onNext: (T => Unit)): Mono[T] = {
val onNextFunction = new Consumer[T] {
override def accept(t: T): Unit = onNext(t)
Expand Down
10 changes: 10 additions & 0 deletions src/test/scala/reactor/core/scala/publisher/FluxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2042,5 +2042,15 @@ class FluxTest extends FreeSpec with Matchers with TableDrivenPropertyChecks {
.verifyComplete()
}
}

".asJava should convert to java" in {
val flux = Flux.just(1, 2, 3).asJava()
flux shouldBe a[reactor.core.publisher.Flux[_]]
}

".apply should convert to scala" in {
val flux = Flux(reactor.core.publisher.Flux.just(1, 2, 3))
flux shouldBe a[Flux[_]]
}
}
}
12 changes: 11 additions & 1 deletion src/test/scala/reactor/core/scala/publisher/MonoTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class MonoTest extends FreeSpec with Matchers with TableDrivenPropertyChecks wit
}

".delayUntil should delay until the other provider terminate" in {
StepVerifier.withVirtualTime(() => Mono.just(randomValue).delayUntil(t => Flux.just(1, 2).delayElements(2 seconds)))
StepVerifier.withVirtualTime(() => Mono.just(randomValue).delayUntil(_ => Flux.just(1, 2).delayElements(2 seconds)))
.thenAwait(4 seconds)
.expectNext(randomValue)
.verifyComplete()
Expand Down Expand Up @@ -1162,6 +1162,16 @@ class MonoTest extends FreeSpec with Matchers with TableDrivenPropertyChecks wit
.expectNext(randomValue.toString)
.verifyComplete()
}

".asJava should convert to java" in {
val mono = Mono.just(randomValue).asJava()
mono shouldBe a[JMono[_]]
}

".apply should convert to scala" in {
val mono = Mono(JMono.just(randomValue))
mono shouldBe a[Mono[_]]
}
}


Expand Down

0 comments on commit faad6f9

Please sign in to comment.