Created
June 4, 2015 07:27
-
-
Save rjsen/55c833650609aaa97b0a to your computer and use it in GitHub Desktop.
Example Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.log4j.{Level, Logger} | |
import org.specs2.mutable._ | |
import Predef.{conforms => _, _} | |
class ExampleTest extends Specification { | |
Logger.getRootLogger.setLevel(Level.ERROR) | |
sequential | |
"the transformStream method" should { | |
implicit val fun = Example.transformStream _ | |
"with 10 identical records" should { | |
val records = Seq.fill(10)("""{"item_id":"abc123","amount":1.23,"time":1431504603105}""") | |
"return a single record with the correct total" in new spark(records) { | |
collector.length mustEqual 1 | |
val output = collector.head | |
output.total mustEqual BigDecimal(12.3) | |
} | |
} | |
"with invalid records" should { | |
val records = Seq("this is not json", """{"this":"isn't in the right format"}""") | |
"output no records" in new spark(records) { | |
collector.length mustEqual 0 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment