<commit_before>package com.themillhousegroup.gatsby.actors

import org.specs2.mutable.Specification
import org.specs2.mock.Mockito
import io.gatling.core.session.{ Session, Expression }
import com.themillhousegroup.gatsby.stubby.RuntimeStubbing
import com.dividezero.stubby.core.model.StubExchange
import akka.actor.ActorRef
import scala.concurrent.{ Await, Promise, Future }
import io.gatling.core.validation.Success
import com.typesafe.scalalogging.slf4j.StrictLogging
import akka.testkit.TestActorRef
import scala.concurrent.duration.Duration
import com.themillhousegroup.gatsby.test.{ ActorScope, NextActor }

class SpinUpSpec extends Specification with Mockito {

  val waitTime = Duration(5, "seconds")

  class TestSpinUp(val simulation: RuntimeStubbing,
    val requestNameExp: Expression[String],
    val ses: Seq[Expression[StubExchange]],
    val next: ActorRef) extends CanSpinUp with StrictLogging

  def spinUpWith(sim: RuntimeStubbing,
    next: ActorRef,
    requestName: String = "request",
    se: StubExchange = mock[StubExchange]) = {

    val mockReq = mock[Expression[String]]
    mockReq(any[Session]) returns Success(requestName)

    val mockSE = mock[Expression[StubExchange]]

    mockSE(any[Session]) returns Success(se)

    new TestSpinUp(sim, mockReq, Seq(mockSE), next)
  }

  "SpinUp Actor" should {

    "Execute immediately if there is no contention for the simulation lock" in new ActorScope {
      val sim = mock[RuntimeStubbing]
      sim.acquireLock(anyString) answers (_ => Future.successful(true))
      val su = spinUpWith(sim, TestActorRef[NextActor])

      val session = mock[Session]
      session.scenarioName returns "scenarioName"
      su.execute(session)

      there was one(sim).addExchange(anyString, any[StubExchange])

    }

    "Call the next actor in the chain" in new ActorScope {

      val sim = mock[RuntimeStubbing]
      sim.acquireLock(anyString) returns Future.successful(true)

      val next = TestActorRef[NextActor]
      val su = spinUpWith(sim, next)

      val session = mock[Session]
      session.scenarioName returns "scenarioName"
      su.execute(session)

      val result = Await.result(next.underlyingActor.notified, waitTime)

      system.shutdown

      result must beEqualTo(session)
    }
<commit_msg>Use a return when an answer is not required<commit_after>package com.themillhousegroup.gatsby.actors

import org.specs2.mutable.Specification
import org.specs2.mock.Mockito
import io.gatling.core.session.{ Session, Expression }
import com.themillhousegroup.gatsby.stubby.RuntimeStubbing
import com.dividezero.stubby.core.model.StubExchange
import akka.actor.ActorRef
import scala.concurrent.{ Await, Promise, Future }
import io.gatling.core.validation.Success
import com.typesafe.scalalogging.slf4j.StrictLogging
import akka.testkit.TestActorRef
import scala.concurrent.duration.Duration
import com.themillhousegroup.gatsby.test.{ ActorScope, NextActor }

class SpinUpSpec extends Specification with Mockito {

  val waitTime = Duration(5, "seconds")

  class TestSpinUp(val simulation: RuntimeStubbing,
    val requestNameExp: Expression[String],
    val ses: Seq[Expression[StubExchange]],
    val next: ActorRef) extends CanSpinUp with StrictLogging

  def spinUpWith(sim: RuntimeStubbing,
    next: ActorRef,
    requestName: String = "request",
    se: StubExchange = mock[StubExchange]) = {

    val mockReq = mock[Expression[String]]
    mockReq(any[Session]) returns Success(requestName)

    val mockSE = mock[Expression[StubExchange]]

    mockSE(any[Session]) returns Success(se)

    new TestSpinUp(sim, mockReq, Seq(mockSE), next)
  }

  "SpinUp Actor" should {

    "Execute immediately if there is no contention for the simulation lock" in new ActorScope {
      val sim = mock[RuntimeStubbing]
      sim.acquireLock(anyString) returns Future.successful(true)
      val su = spinUpWith(sim, TestActorRef[NextActor])

      val session = mock[Session]
      session.scenarioName returns "scenarioName"
      su.execute(session)

      there was one(sim).addExchange(anyString, any[StubExchange])

    }

    "Call the next actor in the chain" in new ActorScope {

      val sim = mock[RuntimeStubbing]
      sim.acquireLock(anyString) returns Future.successful(true)

      val next = TestActorRef[NextActor]
      val su = spinUpWith(sim, next)

      val session = mock[Session]
      session.scenarioName returns "scenarioName"
      su.execute(session)

      val result = Await.result(next.underlyingActor.notified, waitTime)

      system.shutdown

      result must beEqualTo(session)
    }

{'fraction_non_alphanumeric': 0.08911106281243208, 'fraction_numerical': 0.001738752445120626, 'mean_word_length': 4.188275084554679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4627615', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1386, 'n_words': 336}