当前位置: 首页>>代码示例>>Scala>>正文


Scala IntegrationPatience类代码示例

本文整理汇总了Scala中org.scalatest.concurrent.IntegrationPatience的典型用法代码示例。如果您正苦于以下问题:Scala IntegrationPatience类的具体用法?Scala IntegrationPatience怎么用?Scala IntegrationPatience使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IntegrationPatience类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: ApiSpecServer

//设置package包名称以及导入依赖的类
package global

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatestplus.play._
import play.api.GlobalSettings
import play.api.mvc.Results
import play.api.test._

abstract class ApiSpecServer extends PlaySpec with OneServerPerTest with Results with ScalaFutures with IntegrationPatience {

  val currentVersion = 1

  protected def getFakeApp(global: GlobalSettings): FakeApplication = {
    FakeApplication(
      additionalConfiguration = Map(
        "slick.dbs.default.driver" -> "slick.driver.H2Driver$",
        "slick.dbs.default.db.driver" -> "org.h2.Driver",
        "slick.dbs.default.db.url" -> "jdbc:h2:mem:play;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=FALSE",
        "slick.dbs.default.db.user" -> "sa",
        "slick.dbs.default.db.password" -> "",
        "slick.dbs.default.db.connectionPool" -> "disabled",
        "slick.dbs.default.db.keepAliveConnection" -> "true",

        "play.evolutions.enabled" -> "false",
        "play.evolutions.autoApply" -> "false",
        "play.evolutions.autocommit" -> "false"
      ),
      withGlobal = Some(global)
    )
  }
} 
开发者ID:Driox,项目名称:play-app-seed,代码行数:32,代码来源:ApiSpecServer.scala

示例2: WiremockHelper

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.emailverification

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import org.scalatest._
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatestplus.play.OneServerPerSuite


object WiremockHelper {
  val wiremockPort = 11111
  val wiremockHost = "localhost"
  val url = s"http://$wiremockHost:$wiremockPort"
}

trait WiremockHelper {

  import uk.gov.hmrc.emailverification.WiremockHelper._

  val wmConfig = wireMockConfig().port(wiremockPort)
  val wireMockServer = new WireMockServer(wmConfig)

  def startWiremock() = {
    wireMockServer.start()
    WireMock.configureFor(wiremockHost, wiremockPort)
  }

  def stopWiremock() = wireMockServer.stop()

  def resetWiremock() = WireMock.reset()

}

trait IntegrationSpecBase extends FeatureSpec with GivenWhenThen with OneServerPerSuite with ScalaFutures with IntegrationPatience with Matchers with WiremockHelper with BeforeAndAfterEach with BeforeAndAfterAll {
  override def beforeEach() = {
    resetWiremock()
  }

  override def beforeAll() = {
    super.beforeAll()
    startWiremock()
  }

  override def afterAll() = {
    stopWiremock()
    super.afterAll()
  }
} 
开发者ID:hmrc,项目名称:email-verification-frontend,代码行数:50,代码来源:IntegrationSpecBase.scala

示例3: NegociosFunctionalTest

//设置package包名称以及导入依赖的类
package controllers

import org.scalamock.scalatest.MockFactory
import org.scalatest._
import org.scalatest.concurrent.IntegrationPatience
import org.scalatestplus.play._
import play.api.mvc.Results


class NegociosFunctionalTest extends FlatSpec with Matchers with OptionValues
with WsScalaTestClient with BeforeAndAfterEach with BeforeAndAfterAll with Results
with MockFactory with OneServerPerSuite with HtmlUnitFactory with AllBrowsersPerSuite with IntegrationPatience {

  override lazy val browsers = Vector(
    ChromeInfo,
    FirefoxInfo(firefoxProfile),
    InternetExplorerInfo
  )

  override def afterAll(): Unit = {
  }

  val host = s"http://localhost:$port"

  def sharedTests(browser: BrowserInfo) = {

    "Index" should s"mostrar los negocios en el listado y cargar la configuracion ${browser.name}" in {
      go to s"$host/"
      pageTitle shouldBe "Hello MV - Configurador"
      click on find(name("configuracion")).value

      eventually(currentUrl shouldBe s"$host/negocios/avanza_seguro/configuracion")
    }

    it should s"cargar un negocio ${browser.name}" in {
      go to s"$host/"
      pageTitle shouldBe "Hello MV - Configurador"
      click on find(name("negocios")).value

      eventually(currentUrl shouldBe s"$host/negocios/avanza_seguro")
    }

  }

  override def convertToLegacyEqualizer[T](left: T): LegacyEqualizer[T] = ???

  override def convertToLegacyCheckingEqualizer[T](left: T): LegacyCheckingEqualizer[T] = ???
} 
开发者ID:luissalda1995,项目名称:generador-vistas,代码行数:49,代码来源:NegociosFunctionalTest.scala

