<commit_before>package com.themillhousegroup.gatsby

import org.specs2.mock.Mockito
import org.specs2.mutable.Specification
import com.themillhousegroup.gatsby.stubby.RuntimeStubbing
import io.gatling.core.session.{ Expression, Session }
import io.gatling.http.request.builder.{ CommonAttributes, AbstractHttpRequestBuilder }
import com.themillhousegroup.gatsby.test.{ NextActor, ActorScope }
import akka.testkit.TestActorRef
import io.gatling.core.config.{ GatlingConfiguration, Protocols }
import io.gatling.http.config.{ HttpProtocolResponsePart, HttpProtocol }
import io.gatling.core.controller.throttle.ThrottlingProtocol
import io.gatling.core.akka.GatlingActorSystem
import io.gatling.core.validation.Success
import io.gatling.http.request.{ HttpRequestConfig, HttpRequestDef }
import com.dividezero.stubby.core.model.StubExchange
import scala.concurrent.Future

class GatsbyHttpActionBuilderSpec extends Specification with Mockito {

  // Prevent explosions when the *ActionBuilder attempts to read configuration:
  GatlingConfiguration.setUp()
  GatlingActorSystem.start

  "GatsbyHttpActionBuilder" should {
    "Cause a 200 OK stub to be built when a request is wrapped in withStubby" in new ActorScope {

      implicit val mockSimulation = mock[RuntimeStubbing]

      val mockSession = Session("s1", "me")
      mockSimulation.acquireLock(anyString) returns Future.successful(true)

      val requestBuilder = givenRequest("GET", "/foo", "myRequest")

      val builder = GatsbyHttpActionBuilder.withStubby(requestBuilder)

      val next = TestActorRef[NextActor]

      val mockProtocols = mock[Protocols]<commit_msg>Not using TestActorRef where a Mockito mock suffices<commit_after>package com.themillhousegroup.gatsby

import org.specs2.mock.Mockito
import org.specs2.mutable.{ After, Specification }
import com.themillhousegroup.gatsby.stubby.RuntimeStubbing
import io.gatling.core.session.{ Expression, Session }
import io.gatling.http.request.builder.{ CommonAttributes, AbstractHttpRequestBuilder }
import com.themillhousegroup.gatsby.test.ActorScope
import io.gatling.core.config.{ GatlingConfiguration, Protocols }
import io.gatling.http.config.{ HttpProtocolResponsePart, HttpProtocol }
import io.gatling.core.controller.throttle.ThrottlingProtocol
import io.gatling.core.akka.GatlingActorSystem
import io.gatling.core.validation.Success
import io.gatling.http.request.{ HttpRequestConfig, HttpRequestDef }
import scala.concurrent.Future
import akka.actor.ActorRef

class GatsbyHttpActionBuilderSpec extends Specification with Mockito {

  // Prevent explosions when the *ActionBuilder attempts to read configuration:
  GatlingConfiguration.setUp()
  GatlingActorSystem.start

  "GatsbyHttpActionBuilder" should {
    "Cause a 200 OK stub to be built when a request is wrapped in withStubby" in new ActorScope {

      implicit val mockSimulation = mock[RuntimeStubbing]

      val mockSession = Session("s1", "me")
      mockSimulation.acquireLock(anyString) returns Future.successful(true)

      val requestBuilder = givenRequest("GET", "/foo", "myRequest")

      val builder = GatsbyHttpActionBuilder.withStubby(requestBuilder)

      val next = mock[ActorRef]

      val mockProtocols = mock[Protocols]
{'fraction_non_alphanumeric': 0.08134859263841633, 'fraction_numerical': 0.0037117228580266005, 'mean_word_length': 5.403960396039604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4156822', 'n_tokens_mistral': 967, 'n_tokens_neox': 953, 'n_words': 216}