Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100436712
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, Jan 30, 19:43
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Feb 1, 19:43 (2 d)
Engine
blob
Format
Raw Data
Handle
23957733
Attached To
R2664 SHRINE MedCo Fork
MetaDataServiceTest.scala
View Options
package 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._
"metadata.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")
}
}
"metadata.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\"")
}
}
"metadata.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)
}
}
"metadata.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