<commit_before>package com.thoughtworks.restRpc.play

import com.github.dreamhead.moco._
import com.qifun.jsonStream.rpc.IFuture1
import org.mockito.Mockito
import org.specs2.Specification
import org.specs2.mock.{Mockito => SpecMockito}

import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import scala.language.implicitConversions
import java.util.concurrent.TimeUnit.SECONDS

object Implicits {
  implicit def jsonStreamFutureToScalaFuture[Value](jsonStreamFuture: IFuture1[Value]):Future[Value] = ???
}

import com.thoughtworks.restRpc.play.Implicits._

class RpcOutgoingTest extends Specification with SpecMockito {def is = s2"""

      This is a specification of using rest-rpc-play tools to make http requests

      Should be able to send a get request without parameters     $e1
                                                                  """

  def e1 = {
    val monitor = Mockito.mock(classOf[MocoMonitor])

    val server: HttpServer = Moco.httpServer(9000, monitor)
    server.get(Moco.by(Moco.uri("/my-method/1/name/abc"))).response(
      """
        {
          "myInnerEntity": {
            "code":1,
            "message":"this is a message"<commit_msg>finish the implicitly convertion from IFuture1 to Future<commit_after>package com.thoughtworks.restRpc.play

import java.util.concurrent.TimeUnit.SECONDS

import com.github.dreamhead.moco._
import com.qifun.jsonStream.rpc.{ICompleteHandler1, IFuture1}
import org.mockito.Mockito
import org.specs2.Specification
import org.specs2.mock.{Mockito => SpecMockito}

import scala.concurrent.duration._
import scala.concurrent.{Await, Future, Promise}
import scala.language.implicitConversions

object Implicits {
  implicit def jsonStreamFutureToScalaFuture[Value](jsonStreamFuture: IFuture1[Value]):Future[Value] = {
    val p = Promise[Value]()

    jsonStreamFuture.start(new ICompleteHandler1[Value] {
      override def onSuccess(value: Value): Unit = p success value
      override def onFailure(ex: scala.Any): Unit = p failure ex.asInstanceOf[Throwable]
    })

    p.future
  }
}

import com.thoughtworks.restRpc.play.Implicits._

class RpcOutgoingTest extends Specification with SpecMockito {def is = s2"""

      This is a specification of using rest-rpc-play tools to make http requests

      Should be able to send a get request without parameters     $e1
                                                                  """

  def e1 = {
    val monitor = Mockito.mock(classOf[MocoMonitor])

    val server: HttpServer = Moco.httpServer(9000, monitor)
    server.get(Moco.by(Moco.uri("/my-method/1/name/abc"))).response(
      """
        {
          "myInnerEntity": {
            "code":1,
            "message":"this is a message"
{'fraction_non_alphanumeric': 0.0984323733138899, 'fraction_numerical': 0.010572366022602989, 'mean_word_length': 3.138763197586727, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1792741', 'n_tokens_mistral': 830, 'n_tokens_neox': 807, 'n_words': 188}