aboutsummaryrefslogtreecommitdiff
path: root/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala
diff options
context:
space:
mode:
authorSam Guymer <sam@guymer.me>2018-05-20 21:02:37 +1000
committerSam Guymer <sam@guymer.me>2018-05-20 21:02:37 +1000
commitbcb94e252a96c78b1db29aebe47b18bfd337e764 (patch)
tree7462765d4dfcb2eda9a21591aba1bcfc51352b9f /implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala
parent92e10991df0d168d1972d4618fcc7e02e2e0a0fa (diff)
downloadsttp-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.scala26
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"))
+}