Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82555483
MetaDataServiceTest.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Sep 12, 02:25
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Sep 14, 02:25 (2 d)
Engine
blob
Format
Raw Data
Handle
20713096
Attached To
R2664 SHRINE MedCo Fork
MetaDataServiceTest.scala
View Options
package net.shrine.metadata
import akka.actor.ActorRefFactory
import org.json4s.DefaultFormats
import org.json4s.native.JsonMethods.parse
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import spray.testkit.ScalatestRouteTest
@RunWith(classOf[JUnitRunner])
class MetaDataServiceTest extends FlatSpec with ScalatestRouteTest with MetaDataService {
override def actorRefFactory: ActorRefFactory = system
import scala.concurrent.duration._
implicit val routeTestTimeout = RouteTestTimeout(10.seconds)
import spray.http.StatusCodes._
"MetaDataService" should "return an OK and pong for a ping" in {
Get(s"/ping") ~> route ~> check {
implicit val formats = DefaultFormats
val result = new String(body.data.toByteArray)
assertResult(OK)(status)
assertResult(result)("pong")
}
}
"MetaDataService" should "return an OK and pong for a data" in {
Get(s"/data?key=ping") ~> route ~> check {
implicit val formats = DefaultFormats
val result = new String(body.data.toByteArray)
assertResult(OK)(status)
assertResult(result)("\"pong\"")
}
}
"MetaDataService" should "return an OK for all data" in {
Get(s"/data") ~> route ~> check {
implicit val formats = DefaultFormats
val result = parse(new String(body.data.toByteArray))
assertResult(OK)(status)
}
}
"MetaDataService" should "return an Ok and a list for a data" in {
Get("/data?key=list") ~> route ~> check {
implicit val formats = DefaultFormats
val result = new String(body.data.toByteArray)
assertResult(OK)(status)
assertResult(parse(result).extract[List[String]])(Seq("list", "list", "list"))
}
}
}
Event Timeline
Log In to Comment