示例4: SearchServiceIntegrationTest

//设置package包名称以及导入依赖的类
package services

import model.{Airport, Country, Runway, SearchResult}
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{FunSpec, Matchers}
import resolver.MySqlResolver
import utils.TestInjector

class SearchServiceIntegrationTest extends FunSpec with Matchers with TestInjector with ScalaFutures with IntegrationPatience {

  describe("Search Service") {
    val searchResolver = getInjector.instanceOf[MySqlResolver]
    val service = new SearchService(searchResolver)

    it("should get search results if searched by country name") {
      val expectedSearchResult= SearchResult(Country("Australia", "AU"), Airport("Allambie Airport", "small_airport"),Runway("X", 0))
      val searchResults = service.searchCountriesByNameOrCountryCode("australia").futureValue

      searchResults.length should be(799)
      searchResults.count(_.country.name == "Australia") should be(799)
      searchResults.head should be(expectedSearchResult)
    }

    it("should get search results if searched by country code") {
      val expectedSearchResult= SearchResult(Country("Australia", "AU"), Airport("Allambie Airport", "small_airport"),Runway("X", 0))
      val searchResults = service.searchCountriesByNameOrCountryCode("au").futureValue

      searchResults.length should be(799)
      searchResults.count(_.country.name == "Australia") should be(799)
      searchResults.head should be(expectedSearchResult)
    }

    it("should get search results if searched for fuzzy term") {
      val expectedSearchResult= SearchResult(Country("Australia", "AU"), Airport("Allambie Airport", "small_airport"),Runway("X", 0))
      val searchResults = service.searchCountriesByNameOrCountryCode("aus").futureValue

      searchResults.length should be(799)
      searchResults.count(_.country.name == "Australia") should be(799)
      searchResults.head should be(expectedSearchResult)
    }

  }

} 
开发者ID:atiqsayyed,项目名称:airport,代码行数:45,代码来源:SearchServiceIntegrationTest.scala

示例5: ReportServiceIntegrationTest

//设置package包名称以及导入依赖的类
package services

import model.{Country, CountryReport, RunwayReport, SurfaceReport}
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{FunSpec, Matchers}
import resolver.MySqlResolver
import utils.TestInjector

class ReportServiceIntegrationTest extends FunSpec with Matchers with TestInjector with ScalaFutures with IntegrationPatience {
  describe("Report Service") {
    val sqlResolver = getInjector.instanceOf[MySqlResolver]
    val service = new ReportService(sqlResolver)

    it("should generate report for top 10 Countries with highest no of airports") {
      val results = service.findCountriesWithHighestNoOfAirports.futureValue

      results.size should be(10)
      results.head should be(CountryReport(Country("United States", "US"), 14167))
    }

    it("should generate report for top 10 Countries with lowest no of airports") {
      val results = service.findCountriesWithLowestNoOfAirports.futureValue

      results.size should be(10)
      results.head should be(CountryReport(Country("Chad", "TD"), 1))
    }

    it("should generate report for surface per countries") {
      val results = service.findSurfacePerCountry().futureValue

      results.size should be(390)
      results.head should be(SurfaceReport(Country("Afghanistan", "AF"), "GVL"))
    }

    it("should generate report for top 10 runway idents") {
      val results = service.findCommonRunwayIdents().futureValue

      results.size should be(10)
      results.head should be(RunwayReport("H1", 5482))
    }
  }
} 
开发者ID:atiqsayyed,项目名称:airport,代码行数:43,代码来源:ReportServiceIntegrationTest.scala

示例6: SectionEmptyValuesMatchingSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model._
import uk.gov.hmrc.decisionservice.model.rules.{SectionCarryOver, SectionRule, SectionRuleSet}
import uk.gov.hmrc.decisionservice.ruleengine.SectionFactMatcher
import uk.gov.hmrc.play.test.UnitSpec

class SectionEmptyValuesMatchingSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  "section fact with empty values matcher" should {
    "produce fact error when fact is missing answers for which there is no match and corresponding rule values are not all empty in any of the rules" in {
      val fact = Map(
        ("question1" -> "yes"),
        ("question2" -> ""),
        ("question3" -> ""))
      val rules = List(
        SectionRule(List("yes","yes","yes"), SectionCarryOver("high"  , true)),
        SectionRule(List("yes","no" ,"no" ), SectionCarryOver("medium", true)),
        SectionRule(List("no" ,"yes",""   ), SectionCarryOver("low"   , false))
      )
      val ruleSet = SectionRuleSet(List("question1", "question2", "question3"), rules)

      val response = SectionFactMatcher.matchFacts(fact, ruleSet)
      response.isLeft shouldBe true
      response.leftMap { error =>
        error shouldBe a [FactError]
      }
    }
    "produce rules error when fact is missing answers for which there is no match but corresponding rule values are empty in at least one rule" in {
      val fact = Map(
        ("question1" -> "yes"),
        ("question2" -> ""),
        ("question3" -> ""))
      val rules = List(
        SectionRule(List("yes","yes","yes"), SectionCarryOver("high"  , true)),
        SectionRule(List("yes","no" ,""   ), SectionCarryOver("medium", true)),
        SectionRule(List("no" ,""   ,""   ), SectionCarryOver("low"   , false))
      )
      val ruleSet = SectionRuleSet(List("question1", "question2", "question3"), rules)

      val response = SectionFactMatcher.matchFacts(fact, ruleSet)
      response.isLeft shouldBe true
      response.leftMap { error =>
        error shouldBe a [RulesFileError]
      }
    }
  }

} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:52,代码来源:SectionEmptyValuesMatchingSpec.scala

示例7: EmptyValuesValidatorSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model.rules.{SectionCarryOver, SectionRule}
import uk.gov.hmrc.decisionservice.model._
import uk.gov.hmrc.decisionservice.ruleengine.EmptyValuesValidator
import uk.gov.hmrc.play.test.UnitSpec

class EmptyValuesValidatorSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  object SectionEmptyValuesValidator extends EmptyValuesValidator {
    type ValueType = String
    type Rule = SectionRule
    type RuleResult = SectionCarryOver

    def valueEmpty(s: String) = s.isEmpty
  }

  "empty values validator" should {
    "produce fact error if FactsEmptySet is a subset of MaximumRulesEmptySet" in {
      val fact = Map(
        ("question1" -> "yes"),
        ("question2" -> ""),
        ("question3" -> ""))
      val rules = List(
        SectionRule(List("yes","yes","yes"), SectionCarryOver("high"  , true)),
        SectionRule(List("yes","no" ,"no" ), SectionCarryOver("medium", true)),
        SectionRule(List("no" ,"yes",""   ), SectionCarryOver("low"   , false))
      )

      val error = SectionEmptyValuesValidator.noMatchError(fact,rules)
      error shouldBe a [FactError]
    }
    "produce rules error if FactsEmptySet is a superset of MaximumRulesEmptySet" in {
      val fact = Map(
        ("question1" -> "yes"),
        ("question2" -> ""),
        ("question3" -> ""))
      val rules = List(
        SectionRule(List("yes","yes","yes"), SectionCarryOver("high"  , true)),
        SectionRule(List("yes","no" ,""   ), SectionCarryOver("medium", true)),
        SectionRule(List("no" ,""   ,""   ), SectionCarryOver("low"   , false))
      )

      val error = SectionEmptyValuesValidator.noMatchError(fact,rules)
      error shouldBe a [RulesFileError]
    }
  }

} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:52,代码来源:EmptyValuesValidatorSpec.scala

示例8: MatrixRulesLoaderSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model.RulesFileLoadError
import uk.gov.hmrc.decisionservice.model.rules.SectionCarryOver
import uk.gov.hmrc.decisionservice.ruleengine.{MatrixFactMatcher, MatrixRulesLoader, RulesFileMetaData}
import uk.gov.hmrc.play.test.UnitSpec

class MatrixRulesLoaderSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  val csvFilePath = "/matrix.csv"
  val csvFilePathError = "/matrix_error.csv"
  val csvMetadata = RulesFileMetaData(2, 1, csvFilePath)
  val csvMetadataError = RulesFileMetaData(2, 1, csvFilePathError)

  "matrix rules loader" should {
    "load matrix rules from a csv file" in {
      val maybeRules = MatrixRulesLoader.load(csvMetadata)
      maybeRules.isRight shouldBe true
      maybeRules.map { ruleset =>
        ruleset.rules should have size 3
        ruleset.headings should have size 2
      }
    }
    "return error if file is not found" in {
      val maybeRules = MatrixRulesLoader.load(RulesFileMetaData(2, 1, csvFilePath + "xx"))
      maybeRules.isLeft shouldBe true
      maybeRules.leftMap { error =>
        error shouldBe a [RulesFileLoadError]
      }
    }
    "return error if file contains invalid data" in {
      val maybeRules = MatrixRulesLoader.load(csvMetadataError)
      maybeRules.isLeft shouldBe true
      maybeRules.leftMap { error =>
        error shouldBe a [RulesFileLoadError]
      }
    }
    "provide valid input for an inference against fact" in {
      val matrixFacts = Map(
        ("BusinessStructure" -> SectionCarryOver("high", true)), ("Substitute" -> SectionCarryOver("high" , false))
      )
      val maybeRules = MatrixRulesLoader.load(csvMetadata)
      maybeRules.isRight shouldBe true
      maybeRules.map { ruleset =>
        ruleset.rules should have size 3
        ruleset.headings should have size 2
        val response = MatrixFactMatcher.matchFacts(matrixFacts, ruleset)
        response.isRight shouldBe true
        response.map { decision =>
          decision.value should equal("out of IR35")
        }
      }
    }
  }
} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:58,代码来源:MatrixRulesLoaderSpec.scala

示例9: MatrixEmptyValuesMatchingSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model._
import uk.gov.hmrc.decisionservice.model.rules.{MatrixDecision, MatrixRule, MatrixRuleSet, SectionCarryOver}
import uk.gov.hmrc.decisionservice.ruleengine.MatrixFactMatcher
import uk.gov.hmrc.play.test.UnitSpec

class MatrixEmptyValuesMatchingSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  "matrix fact with empty values matcher" should {
    "produce fact error when fact is missing answers for which rule values are not empty" in {
      val matrixFacts = Map(
        ("BusinessStructure" -> SectionCarryOver("high", true)),
        ("Substitute" -> SectionCarryOver("" , false)),
        ("FinancialRisk" -> SectionCarryOver("" , false))
      )
      val matrixRules = List(
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("high" , true ),SectionCarryOver("low" , true )), MatrixDecision("self employed")),
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("low" , false),SectionCarryOver("low" , true )), MatrixDecision("in IR35")),
        MatrixRule(List(SectionCarryOver("medium", true ),SectionCarryOver("high", true ),SectionCarryOver("low" , true )), MatrixDecision("out of IR35"))
      )
      val matrixRuleSet = MatrixRuleSet(List("BusinessStructure", "Substitute", "FinancialRisk"), matrixRules)

      val response = MatrixFactMatcher.matchFacts(matrixFacts, matrixRuleSet)
      println(response)
      response.isLeft shouldBe true
      response.leftMap { error =>
        error shouldBe a [FactError]
      }
    }
    "produce rules error when fact is missing answers for which there is no match but corresponding rule values are empty in at least one rule" in {
      val matrixFacts = Map(
        ("BusinessStructure" -> SectionCarryOver("high", true)),
        ("Substitute" -> SectionCarryOver("" , false)),
        ("FinancialRisk" -> SectionCarryOver("" , false))
      )
      val matrixRules = List(
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("high" , true ),SectionCarryOver("low" , true )), MatrixDecision("self employed")),
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("low" , false),SectionCarryOver("low" , true )), MatrixDecision("in IR35")),
        MatrixRule(List(SectionCarryOver("medium", true ),SectionCarryOver("", true ),SectionCarryOver("" , true )), MatrixDecision("out of IR35"))
      )
      val matrixRuleSet = MatrixRuleSet(List("BusinessStructure", "Substitute", "FinancialRisk"), matrixRules)

      val response = MatrixFactMatcher.matchFacts(matrixFacts, matrixRuleSet)
      println(response)
      response.isLeft shouldBe true
      response.leftMap { error =>
        error shouldBe a [RulesFileError]
      }
    }
  }

} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:56,代码来源:MatrixEmptyValuesMatchingSpec.scala

示例10: DecisionRequestSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import play.api.libs.json.{JsValue, Json}
import uk.gov.hmrc.decisionservice.model.api.{Section, QuestionSet}
import uk.gov.hmrc.play.test.UnitSpec

class DecisionRequestSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  val json =
    """
      |{
      |  "version" : "1.0",
      |  "sections" : [ {
      |    "name" : "personal-service",
      |    "facts" : {
      |      "1" : true,
      |      "2" : false,
      |      "3" : true
      |    }
      |  } ]
      |}
      |
    """.stripMargin

  "decision request json" should {
    "be correctly converted to Scala object" in {
      val parsed = Json.parse(json)
      val jsResult = Json.fromJson[QuestionSet](parsed)
      jsResult.isSuccess shouldBe true
      val obj = jsResult.get
      obj.sections should have size 1
      obj.sections(0).facts should have size 3

      val m:Map[String,Boolean] = obj.sections(0).facts
      val res = (1 to 3).flatMap(i => m.get(i.toString))
      res should contain theSameElementsInOrderAs (List(true, false, true))
    }
  }

  "decision request Scala object" should {
    "be correctly converted to json object" in {
      val personalServiceQuestions = Map("1" -> true, "2" -> false, "3" -> true)
      val helperQuestions = Map("1" -> false, "2" -> false, "3" -> false)
      val controlQuestions = Map("1" -> true, "2" -> true, "3" -> true)
      val sections = List(
        Section("personal-service", personalServiceQuestions),
        Section("helper", helperQuestions),
        Section("control", controlQuestions)
      )
      val decisionRequest = QuestionSet("1.0", sections)
      val jsValue:JsValue = Json.toJson(decisionRequest)
      val jsections = jsValue \\ "sections"
      val jfacts = jsValue \\ "facts"
      jsections should have size 1
      jfacts should have size 3
    }
  }

} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:62,代码来源:DecisionRequestSpec.scala

示例11: MatrixFactMatcherSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model._
import uk.gov.hmrc.decisionservice.model.rules.{MatrixDecision, MatrixRule, MatrixRuleSet, SectionCarryOver}
import uk.gov.hmrc.decisionservice.ruleengine.MatrixFactMatcher
import uk.gov.hmrc.play.test.UnitSpec

class MatrixFactMatcherSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  "matrix fact matcher" should {
    "produce correct result for a sample matrix fact" in {
      val matrixFacts = Map(
        ("BusinessStructure" -> SectionCarryOver("high", true)), ("Substitute" -> SectionCarryOver("high" , false))
      )
      val matrixRules = List(
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("low" , true )), MatrixDecision("in IR35")),
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("high", false)), MatrixDecision("out of IR35")),
        MatrixRule(List(SectionCarryOver("medium", true ),SectionCarryOver("high", true )), MatrixDecision("in IR35"))
      )
      val matrixRuleSet = MatrixRuleSet(List("BusinessStructure", "Substitute"), matrixRules)

      val response = MatrixFactMatcher.matchFacts(matrixFacts, matrixRuleSet)

      response.isRight shouldBe true
      response.map { decision =>
        decision.value should equal("out of IR35")
      }
    }
    "produce correct result for a partial fact" in {
      val matrixFacts = Map(
        ("BusinessStructure" -> SectionCarryOver("high", true)),
        ("Substitute" -> SectionCarryOver("low" , false)),
        ("FinancialRisk" -> SectionCarryOver("" , false))
      )
      val matrixRules = List(
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("high" , true ),SectionCarryOver("" , true )), MatrixDecision("self employed")),
        MatrixRule(List(SectionCarryOver("high"  , true ),SectionCarryOver("low" , false),SectionCarryOver("" , true )), MatrixDecision("in IR35")),
        MatrixRule(List(SectionCarryOver("medium", true ),SectionCarryOver("high", true ),SectionCarryOver("low" , true )), MatrixDecision("out of IR35"))
      )
      val matrixRuleSet = MatrixRuleSet(List("BusinessStructure", "Substitute", "FinancialRisk"), matrixRules)

      val response = MatrixFactMatcher.matchFacts(matrixFacts, matrixRuleSet)

      response.isRight shouldBe true
      response.map { decision =>
        decision.value should equal("in IR35")
      }
    }
  }

} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:54,代码来源:MatrixFactMatcherSpec.scala

