Skip to content

Commit

Permalink
updated StoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bennfocus committed Jan 2, 2019
1 parent 89ffef7 commit 85ec767
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package com.thenetcircle.event_bus.story

import akka.NotUsed
import akka.stream.Attributes
import akka.stream.scaladsl.{Flow, Source}
import com.thenetcircle.event_bus.TestBase
import com.thenetcircle.event_bus.interfaces.EventStatus._
import com.thenetcircle.event_bus.story.Story.Payload

import scala.concurrent.{Await, Future}
import scala.util.Random

class StoryTest extends TestBase {

Expand All @@ -33,17 +35,25 @@ class StoryTest extends TestBase {

val slowTask: Flow[Payload, Payload, NotUsed] = Flow[Payload]
.mapAsync(2) { pl =>
Thread.sleep(1000)
Future.successful(pl)
Future {
Thread.sleep(Random.nextInt(1000))
pl
}
}
val wrappedTask: Flow[Payload, Payload, NotUsed] = Story.wrapTask(slowTask, "testTask")

val slowTask2: Flow[Payload, Payload, NotUsed] = Flow[Payload].async
.addAttributes(Attributes.inputBuffer(1, 1))

val wrappedTask: Flow[Payload, Payload, NotUsed] = Story.wrapTask(slowTask2, "testTask")

val testSource: Source[Payload, NotUsed] = Source(
List(
(NORM, createTestEvent("norm_event1")),
(SKIP, createTestEvent("skip_event1")),
(NORM, createTestEvent("norm_event2")),
(SKIP, createTestEvent("skip_event2"))
(SKIP, createTestEvent("skip_event2")),
(NORM, createTestEvent("norm_event3")),
(SKIP, createTestEvent("skip_event3"))
)
)

Expand Down

0 comments on commit 85ec767

Please sign in to comment.