Как использовать метод заемщика с AsyncFeatureSpec? - PullRequest
0 голосов
/ 11 июня 2019

Как я могу использовать метод фиксирования ссуды с AsyncFeatureSpec?Я пробовал следующим образом:

import akka.actor._
import akka.testkit._
import com.sweetsoft._
import org.scalatest._

import scala.concurrent.duration._

class SapOnlineKafkaOnlineSpec extends fixture.AsyncFeatureSpec with Matchers
  with GivenWhenThen
  with BeforeAndAfter
  with BeforeAndAfterAll {
  private val listener1 = TestProbe()
  private val detector = system.actorOf(DetectorSupervisor.props)

  def withKafkaAndSap(testCode: (ActorRef) => Any) {



  }


  feature("Detect Kafka and SAP availability") {
    info("As a technical user, I want to be notified in real time, if Kafka and SAP is up and running or not.")
    scenario("SAP and Kafka are available") in withKafkaAndSap { (listener) =>
      Given("I am waiting for the current state message")
      detector ! AddNewListener(listener1.ref)
      When("I am receive the state message")
      val res1 = listener1.expectMsgPF[Assertion](6.second) _
      Then("it should contain `SAP and Kafka are online`")
      res1 {
        case status: ServerStatus =>
          status.health should be(ServersOnline)
      }
    }
  }
}

Я не знаю, как ввести метод кредитования.

1 Ответ

3 голосов
/ 11 июня 2019

Попробуйте следующее

class SapOnlineKafkaOnlineSpec extends AsyncFeatureSpec with Matchers
  with GivenWhenThen
  with BeforeAndAfter
  with BeforeAndAfterAll {

  def withKafkaAndSap(testCode: ActorRef => Future[Assertion]) = {
    val actor = ...
    testCode(actor)
  }

  feature("Detect Kafka and SAP availability") {
    info("As a technical user, I want to be notified in real time, if Kafka and SAP is up and running or not.")
    scenario("SAP and Kafka are available") {
      withKafkaAndSap { listner =>
        Given("I am waiting for the current state message")
        When("I am receive the state message")
        Then("it should contain `SAP and Kafka are online`")
        succeed
      }
    }
  }
}

Обратите внимание, что тип параметра фиксатора кредита должен быть

testCode: ActorRef => Future[Assertion]

вместо ActorRef => Any, и мы расширяем просто AsyncFeatureSpec вместо fixture.AsyncFeatureSpec

...