本文整理汇总了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))
}
}
示例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))))
}
}
示例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
}
}
}
}
示例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)
}
}