diff options
author | Sam Guymer <sam@guymer.me> | 2018-05-20 21:02:37 +1000 |
---|---|---|
committer | Sam Guymer <sam@guymer.me> | 2018-05-20 21:02:37 +1000 |
commit | bcb94e252a96c78b1db29aebe47b18bfd337e764 (patch) | |
tree | 7462765d4dfcb2eda9a21591aba1bcfc51352b9f /implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala | |
parent | 92e10991df0d168d1972d4618fcc7e02e2e0a0fa (diff) | |
download | sttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.tar.gz sttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.tar.bz2 sttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.zip |
Code review updates
Remove tests sub project, all tests are now in core.
Remove TestStreamingBackend, StreamingTest now has the required abstract
methods.
Diffstat (limited to 'implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala')
-rw-r--r-- | implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala b/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala new file mode 100644 index 0000000..d00c056 --- /dev/null +++ b/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala @@ -0,0 +1,26 @@ +package com.softwaremill.sttp.impl.monix + +import java.nio.ByteBuffer + +import com.softwaremill.sttp.testing.ConvertToFuture +import com.softwaremill.sttp.testing.streaming.StreamingTest +import monix.eval.Task +import monix.reactive.Observable + +abstract class MonixStreamingTest extends StreamingTest[Task, Observable[ByteBuffer]] { + + override implicit val convertToFuture: ConvertToFuture[Task] = convertMonixTaskToFuture + + override def bodyProducer(body: String): Observable[ByteBuffer] = + Observable + .fromIterable( + body.getBytes("utf-8") + ) + .map(v => ByteBuffer.wrap(Array(v))) + + override def bodyConsumer(stream: Observable[ByteBuffer]): Task[String] = + stream + .flatMap(v => Observable.fromIterable(v.array())) + .toListL + .map(bs => new String(bs.toArray, "utf8")) +} |