示例12: SectionRulesLoaderSpec

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.decisionservice

import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{BeforeAndAfterEach, Inspectors, LoneElement}
import uk.gov.hmrc.decisionservice.model.RulesFileLoadError
import uk.gov.hmrc.decisionservice.ruleengine.{RulesFileMetaData, SectionFactMatcher, SectionRulesLoader}
import uk.gov.hmrc.play.test.UnitSpec

class SectionRulesLoaderSpec extends UnitSpec with BeforeAndAfterEach with ScalaFutures with LoneElement with Inspectors with IntegrationPatience {

  val csvFilePath = "/business_structure.csv"
  val csvFilePathError = "/business_structure_error.csv"
  val csvMetadata = RulesFileMetaData(3, 2, csvFilePath)
  val csvMetadataError = RulesFileMetaData(3, 2, csvFilePathError)

  "section rules loader" should {
    "load section rules from a csv file" in {
      val maybeRules = SectionRulesLoader.load(csvMetadata)
      maybeRules.isRight shouldBe true
      maybeRules.map { ruleset =>
        ruleset.rules should have size 4
        ruleset.headings should have size 3
      }
    }
    "return error if file is not found" in {
      val maybeRules = SectionRulesLoader.load(RulesFileMetaData(3, 2, csvFilePath + "xx"))
      maybeRules.isLeft shouldBe true
      maybeRules.leftMap { error =>
        error shouldBe a [RulesFileLoadError]
      }
    }
    "return error if file contains invalid data" in {
      val maybeRules = SectionRulesLoader.load(csvMetadataError)
      maybeRules.isLeft shouldBe true
      maybeRules.leftMap { error =>
        error shouldBe a [RulesFileLoadError]
      }
    }
    "provide valid input for an inference against fact" in {
      val fact = Map(
        ("Q1" -> "yes"),
        ("Q2" -> "no"),
        ("Q3" -> "yes"))
      val maybeRules = SectionRulesLoader.load(csvMetadata)
      maybeRules.isRight shouldBe true
      maybeRules.map { ruleset =>
        ruleset.rules should have size 4
        ruleset.headings should have size 3
        val response = SectionFactMatcher.matchFacts(fact, ruleset)
        response.isRight shouldBe true
        response.map { sectionResult =>
          sectionResult.value should equal("low")
          sectionResult.exit should equal(true)
        }
      }
    }
  }
} 
开发者ID:Baisysoft,项目名称:off-payroll-decision-service,代码行数:59,代码来源:SectionRulesLoaderSpec.scala

示例13: ExampleApplication

//设置package包名称以及导入依赖的类
package com.example

import java.net.URI

import com.pygmalios.reactiveinflux.ReactiveInfluxDbName
import com.pygmalios.reactiveinflux.command.query.BaseQueryCommand
import com.pygmalios.reactiveinflux.itest.ITestConfig
import com.pygmalios.reactiveinflux.response.EmptyJsonResponse
import com.pygmalios.reactiveinflux.{ReactiveInflux, ReactiveInfluxCore}
import org.scalatest.FunSuite
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import play.api.libs.ws.{WSClient, WSResponse}

class ExampleApplication extends FunSuite with ScalaFutures with IntegrationPatience {
  test("Execute custom command") {
    val reactiveInflux = ReactiveInflux(config = Some(ITestConfig.config))
    try {
      implicit val dbName = ReactiveInfluxDbName("ExampleApplicatixon")
      val db = reactiveInflux.database
      try {
        val core = reactiveInflux.asInstanceOf[ReactiveInfluxCore]
        whenReady(core.execute(new CustomQueryCommand(core.config.url)).failed) { ex =>
        }
      }
      finally {
        db.drop()
      }
    }
    finally {
      reactiveInflux.close()
    }
  }
}

class CustomQueryCommand(baseUri: URI) extends BaseQueryCommand(baseUri) {
  override type TResult = Unit
  override protected def responseFactory(wsResponse: WSResponse) =  new CustomQueryCommandResponse(wsResponse)
  override def httpRequest(ws: WSClient) = ws.url(qUri("WHATEVER").toString)
}

