Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. class BMProxy() extends BaseProxy()
  2. {
  3. override def send(data:JsValue):JsValue =
  4. {
  5. val id = "--123---"
  6. val workspaceid = "---xyz---"
  7. val username = "---username---"
  8. val password = "---password---"
  9. val bluemixURL = s"https://gateway.watsonplatform.net/conversation/api/v1/workspaces/$id/message?version=2016-07-11"
  10. Logger.info(s"data: $data")
  11.  
  12. val req = WS.url(bluemixURL).
  13. withAuth(username, password, WSAuthScheme.BASIC).
  14. withHeaders("Content-Type" -> "application/json").
  15. post(data.toString).
  16. map {
  17. response => {
  18. val rawbody = response.body
  19. val responsecode = response.status
  20. val responsetext = response.statusText
  21. Json.parse(rawbody)
  22. }
  23. }
  24. Await.result(req, 5 seconds)
  25. }
  26. }
  27.  
  28. class Proxies extends Specification {
  29. "Chatscript proxy" should {
  30. "gives response" in {
  31. val data = Json.parse("""{"input":{"text":"Hey"},"context":{"conversation_id":"234234234" } }""")
  32. val response = new BMProxy().send(data)
  33. println("---", response)
  34. Json.stringify(response) must contain ("response")
  35. }
  36. }
  37. }
  38.  
  39. [error] Could not create an instance of Proxies
  40. [error] caused by java.lang.Exception: Could not instantiate class Proxies: null
  41. [error]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement