Skip to content

Instantly share code, notes, and snippets.

@artgon
Created August 10, 2012 00:15
Show Gist options
  • Save artgon/3309408 to your computer and use it in GitHub Desktop.
Save artgon/3309408 to your computer and use it in GitHub Desktop.
Test
"be marked completed as done with concurrent requests" in {
var q1, q2 = new FreeFormQuestion()
inTransaction {
q1 = FreeFormQuestionDao.saveOrUpdate(new FreeFormQuestion("is this the real life?", middle.id))
q2 = FreeFormQuestionDao.saveOrUpdate(new FreeFormQuestion("is this just fantasy?", middle.id))
}
val system = ActorSystem("testSystem")
val sarActor = system.actorOf(Props(new Actor {
protected def receive = {
case sar: (Map[String,String], String) => {
post("/selfAssessmentResponses", headers = sar._1, body = sar._2) {
println(body)
status should equal(200)
}
}
case _ => println("fail")
}
}))
val ffrActor = system.actorOf(Props(new Actor{
protected def receive = {
case ffr: (Map[String,String], String) => {
post("/freeFormResponses", headers =ffr._1, body = ffr._2) {
println(body)
status should equal(200)
}
}
case _ => println("fail")
}
}))
val sarBody = """{"conceptId":%s,"userId":%s,"createdOn":"2012-08-08T16:58:47-0700","lastUpdate":"2012-08-08T16:58:47-0700","rating":2,"ratingWasValidated":true,"ratingError":"","ratingIsInError":""}"""
.format(middle.id, user.id)
val ffrBody1 = """{"questionId":%s,"userId":%s,"createdOn":"2012-08-08T16:58:47-0700","lastUpdate":"2012-08-08T16:58:47-0700","response":"TEst","responseWasValidated":true,"responseError":"","responseIsInError":""}"""
.format(q1.id, user.id)
val ffrBody2 = """{"questionId":%s,"userId":%s,"createdOn":"2012-08-08T16:58:47-0700","lastUpdate":"2012-08-08T16:58:47-0700","response":"TEst","responseWasValidated":true,"responseError":"","responseIsInError":""}"""
.format(q2.id, user.id)
ffrActor ! (setUserCookie(Some(user)), ffrBody1)
sarActor ! (setUserCookie(Some(user)), sarBody)
ffrActor ! (setUserCookie(Some(user)), ffrBody2)
Thread.sleep(2000)
get("/concepts/" + middle.id, headers = setUserCookie(Some(user))) {
println(body)
status should equal(200)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment