本文整理汇总了Scala中org.mockito.ArgumentMatchers类的典型用法代码示例。如果您正苦于以下问题:Scala ArgumentMatchers类的具体用法?Scala ArgumentMatchers怎么用?Scala ArgumentMatchers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArgumentMatchers类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: SynchronizerSpec
//设置package包名称以及导入依赖的类
package fr.univ_lille.cristal.emeraude.chasqui.tests
import fr.univ_lille.cristal.emeraude.chasqui.core.SynchronizerStrategy
import org.mockito.ArgumentMatchers
import org.mockito.Mockito.verify
class SynchronizerSpec extends ChasquiBaseSpec {
"A node that processed all messages in time t" should "inform its synchronizer strategy to wait" in {
val nodeA = newNode
val synchronizerStrategy = mock[SynchronizerStrategy]
nodeA.setSynchronizerStrategy(synchronizerStrategy)
//This will process all message in time 1 and inform it finished to its synchronizer strategy
nodeA.advanceSimulationTime()
//We sleep here to wait the actor system to react
//This is not the best way to test, because it may not scale in the future
// but it's a practical and simple one to start with
Thread.sleep(500)
verify(synchronizerStrategy).notifyFinishedTime(
org.mockito.ArgumentMatchers.eq(nodeA.actor),
ArgumentMatchers.any(),
org.mockito.ArgumentMatchers.eq(1L),
org.mockito.ArgumentMatchers.eq(0),
org.mockito.ArgumentMatchers.eq(0))
}
}
开发者ID:guillep,项目名称:chasqui,代码行数:33,代码来源:SynchronizerSpec.scala
示例2: KingdomPlacementValidatorTest
//设置package包名称以及导入依赖的类
package se.apogo.kdom
import org.mockito.ArgumentMatchers
import org.mockito.Mockito._
import org.testng.Assert
import org.testng.annotations.Test
class KingdomPlacementValidatorTest {
@Test
def test_placeNextToCastle_true(): Unit =
{
val kingdom = Kingdom.start(Player(""))
val kingdomSizeValidator = mock(classOf[KingdomSizeValidator])
when(kingdomSizeValidator.hasValidSize(ArgumentMatchers.any())).thenReturn(true)
val domino = Domino(0, Tile(Field), Tile(Water))
Assert.assertTrue(new KingdomPlacementValidator(kingdomSizeValidator).validate(kingdom, PlacedDomino(domino, Position(0,1), Position(0,2))))
}
}
开发者ID:mratin,项目名称:kdom,代码行数:22,代码来源:KingdomPlacementValidatorTest.scala
示例3: AdminServiceSpec
//设置package包名称以及导入依赖的类
package services
import connectors.MongoConnector
import helpers.TestSpec
import models.coordinates.SectorCoordinateModel
import models.universe.{SectorModel, UniverseModel}
import org.mockito.ArgumentMatchers
import org.scalatestplus.play.OneAppPerSuite
import org.mockito.Mockito._
import scala.concurrent.Future
class AdminServiceSpec extends TestSpec with OneAppPerSuite {
def setupService(inputResponse: Future[Unit]): AdminService = {
val mockConnector = mock[MongoConnector]
when(mockConnector.putEntry(ArgumentMatchers.any(), ArgumentMatchers.any())(ArgumentMatchers.any()))
.thenReturn(inputResponse)
new AdminService(mockConnector)
}
"Calling .storeUniverse" when {
val universeModel = UniverseModel(Seq(SectorModel(SectorCoordinateModel(0, 0), Seq()), SectorModel(SectorCoordinateModel(0, 1), Seq())))
"an error is returned from the connector" should {
lazy val service = setupService(Future.failed(new Exception("error message")))
lazy val result = service.storeUniverse("test", universeModel)
"return the correct error message" in {
lazy val exception = intercept[Exception](await(result))
exception.getMessage shouldBe "error message"
}
}
"a success is returned from the connector" should {
lazy val service = setupService(Future.successful({}))
lazy val result = service.storeUniverse("test", universeModel)
"return a Unit" in {
await(result).isInstanceOf[Unit] shouldBe true
}
}
}
}
开发者ID:jameshforster,项目名称:OverVerse,代码行数:49,代码来源:AdminServiceSpec.scala
示例4: KafkaProducerWrapperSpec
//设置package包名称以及导入依赖的类
package articlestreamer.shared.kafka
import articlestreamer.shared.BaseSpec
import articlestreamer.shared.configuration.ConfigLoader
import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord}
import org.mockito.ArgumentMatchers
import org.mockito.ArgumentMatchers._
import org.mockito.Mockito._
import org.scalatest.BeforeAndAfter
class KafkaProducerWrapperSpec extends BaseSpec with BeforeAndAfter {
class TestConfig extends ConfigLoader
var producer: KafkaProducer[String, String] = _
val factory = mock(classOf[KafkaFactory[String, String]])
var producerWrapper: KafkaProducerWrapper = _
before {
producer = mock(classOf[KafkaProducer[String, String]])
when(factory.getProducer(any())).thenReturn(producer)
producerWrapper = new KafkaProducerWrapper(new TestConfig, factory)
}
"Wrapper" should "acquire producer" in {
verify(factory, times(1)).getProducer(any())
}
it should "send record" in {
val record = new ProducerRecord[String, String]("", "")
producerWrapper.send(record)
verify(producer, times(1)).send(ArgumentMatchers.eq(record), any())
}
it should "stop producer" in {
producerWrapper.stopProducer()
verify(producer, times(1)).close()
}
"Config" should "be tested with SSL" in {
class Test2Config extends ConfigLoader {
override val kafkaSSLMode: Boolean = true
}
producerWrapper = new KafkaProducerWrapper(new Test2Config, factory)
}
it should "be tested without SSL" in {
class Test2Config extends ConfigLoader {
override val kafkaSSLMode: Boolean = false
}
producerWrapper = new KafkaProducerWrapper(new Test2Config, factory)
}
}
开发者ID:firens,项目名称:article-streamer,代码行数:58,代码来源:KafkaProducerWrapperSpec.scala
注:本文中的org.mockito.ArgumentMatchers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论