本文整理汇总了Scala中org.specs2.matcher.Matchers类的典型用法代码示例。如果您正苦于以下问题:Scala Matchers类的具体用法?Scala Matchers怎么用?Scala Matchers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matchers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: containBillingAddress
//设置package包名称以及导入依赖的类
package com.wix.pay.stripe.drivers
import java.util
import com.wix.pay.creditcard.{AddressDetailed, PublicCreditCardOptionalFields}
import com.wix.pay.model.{Customer, IncludedCharges, OrderItem, ShippingAddress}
import com.wix.pay.stripe._
import org.specs2.matcher.{Matcher, Matchers}
trait StripeMatchers { self : Matchers =>
def containBillingAddress(billingAddress: AddressDetailed): Matcher[MappedParams] = {
be_===(billingAddress) ^^ {
StripeAdditionalInfoReConstructor.reconstructBillingAddress(_: MappedParams)
}
}
def containCustomer(customer: Customer): Matcher[MappedParams] = {
be_===(customer) ^^ {
StripeAdditionalInfoReConstructor.reconstructCustomer(_: MappedParams)
}
}
def containInvoiceId(invoiceId: String): Matcher[MappedParams] = {
be_===(invoiceId) ^^ {
StripeAdditionalInfoReConstructor.reconstructInvoiceId(_: MappedParams)
}
}
def containShippingAddress(shippingAddress: ShippingAddress): Matcher[MappedParams] = {
be_===(shippingAddress) ^^ {
StripeAdditionalInfoReConstructor.reconstructShippingAddress(_: MappedParams)
}
}
def containOrderItems(orderItems: Seq[OrderItem]): Matcher[MappedParams] = {
be_===(orderItems) ^^ {
StripeAdditionalInfoReConstructor.reconstructOrderItems(_: MappedParams)
}
}
def containIncludedCharges(includedCharges: IncludedCharges): Matcher[MappedParams] = {
be_===(includedCharges) ^^ {
StripeAdditionalInfoReConstructor.reconstructIncludedCharges(_: MappedParams)
}
}
def haveFieldParams(fields: PublicCreditCardOptionalFields): Matcher[util.LinkedHashMap[String, Object]] = {
be_===(fields.billingAddress.get) ^^ {(_:util.LinkedHashMap[String, Object]).get("address_line1").toString} and
be_===(fields.billingPostalCode.get) ^^ {(_:util.LinkedHashMap[String, Object]).get("address_zip").toString} and
be_===(fields.holderName.get) ^^ {(_:util.LinkedHashMap[String, Object]).get("name").toString}
}
def haveAnyEmptyFields(): Matcher[util.LinkedHashMap[String, Object]] = {
beTrue ^^ {(_:util.LinkedHashMap[String, Object]).containsKey("address_line1")} or
beTrue ^^ {(_:util.LinkedHashMap[String, Object]).containsKey("address_zip")}
}
}
示例2: StripeAdditionalInfoMapperTest
//设置package包名称以及导入依赖的类
package com.wix.pay.stripe
import com.wix.pay.stripe.drivers.{StripeAdditionalInfoDomain, StripeMatchers}
import org.specs2.matcher.Matchers
import org.specs2.mutable.SpecWithJUnit
import org.specs2.specification.Scope
class StripeAdditionalInfoMapperTest extends SpecWithJUnit with Matchers with StripeMatchers {
trait Ctx extends Scope with StripeAdditionalInfoDomain {
val mapper = new StripeAdditionalInfoMapper()
}
"Stripe additional info mapper" should {
"map additional Info into a map" in new Ctx {
val map: MappedParams = mapper.createMap(someCreditCard, someCustomer, someDeal)
map must {
containBillingAddress(billingAddress.get) and
containCustomer(someCustomer.get) and
containInvoiceId(someInvoiceId.get) and
containShippingAddress(someShippingAddress.get) and
containOrderItems(orderItems) and
containIncludedCharges(includedCharges.get)
}
}
}
}
示例3: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.tranzila
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait TranzilaMatchers extends Matchers {
def authorizationParser: TranzilaAuthorizationParser
def beMerchant(username: Matcher[String] = AlwaysMatcher()): Matcher[TranzilaMerchant] = {
username ^^ { (_: TranzilaMerchant).username aka "username" }
}
def beAuthorization(index: Matcher[String] = AlwaysMatcher(),
confirmationCode: Matcher[String] = AlwaysMatcher()): Matcher[TranzilaAuthorization] = {
index ^^ { (_: TranzilaAuthorization).index aka "currency" } and
confirmationCode ^^ { (_: TranzilaAuthorization).confirmationCode aka "confirmation code" }
}
def beAuthorizationKey(authorization: Matcher[TranzilaAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object TranzilaMatchers extends TranzilaMatchers {
override val authorizationParser = new JsonTranzilaAuthorizationParser()
}
示例4: YahooFinanceSpec
//设置package包名称以及导入依赖的类
package openquant.yahoofinance
import java.time.ZonedDateTime
import akka.actor.ActorSystem
import akka.testkit.TestKit
import org.specs2.matcher.{FutureMatchers, Matchers}
import org.specs2.mutable._
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class YahooFinanceSpec extends TestKit(ActorSystem()) with SpecificationLike with Matchers with Logging {
"get quotes" in {
val yahooFinance = new YahooFinance()
val res = Await.result(yahooFinance.quotes("MSFT", Some(ZonedDateTime.now().minusDays(5))), Duration.Inf)
res.length must be_>=(3)
res.length must be_<=(5)
}
"get full history" in {
val yahooFinance = new YahooFinance()
val res = Await.result(yahooFinance.quotes("MSFT"), Duration.Inf)
res.length must be_>=(1000)
}
"non-existent symbol" in {
val yahooFinance = new YahooFinance()
Await.result(yahooFinance.quotes("qwertyasdf"), Duration.Inf) must throwA[RuntimeException]
}
"invalid fundamentals" in {
val yahooFinance = new YahooFinance()
val invalids = Await.result(yahooFinance.fundamentals(Vector("qwertyasdf")), Duration.Inf)
invalids must have size (1)
invalids.head.looksValid must beFalse
}
"valid fundamentals" in {
val yahooFinance = new YahooFinance()
val syms = Vector("MSFT", "IBM")
val valids = Await.result(yahooFinance.fundamentals(syms), Duration.Inf)
valids must have size(2)
valids.foreach { x ?
x.looksValid must beTrue
x.name must not beEmpty
}
valids.map { _.symbol } must contain(exactly(syms:_*))
ok
}
}
示例5: FlightPassengerSplitCalculatorSpec
//设置package包名称以及导入依赖的类
package core
import core.PassengerSplitsCalculator.PaxSplits
import org.specs2.matcher.Matchers
import org.specs2.mutable.Specification
import org.specs2.specification.Tables
import parsing.PassengerInfoParser.PassengerInfo
class FlightPassengerSplitCalculatorSpec extends Specification with Matchers {
import PassengerSplitsCalculator._
"FlightPassengerSplitCalculator should" >> {
"given an API passenger info set " in {
"where everyone is from GB and the DocumentType is Passport (P)" in {
val passengerInfo = PassengerInfo(passport, "GB", None) :: Nil
"then egate usage should be 100%" in {
flightPaxSplits(passengerInfo) should beEqualTo(PaxSplits(egate = 1.0))
}
}
"where half are from GB and half are from NZ " in {
val passengerInfo = PassengerInfo(passport, "GB", None) :: PassengerInfo(passport, "NZ") :: Nil
"then egate usage should be 50% and nonEEA = 50%" in {
flightPaxSplits(passengerInfo) should beEqualTo(PaxSplits(egate = 1, nonEea = 1))
}
}
"where half are from GB and half are from AU " in {
val passengerInfo = PassengerInfo(passport, "GB", None) :: PassengerInfo(passport, "AU") :: Nil
"then egate usage should be 50% and nonEEA = 50%" in {
flightPaxSplits(passengerInfo) should beEqualTo(PaxSplits(egate = 1, nonEea = 1))
}
}
"where half are from GB and half are from DE and everyone has electronic passports" in {
val passengerInfo = PassengerInfo(passport, "GB") :: PassengerInfo(passport, "DE") :: Nil
"then egate usage should be 100%" in {
flightPaxSplits(passengerInfo) should beEqualTo(PaxSplits(egate = 2))
}
}
"where half are from GB and half are from DE and the DE have Identity Cards" in {
val passengerInfo = PassengerInfo(passport, "GB") :: PassengerInfo(identityCard, "DE") :: Nil
"then egate usage should be 50% and 50% EEA queues" in {
flightPaxSplits(passengerInfo) should beEqualTo(PaxSplits(egate = 1, eea = 1))
}
}
}
}
}
示例6: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.dengionline
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait DengionlineMatchers extends Matchers {
def authorizationParser: DengionlineAuthorizationParser
def beAuthorization(transactionId: Matcher[String] = AlwaysMatcher()): Matcher[DengionlineAuthorization] = {
transactionId ^^ { (_: DengionlineAuthorization).transactionId aka "transactionId" }
}
def beAuthorizationKey(authorization: Matcher[DengionlineAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object DengionlineMatchers extends DengionlineMatchers {
override val authorizationParser = new JsonDengionlineAuthorizationParser()
}
示例7: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.paguelofacil
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait PaguelofacilMatchers extends Matchers {
def authorizationParser: PaguelofacilAuthorizationParser
def beAuthorization(authRefNum: Matcher[String] = AlwaysMatcher()): Matcher[PaguelofacilAuthorization] = {
authRefNum ^^ { (_: PaguelofacilAuthorization).authRefNum aka "authRefNum" }
}
def beAuthorizationKey(authorization: Matcher[PaguelofacilAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object PaguelofacilMatchers extends PaguelofacilMatchers {
override val authorizationParser = new JsonPaguelofacilAuthorizationParser()
}
示例8: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.mercadopago
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait MercadopagoMatchers extends Matchers {
def authorizationParser: MercadopagoAuthorizationParser
def beMerchant(clientId: Matcher[String] = AlwaysMatcher(),
clientSecret: Matcher[String] = AlwaysMatcher(),
countryCode: Matcher[String] = AlwaysMatcher()): Matcher[MercadopagoMerchant] = {
clientId ^^ { (_: MercadopagoMerchant).clientId aka "client ID" } and
clientSecret ^^ { (_: MercadopagoMerchant).clientSecret aka "client Secret" } and
countryCode ^^ { (_: MercadopagoMerchant).countryCode aka "country code" }
}
def beAuthorization(): Matcher[MercadopagoAuthorization] = {
AlwaysMatcher()
}
def beAuthorizationKey(authorization: Matcher[MercadopagoAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object MercadopagoMatchers extends MercadopagoMatchers {
override val authorizationParser = new JsonMercadopagoAuthorizationParser()
}
示例9: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.paybox
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait PayboxMatchers extends Matchers {
def authorizationParser: PayboxAuthorizationParser
def beAuthorization(numTrans: Matcher[String] = AlwaysMatcher(),
numAppel: Matcher[String] = AlwaysMatcher(),
numQuestion: Matcher[String] = AlwaysMatcher(),
devise: Matcher[String] = AlwaysMatcher(),
reference: Matcher[String] = AlwaysMatcher(),
dateQ: Matcher[String] = AlwaysMatcher()): Matcher[PayboxAuthorization] = {
numTrans ^^ { (_: PayboxAuthorization).numTrans aka "numTrans" } and
numAppel ^^ { (_: PayboxAuthorization).numAppel aka "numAppel" } and
numQuestion ^^ { (_: PayboxAuthorization).numQuestion aka "numQuestion" } and
devise ^^ { (_: PayboxAuthorization).devise aka "devise" } and
reference ^^ { (_: PayboxAuthorization).reference aka "reference" } and
dateQ ^^ { (_: PayboxAuthorization).dateQ aka "dateQ" }
}
def beAuthorizationKey(authorization: Matcher[PayboxAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object PayboxMatchers extends PayboxMatchers {
override val authorizationParser = new JsonPayboxAuthorizationParser()
}
示例10: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.mercurypay
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait MercurypayMatchers extends Matchers {
def authorizationParser: MercurypayAuthorizationParser
def beAuthorization(invoiceNo: Matcher[String] = AlwaysMatcher(),
acctNo: Matcher[String] = AlwaysMatcher(),
expDate: Matcher[String] = AlwaysMatcher(),
authCode: Matcher[String] = AlwaysMatcher(),
acqRefData: Matcher[String] = AlwaysMatcher(),
authorize: Matcher[String] = AlwaysMatcher(),
tranCode: Matcher[String] = AlwaysMatcher()): Matcher[MercurypayAuthorization] = {
invoiceNo ^^ { (_: MercurypayAuthorization).invoiceNo aka "invoiceNo" } and
acctNo ^^ { (_: MercurypayAuthorization).acctNo aka "acctNo" } and
expDate ^^ { (_: MercurypayAuthorization).expDate aka "expDate" } and
authCode ^^ { (_: MercurypayAuthorization).authCode aka "authCode" } and
acqRefData ^^ { (_: MercurypayAuthorization).acqRefData aka "acqRefData" } and
authorize ^^ { (_: MercurypayAuthorization).authorize aka "authorize" }
}
def beAuthorizationKey(authorization: Matcher[MercurypayAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object MercurypayMatchers extends MercurypayMatchers {
override val authorizationParser = new JsonMercurypayAuthorizationParser()
}
示例11: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.fatzebra
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait FatzebraMatchers extends Matchers {
def authorizationParser: FatzebraAuthorizationParser
def beAuthorization(purchaseId: Matcher[String] = AlwaysMatcher()): Matcher[FatzebraAuthorization] = {
purchaseId ^^ { (_: FatzebraAuthorization).purchaseId aka "purchaseId" }
}
def beAuthorizationKey(authorization: Matcher[FatzebraAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
def beMerchant(username: Matcher[String] = AlwaysMatcher(),
password: Matcher[String] = AlwaysMatcher()): Matcher[FatzebraMerchant] = {
username ^^ { (_: FatzebraMerchant).username aka "username" } and
password ^^ { (_: FatzebraMerchant).password aka "password" }
}
}
object FatzebraMatchers extends FatzebraMatchers {
override val authorizationParser = new JsonFatzebraAuthorizationParser()
}
示例12: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.creditguard
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait CreditguardMatchers extends Matchers {
def authorizationParser: CreditguardAuthorizationParser
def beMerchant(user: Matcher[String] = AlwaysMatcher(),
password: Matcher[String] = AlwaysMatcher(),
terminalNumber: Matcher[String] = AlwaysMatcher(),
supplierNumber: Matcher[String] = AlwaysMatcher(),
idPrefix: Matcher[String] = AlwaysMatcher()): Matcher[CreditguardMerchant] = {
user ^^ { (_: CreditguardMerchant).user aka "user" } and
password ^^ { (_: CreditguardMerchant).password aka "password" } and
terminalNumber ^^ { (_: CreditguardMerchant).terminalNumber aka "terminal number" } and
supplierNumber ^^ { (_: CreditguardMerchant).supplierNumber aka "supplier number" } and
idPrefix ^^ { (_: CreditguardMerchant).idPrefix aka "ID prefix" }
}
def beAuthorization(authNumber: Matcher[String] = AlwaysMatcher(),
currency: Matcher[String] = AlwaysMatcher(),
tranId: Matcher[String] = AlwaysMatcher(),
cardId: Matcher[String] = AlwaysMatcher(),
cardExpiration: Matcher[String] = AlwaysMatcher(),
user: Matcher[String] = AlwaysMatcher()): Matcher[CreditguardAuthorization] = {
authNumber ^^ { (_: CreditguardAuthorization).authNumber aka "authorization number" } and
currency ^^ { (_: CreditguardAuthorization).currency aka "currency" } and
tranId ^^ { (_: CreditguardAuthorization).tranId aka "transaction ID" } and
cardId ^^ { (_: CreditguardAuthorization).cardId aka "card ID" } and
cardExpiration ^^ { (_: CreditguardAuthorization).cardExpiration aka "card expiration" } and
user ^^ { (_: CreditguardAuthorization).user aka "user" }
}
def beAuthorizationKey(authorization: Matcher[CreditguardAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object CreditguardMatchers extends CreditguardMatchers {
override val authorizationParser = new JsonCreditguardAuthorizationParser()
}
示例13: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.paymentexpress
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait PaymentexpressMatchers extends Matchers {
def authorizationParser: PaymentexpressAuthorizationParser
def beAuthorization(currency: Matcher[String] = AlwaysMatcher(),
dpsTxnRef: Matcher[String] = AlwaysMatcher()): Matcher[PaymentexpressAuthorization] = {
currency ^^ { (_: PaymentexpressAuthorization).currency aka "currency" } and
dpsTxnRef ^^ { (_: PaymentexpressAuthorization).dpsTxnRef aka "dpsTxnRef" }
}
def beAuthorizationKey(authorization: Matcher[PaymentexpressAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
def beMerchant(username: Matcher[String] = AlwaysMatcher(),
password: Matcher[String] = AlwaysMatcher()): Matcher[PaymentexpressMerchant] = {
username ^^ { (_: PaymentexpressMerchant).username aka "username" } and
password ^^ { (_: PaymentexpressMerchant).password aka "password" }
}
}
object PaymentexpressMatchers extends PaymentexpressMatchers {
override val authorizationParser = new JsonPaymentexpressAuthorizationParser()
}
示例14: ApplicationSpec
//设置package包名称以及导入依赖的类
package com.hanip.ssr.controllers
import java.time.Clock
import com.google.inject.{AbstractModule, Provides}
import com.hanip.ssr.dao.CartDAO.CartTable
import com.hanip.ssr.dao.CouponDAO.CouponTable
import com.hanip.ssr.dao.ItemCartDAO.ItemCartTable
import com.hanip.ssr.dao.ItemDAO.ItemTable
import com.hanip.ssr.dao.{AbstractBaseDAO, BaseDAO}
import com.hanip.ssr.models._
import org.specs2.execute.Results
import org.specs2.matcher.Matchers
import org.specs2.mock.Mockito
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.test._
class ApplicationSpec extends PlaySpecification with Results with Matchers with Mockito{
sequential
val application = new GuiceApplicationBuilder().overrides(new AbstractModule {
override def configure() = {
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
}
@Provides
def provideItemDAO: AbstractBaseDAO[ItemTable, Item] = mock[BaseDAO[ItemTable, Item]]
@Provides
def provideCartDAO: AbstractBaseDAO[CartTable, Cart] = mock[BaseDAO[CartTable, Cart]]
@Provides
def provideItemCartDAO: AbstractBaseDAO[ItemCartTable, ItemCart] = mock[BaseDAO[ItemCartTable, ItemCart]]
@Provides
def provideCouponDAO: AbstractBaseDAO[CouponTable, Coupon] = mock[BaseDAO[CouponTable, Coupon]]
}).build
"Routes" should {
"send 404 on a bad request" in {
route(application, FakeRequest(GET, "/stolen")).map(status(_)) shouldEqual Some(NOT_FOUND)
}
}
}
示例15: authorizationParser
//设置package包名称以及导入依赖的类
package com.wix.pay.pelecard
import org.specs2.matcher.{AlwaysMatcher, Matcher, Matchers}
trait PelecardMatchers extends Matchers {
def authorizationParser: PelecardAuthorizationParser
def beMerchant(terminalNumber: Matcher[String] = AlwaysMatcher(),
user: Matcher[String] = AlwaysMatcher(),
password: Matcher[String] = AlwaysMatcher(),
shopNumber: Matcher[String] = AlwaysMatcher()): Matcher[PelecardMerchant] = {
terminalNumber ^^ { (_: PelecardMerchant).terminalNumber aka "terminal number" } and
user ^^ { (_: PelecardMerchant).user aka "user" } and
password ^^ { (_: PelecardMerchant).password aka "password" } and
shopNumber ^^ { (_: PelecardMerchant).shopNumber aka "shopNumber" }
}
def beAuthorization(transactionId: Matcher[String] = AlwaysMatcher(),
token: Matcher[String] = AlwaysMatcher(),
authorizationNumber: Matcher[String] = AlwaysMatcher(),
currency: Matcher[String] = AlwaysMatcher()): Matcher[PelecardAuthorization] = {
transactionId ^^ { (_: PelecardAuthorization).transactionId aka "transaction ID" } and
token ^^ { (_: PelecardAuthorization).token aka "token" } and
authorizationNumber ^^ { (_: PelecardAuthorization).authorizationNumber aka "authorization number" } and
currency ^^ { (_: PelecardAuthorization).currency aka "currency" }
}
def beAuthorizationKey(authorization: Matcher[PelecardAuthorization]): Matcher[String] = {
authorization ^^ { authorizationParser.parse(_: String) aka "parsed authorization"}
}
}
object PelecardMatchers extends PelecardMatchers {
override val authorizationParser = new JsonPelecardAuthorizationParser()
}