<commit_before>package services

import org.specs2.mutable._
import org.specs2.mock.Mockito
import org.mockito.Mockito._
import models.AssetSupport
import scala.concurrent.{Await, Future}
import play.api.libs.json.{Reads, Json}
import scala.concurrent.duration.FiniteDuration
import java.util.concurrent.TimeUnit
import scala.util.{Failure, Success, Try}


class ServicesTest extends Specification with Mockito {


  "RealRepositoryComponent" should {
    "should be mockeable" in {
      type Test = String
      val mockedMongo = mock[MongoDb]

      val target: CrudRepository = new CrudRepository with Mongo {
        override val mongo = mockedMongo

      }

      val expectedId = "blah"
      val query = Json.obj(AssetSupport.idFieldName -> expectedId)
      val expectedResultList = List(Json.obj("foo" -> "bar"))
      implicit val colName = mock[CollectionName[Test]]
      implicit val reads = mock[Reads[Test]]

      when(mockedMongo.find[Test](query)).thenReturn(Future.successful(expectedResultList))



      val result = target.crudRepository.getById[Test](query)
      val timeout: FiniteDuration = FiniteDuration(5, TimeUnit.SECONDS)
      Await.result(result, timeout) match {
        case Some(value) => success //value must beEqualTo("foo")<commit_msg>test fix<commit_after>package services

import org.specs2.mutable._
import org.specs2.mock.Mockito
import org.mockito.Mockito._
import models.AssetSupport
import scala.concurrent.{Await, Future}
import play.api.libs.json.{Reads, Json}
import scala.concurrent.duration.FiniteDuration
import java.util.concurrent.TimeUnit
import scala.util.{Failure, Success, Try}


class ServicesTest extends Specification with Mockito {


  "RealRepositoryComponent" should {
    "should be mockeable" in {
      type Test = String
      val mockedMongo = mock[MongoDb]

      val target: CrudRepository = new CrudRepository with Mongo {
        override val mongo = mockedMongo

      }

      val expectedId = "blah"
      val query = Json.obj(AssetSupport.idFieldName -> expectedId)
      val expectedResultList = List(Json.obj("foo" -> "bar"))
      implicit val colName = mock[CollectionName[Test]]
      implicit val reads = mock[Reads[Test]]

      when(mockedMongo.find[Test](query)).thenReturn(Future.successful(expectedResultList))



      val result = target.crudRepository.getById[Test](DbQuery(query))
      val timeout: FiniteDuration = FiniteDuration(5, TimeUnit.SECONDS)
      Await.result(result, timeout) match {
        case Some(value) => success //value must beEqualTo("foo")
{'fraction_non_alphanumeric': 0.09937402190923318, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 3.917307692307692, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986669', 'n_tokens_mistral': 765, 'n_tokens_neox': 750, 'n_words': 180}