class CustomQueryCommandResponse(wsResponse: WSResponse) extends EmptyJsonResponse(wsResponse) 
开发者ID:pygmalios,项目名称:reactiveinflux,代码行数:42,代码来源:ExampleApplication.scala

示例14: LayerClientIntegrationSpec

//设置package包名称以及导入依赖的类
package com.jatescher.layer

import akka.actor.ActorSystem
import akka.http.scaladsl.model.{ HttpMethods, HttpRequest, HttpResponse, StatusCodes }
import akka.stream.ActorMaterializer
import com.typesafe.config.{ Config, ConfigFactory }
import org.scalatest.concurrent.{ IntegrationPatience, PatienceConfiguration, ScalaFutures }
import org.scalatest.{ Matchers, WordSpec }
import scala.concurrent.Future

class LayerClientIntegrationSpec extends WordSpec with Matchers with PatienceConfiguration with IntegrationPatience with ScalaFutures {
  val testConfig = ConfigFactory.load("test-application.conf")
  val router = new LayerRouter(testConfig)
  implicit val system = ActorSystem("LayerClientIntegrationSpecSystem")
  implicit val materializer = ActorMaterializer()
  implicit val ec = system.dispatcher

  class IntegrationLayerClient(router: LayerRouter, config: Config) extends LayerClient(router, config) {
    def testRequest(httpRequest: HttpRequest): Future[HttpResponse] = executeRequest(httpRequest)
  }

  "#executeRequest" should {
    "complete the request" in {
      val request = HttpRequest(HttpMethods.GET, uri = "https://layer.com")
      val client = new IntegrationLayerClient(router, testConfig)
      client.testRequest(request).futureValue.status shouldBe StatusCodes.OK
    }
  }

} 
开发者ID:jtescher,项目名称:layer-scala,代码行数:31,代码来源:LayerClientIntegrationSpec.scala

示例15: SimulationManagerSpec

//设置package包名称以及导入依赖的类
package com.coding42.gol

import com.coding42.gol.SimulationManager.SimulationConfig
import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures}
import org.scalatest.{FlatSpec, Matchers}

import scala.concurrent.{Await, Promise}
import scala.concurrent.duration._

class SimulationManagerSpec extends FlatSpec with Matchers with ScalaFutures with IntegrationPatience {

  it should "start and stop a simulation without failing" in {
    val generator = SimulationManager.generator( () => 100, _ => (), _ => ())
    val simulation = generator(SimulationConfig(None, 50, 10))
    simulation.start() shouldBe true
    Await.result(simulation.stop(), 1.second)
  }

  it should "when a simulation is started the steps should get updated" in {
    val promise = Promise[List[Int]]()
    var steps: List[Int] = Nil

    val stepUpdater: (Int) => Unit = step => {
      steps = step :: steps

      if(steps.length == 3) {
          promise.success(steps)
      }
    }

    val generator = SimulationManager.generator(() => 100, stepUpdater, _ => ())
    val simulation = generator(SimulationConfig(None, 50, 10))
    simulation.start() shouldBe true

    promise.future.futureValue shouldBe List(3,2,1)
    Await.result(simulation.stop(), 1.second)
  }

  it should "start always the same simulation with a seed" in {
    val generator = SimulationManager.generator( () => 100, _ => (), _ => ())
    val simulation = generator(SimulationConfig(Some(1234), 5, 5))
    simulation.life.board shouldBe Vector(
      Vector(true, false, true, false, true),
      Vector(false, false, true, false, false),
      Vector(false, false, false, false, true),
      Vector(false, true, false, false, false),
      Vector(false, false, false, true, false)
    )
  }

  it should "not be able to start a simulation twice" in {
    val generator = SimulationManager.generator( () => 100, _ => (), _ => ())
    val simulation = generator(SimulationConfig(None, 50, 10))
    simulation.start() shouldBe true
    simulation.start() shouldBe false
    Await.result(simulation.stop(), 1.second)
  }
} 
开发者ID:adrijardi,项目名称:life,代码行数:59,代码来源:SimulationManagerSpec.scala


注:本文中的org.scalatest.concurrent.IntegrationPatience类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。