Migrate Kotlin Mockito tests to Mockk
Closes gh-22345
This commit is contained in:
@@ -159,11 +159,7 @@ configure(allprojects) { project ->
|
||||
testCompile("org.mockito:mockito-core:2.23.4") {
|
||||
exclude group: "org.hamcrest", module: "hamcrest-core"
|
||||
}
|
||||
testCompile("com.nhaarman:mockito-kotlin:1.6.0") {
|
||||
exclude module: "kotlin-stdlib"
|
||||
exclude module: "kotlin-reflect"
|
||||
exclude module: "mockito-core"
|
||||
}
|
||||
testCompile("io.mockk:mockk:1.9")
|
||||
testCompile("org.hamcrest:hamcrest-all:1.3")
|
||||
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
|
||||
testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package org.springframework.beans.factory
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.springframework.core.ResolvableType
|
||||
|
||||
/**
|
||||
@@ -30,23 +26,21 @@ import org.springframework.core.ResolvableType
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class BeanFactoryExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var bf: BeanFactory
|
||||
val bf = mockk<BeanFactory>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `getBean with reified type parameters`() {
|
||||
bf.getBean<Foo>()
|
||||
verify(bf, times(1)).getBean(Foo::class.java)
|
||||
verify { bf.getBean(Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBean with String and reified type parameters`() {
|
||||
val name = "foo"
|
||||
bf.getBean<Foo>(name)
|
||||
verify(bf, times(1)).getBean(name, Foo::class.java)
|
||||
verify { bf.getBean(name, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,13 +48,13 @@ class BeanFactoryExtensionsTests {
|
||||
val arg1 = "arg1"
|
||||
val arg2 = "arg2"
|
||||
bf.getBean<Foo>(arg1, arg2)
|
||||
verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2)
|
||||
verify { bf.getBean(Foo::class.java, arg1, arg2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanProvider with reified type parameters`() {
|
||||
bf.getBeanProvider<Foo>()
|
||||
verify(bf, times(1)).getBeanProvider<ObjectProvider<Foo>>(ArgumentMatchers.any<ResolvableType>())
|
||||
verify { bf.getBeanProvider<ObjectProvider<Foo>>(ofType<ResolvableType>()) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,77 +16,72 @@
|
||||
|
||||
package org.springframework.beans.factory
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
/**
|
||||
* Mock object based tests for ListableBeanFactory Kotlin extensions
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ListableBeanFactoryExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var lbf: ListableBeanFactory
|
||||
val lbf = mockk<ListableBeanFactory>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters`() {
|
||||
lbf.getBeanNamesForType<Foo>()
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true)
|
||||
verify { lbf.getBeanNamesForType(Foo::class.java, true , true) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true)
|
||||
verify { lbf.getBeanNamesForType(Foo::class.java, false , true) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeanNamesForType<Foo>(false, false)
|
||||
verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false)
|
||||
verify { lbf.getBeanNamesForType(Foo::class.java, false , false) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters`() {
|
||||
lbf.getBeansOfType<Foo>()
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true)
|
||||
verify { lbf.getBeansOfType(Foo::class.java, true , true) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true)
|
||||
verify { lbf.getBeansOfType(Foo::class.java, false , true) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansOfType with reified type parameters, Boolean and Boolean`() {
|
||||
lbf.getBeansOfType<Foo>(false, false)
|
||||
verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false)
|
||||
verify { lbf.getBeansOfType(Foo::class.java, false , false) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeanNamesForAnnotation with reified type parameters`() {
|
||||
lbf.getBeanNamesForAnnotation<Bar>()
|
||||
verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java)
|
||||
verify { lbf.getBeanNamesForAnnotation(Bar::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getBeansWithAnnotation with reified type parameters`() {
|
||||
lbf.getBeansWithAnnotation<Bar>()
|
||||
verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java)
|
||||
verify { lbf.getBeansWithAnnotation(Bar::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `findAnnotationOnBean with String and reified type parameters`() {
|
||||
val name = "bar"
|
||||
lbf.findAnnotationOnBean<Bar>(name)
|
||||
verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java)
|
||||
verify { lbf.findAnnotationOnBean(name, Bar::class.java) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,46 +16,35 @@
|
||||
|
||||
package org.springframework.core.env
|
||||
|
||||
import com.nhaarman.mockito_kotlin.any
|
||||
import com.nhaarman.mockito_kotlin.whenever
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.ArgumentMatchers.eq
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
/**
|
||||
* Mock object based tests for PropertyResolver Kotlin extensions.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
class PropertyResolverExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var propertyResolver: PropertyResolver
|
||||
val propertyResolver = mockk<PropertyResolver>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `get operator`() {
|
||||
val name = propertyResolver["name"] ?: "foo"
|
||||
Mockito.verify(propertyResolver, Mockito.times(1)).getProperty("name")
|
||||
propertyResolver["name"]
|
||||
verify { propertyResolver.getProperty("name") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getProperty extension`() {
|
||||
whenever(propertyResolver.getProperty(any(), eq(String::class.java))).thenReturn("foo")
|
||||
val name = propertyResolver.getProperty<String>("name") ?: "foo"
|
||||
Mockito.verify(propertyResolver, Mockito.times(1)).getProperty("name", String::class.java)
|
||||
propertyResolver.getProperty<String>("name")
|
||||
verify { propertyResolver.getProperty("name", String::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getRequiredProperty extension`() {
|
||||
whenever(propertyResolver.getRequiredProperty(any(), eq(String::class.java))).thenReturn("foo")
|
||||
val name = propertyResolver.getRequiredProperty<String>("name")
|
||||
Mockito.verify(propertyResolver, Mockito.times(1)).getRequiredProperty("name", String::class.java)
|
||||
propertyResolver.getRequiredProperty<String>("name")
|
||||
verify { propertyResolver.getRequiredProperty("name", String::class.java) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors
|
||||
* Copyright 2002-2019 the original author or authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package org.springframework.jdbc.core
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import java.sql.*
|
||||
|
||||
/**
|
||||
@@ -31,24 +28,22 @@ import java.sql.*
|
||||
* @author Mario Arias
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class JdbcOperationsExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var template: JdbcTemplate
|
||||
val template = mockk<JdbcTemplate>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `queryForObject with reified type parameters`() {
|
||||
val sql = "select age from customer where id = 3"
|
||||
template.queryForObject<Int>(sql)
|
||||
verify(template, times(1)).queryForObject(sql, Integer::class.java)
|
||||
verify { template.queryForObject(sql, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with RowMapper-like function`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
template.queryForObject(sql, 3) { rs: ResultSet, _: Int -> rs.getInt(1) }
|
||||
verify(template, times(1)).queryForObject(eq(sql), any<RowMapper<Int>>(), eq(3))
|
||||
verify { template.queryForObject(eq(sql), any<RowMapper<Int>>(), eq(3)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +52,7 @@ class JdbcOperationsExtensionsTests {
|
||||
val args = arrayOf(3)
|
||||
val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber)
|
||||
template.queryForObject<Int>(sql, args, argTypes)
|
||||
verify(template, times(1)).queryForObject(sql, args, argTypes, Integer::class.java)
|
||||
verify { template.queryForObject(sql, args, argTypes, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,14 +60,14 @@ class JdbcOperationsExtensionsTests {
|
||||
val sql = "select age from customer where id = ?"
|
||||
val args = arrayOf(3)
|
||||
template.queryForObject<Int>(sql, args)
|
||||
verify(template, times(1)).queryForObject(sql, args, Integer::class.java)
|
||||
verify { template.queryForObject(sql, args, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForList with reified type parameters`() {
|
||||
val sql = "select age from customer where id = 3"
|
||||
template.queryForList<Int>(sql)
|
||||
verify(template, times(1)).queryForList(sql, Integer::class.java)
|
||||
verify { template.queryForList(sql, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +76,7 @@ class JdbcOperationsExtensionsTests {
|
||||
val args = arrayOf(3)
|
||||
val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber)
|
||||
template.queryForList<Int>(sql, args, argTypes)
|
||||
verify(template, times(1)).queryForList(sql, args, argTypes, Integer::class.java)
|
||||
verify { template.queryForList(sql, args, argTypes, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +84,7 @@ class JdbcOperationsExtensionsTests {
|
||||
val sql = "select age from customer where id = ?"
|
||||
val args = arrayOf(3)
|
||||
template.queryForList<Int>(sql, args)
|
||||
verify(template, times(1)).queryForList(sql, args, Integer::class.java)
|
||||
verify { template.queryForList(sql, args, Integer::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,16 +94,17 @@ class JdbcOperationsExtensionsTests {
|
||||
rs.next()
|
||||
rs.getInt(1)
|
||||
}
|
||||
verify(template, times(1)).query(eq(sql), any<ResultSetExtractor<Int>>(), eq(3))
|
||||
verify { template.query(eq(sql), any<ResultSetExtractor<Int>>(), eq(3)) }
|
||||
}
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
@Test
|
||||
fun `query with RowCallbackHandler-like function`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
template.query(sql, 3) { rs ->
|
||||
assertEquals(22, rs.getInt(1))
|
||||
}
|
||||
verify(template, times(1)).query(eq(sql), any<RowCallbackHandler>(), eq(3))
|
||||
verify { template.query(sql, ofType<RowCallbackHandler>(), 3) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,7 +113,7 @@ class JdbcOperationsExtensionsTests {
|
||||
template.query(sql, 3) { rs, _ ->
|
||||
rs.getInt(1)
|
||||
}
|
||||
verify(template, times(1)).query(eq(sql), any<RowMapper<Int>>(), eq(3))
|
||||
verify { template.query(sql, ofType<RowMapper<*>>(), 3) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package org.springframework.messaging.simp.annotation.support
|
||||
|
||||
import io.mockk.mockk
|
||||
import java.util.Collections
|
||||
import java.util.HashMap
|
||||
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
import org.springframework.context.support.StaticApplicationContext
|
||||
import org.springframework.messaging.Message
|
||||
@@ -49,19 +48,16 @@ import org.springframework.messaging.handler.annotation.MessageExceptionHandler
|
||||
class SimpAnnotationMethodMessageHandlerKotlinTests {
|
||||
|
||||
|
||||
lateinit var messageHandler: TestSimpAnnotationMethodMessageHandler
|
||||
lateinit var messageHandler: TestSimpAnnotationMethodMessageHandler
|
||||
|
||||
lateinit var testController: TestController
|
||||
lateinit var testController: TestController
|
||||
|
||||
@Mock
|
||||
lateinit var channel: SubscribableChannel
|
||||
val channel = mockk<SubscribableChannel>(relaxed = true)
|
||||
|
||||
@Mock
|
||||
lateinit var converter: MessageConverter
|
||||
val converter = mockk<MessageConverter>(relaxed = true)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
val brokerTemplate = SimpMessagingTemplate(channel)
|
||||
brokerTemplate.messageConverter = converter
|
||||
messageHandler = TestSimpAnnotationMethodMessageHandler(brokerTemplate, channel, channel)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,17 +16,11 @@
|
||||
|
||||
package org.springframework.test.web.reactive.server
|
||||
|
||||
import com.nhaarman.mockito_kotlin.mock
|
||||
import com.nhaarman.mockito_kotlin.times
|
||||
import com.nhaarman.mockito_kotlin.verify
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.web.reactive.function.server.ServerResponse.*
|
||||
import org.springframework.web.reactive.function.server.router
|
||||
|
||||
/**
|
||||
@@ -34,27 +28,24 @@ import org.springframework.web.reactive.function.server.router
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class WebTestClientExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var requestBodySpec: WebTestClient.RequestBodySpec
|
||||
val requestBodySpec = mockk<WebTestClient.RequestBodySpec>(relaxed = true)
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var responseSpec: WebTestClient.ResponseSpec
|
||||
val responseSpec = mockk<WebTestClient.ResponseSpec>(relaxed = true)
|
||||
|
||||
|
||||
@Test
|
||||
fun `RequestBodySpec#body with Publisher and reified type parameters`() {
|
||||
val body = mock<Publisher<Foo>>()
|
||||
val body = mockk<Publisher<Foo>>()
|
||||
requestBodySpec.body(body)
|
||||
verify(requestBodySpec, times(1)).body(body, Foo::class.java)
|
||||
verify { requestBodySpec.body(body, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#expectBody with reified type parameters`() {
|
||||
responseSpec.expectBody<Foo>()
|
||||
verify(responseSpec, times(1)).expectBody(Foo::class.java)
|
||||
verify { responseSpec.expectBody(Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,13 +75,13 @@ class WebTestClientExtensionsTests {
|
||||
@Test
|
||||
fun `ResponseSpec#expectBodyList with reified type parameters`() {
|
||||
responseSpec.expectBodyList<Foo>()
|
||||
verify(responseSpec, times(1)).expectBodyList(Foo::class.java)
|
||||
verify { responseSpec.expectBodyList(Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#returnResult with reified type parameters`() {
|
||||
responseSpec.returnResult<Foo>()
|
||||
verify(responseSpec, times(1)).returnResult(Foo::class.java)
|
||||
verify { responseSpec.returnResult(Foo::class.java) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,33 +16,26 @@
|
||||
|
||||
package org.springframework.test.web.servlet.result
|
||||
|
||||
import com.nhaarman.mockito_kotlin.mock
|
||||
import com.nhaarman.mockito_kotlin.times
|
||||
import com.nhaarman.mockito_kotlin.verify
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.hamcrest.Matcher
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class StatusResultMatchersExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var matchers: StatusResultMatchers
|
||||
val matchers = mockk<StatusResultMatchers>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `StatusResultMatchers#is with Matcher parameter is called as expected when using isEqualTo extension`() {
|
||||
val matcher = mock<Matcher<Int>>()
|
||||
val matcher = mockk<Matcher<Int>>()
|
||||
matchers.isEqualTo(matcher)
|
||||
verify(matchers, times(1)).`is`(matcher)
|
||||
verify { matchers.`is`(matcher) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `StatusResultMatchers#is with int parameter is called as expected when using isEqualTo extension`() {
|
||||
matchers.isEqualTo(200)
|
||||
verify(matchers, times(1)).`is`(200)
|
||||
verify { matchers.`is`(200) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,10 @@
|
||||
|
||||
package org.springframework.web.client
|
||||
|
||||
import com.nhaarman.mockito_kotlin.mock
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.HttpEntity
|
||||
import org.springframework.http.HttpMethod
|
||||
@@ -38,11 +34,9 @@ import kotlin.reflect.jvm.kotlinFunction
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class RestOperationsExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var template: RestOperations
|
||||
val template = mockk<RestOperations>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `getForObject with reified type parameters, String and varargs`() {
|
||||
@@ -50,7 +44,7 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.getForObject<Foo>(url, var1, var2)
|
||||
verify(template, times(1)).getForObject(url, Foo::class.java, var1, var2)
|
||||
verify { template.getForObject(url, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,21 +52,21 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.getForObject<Foo>(url, vars)
|
||||
verify(template, times(1)).getForObject(url, Foo::class.java, vars)
|
||||
verify { template.getForObject(url, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getForObject with reified type parameters and URI`() {
|
||||
val url = URI("https://spring.io")
|
||||
template.getForObject<Foo>(url)
|
||||
verify(template, times(1)).getForObject(url, Foo::class.java)
|
||||
verify { template.getForObject(url, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getForEntity with reified type parameters, String and URI`() {
|
||||
val url = URI("https://spring.io")
|
||||
template.getForEntity<Foo>(url)
|
||||
verify(template, times(1)).getForEntity(url, Foo::class.java)
|
||||
verify { template.getForEntity(url, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +75,7 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.getForEntity<Foo>(url, var1, var2)
|
||||
verify(template, times(1)).getForEntity(url, Foo::class.java, var1, var2)
|
||||
verify { template.getForEntity(url, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +83,7 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.getForEntity<Foo>(url, vars)
|
||||
verify(template, times(1)).getForEntity(url, Foo::class.java, vars)
|
||||
verify { template.getForEntity(url, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +93,7 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.patchForObject<Foo>(url, body, var1, var2)
|
||||
verify(template, times(1)).patchForObject(url, body, Foo::class.java, var1, var2)
|
||||
verify { template.patchForObject(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +102,7 @@ class RestOperationsExtensionsTests {
|
||||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.patchForObject<Foo>(url, body, vars)
|
||||
verify(template, times(1)).patchForObject(url, body, Foo::class.java, vars)
|
||||
verify { template.patchForObject(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,14 +110,14 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
template.patchForObject<Foo>(url, body)
|
||||
verify(template, times(1)).patchForObject(url, body, Foo::class.java)
|
||||
verify { template.patchForObject(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `patchForObject with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
template.patchForObject<Foo>(url)
|
||||
verify(template, times(1)).patchForObject(url, null, Foo::class.java)
|
||||
verify { template.patchForObject(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +127,7 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.postForObject<Foo>(url, body, var1, var2)
|
||||
verify(template, times(1)).postForObject(url, body, Foo::class.java, var1, var2)
|
||||
verify { template.postForObject(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,7 +136,7 @@ class RestOperationsExtensionsTests {
|
||||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.postForObject<Foo>(url, body, vars)
|
||||
verify(template, times(1)).postForObject(url, body, Foo::class.java, vars)
|
||||
verify { template.postForObject(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,14 +144,14 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
template.postForObject<Foo>(url, body)
|
||||
verify(template, times(1)).postForObject(url, body, Foo::class.java)
|
||||
verify { template.postForObject(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `postForObject with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
template.postForObject<Foo>(url)
|
||||
verify(template, times(1)).postForObject(url, null, Foo::class.java)
|
||||
verify { template.postForObject(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,7 +161,7 @@ class RestOperationsExtensionsTests {
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.postForEntity<Foo>(url, body, var1, var2)
|
||||
verify(template, times(1)).postForEntity(url, body, Foo::class.java, var1, var2)
|
||||
verify { template.postForEntity(url, body, Foo::class.java, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,7 +170,7 @@ class RestOperationsExtensionsTests {
|
||||
val body: Any = "body"
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.postForEntity<Foo>(url, body, vars)
|
||||
verify(template, times(1)).postForEntity(url, body, Foo::class.java, vars)
|
||||
verify { template.postForEntity(url, body, Foo::class.java, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,47 +178,47 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val body: Any = "body"
|
||||
template.postForEntity<Foo>(url, body)
|
||||
verify(template, times(1)).postForEntity(url, body, Foo::class.java)
|
||||
verify { template.postForEntity(url, body, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `postForEntity with reified type parameters`() {
|
||||
val url = "https://spring.io"
|
||||
template.postForEntity<Foo>(url)
|
||||
verify(template, times(1)).postForEntity(url, null, Foo::class.java)
|
||||
verify { template.postForEntity(url, null, Foo::class.java) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exchange with reified type parameters, String, HttpMethod, HttpEntity and varargs`() {
|
||||
val url = "https://spring.io"
|
||||
val method = HttpMethod.GET
|
||||
val entity = mock<HttpEntity<Foo>>()
|
||||
val entity = mockk<HttpEntity<Foo>>()
|
||||
val var1 = "var1"
|
||||
val var2 = "var2"
|
||||
template.exchange<List<Foo>>(url, method, entity, var1, var2)
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, var1, var2)
|
||||
verify { template.exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, var1, var2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exchange with reified type parameters, String, HttpMethod, HttpEntity and Map`() {
|
||||
val url = "https://spring.io"
|
||||
val method = HttpMethod.GET
|
||||
val entity = mock<HttpEntity<Foo>>()
|
||||
val entity = mockk<HttpEntity<Foo>>()
|
||||
val vars = mapOf(Pair("key1", "value1"), Pair("key2", "value2"))
|
||||
template.exchange<List<Foo>>(url, method, entity, vars)
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, vars)
|
||||
verify { template.exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}, vars) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exchange with reified type parameters, String, HttpMethod and HttpEntity`() {
|
||||
val url = "https://spring.io"
|
||||
val method = HttpMethod.GET
|
||||
val entity = mock<HttpEntity<Foo>>()
|
||||
val entity = mockk<HttpEntity<Foo>>()
|
||||
template.exchange<List<Foo>>(url, method, entity)
|
||||
verify(template, times(1)).exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { template.exchange(url, method, entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -232,16 +226,16 @@ class RestOperationsExtensionsTests {
|
||||
val url = "https://spring.io"
|
||||
val method = HttpMethod.GET
|
||||
template.exchange<List<Foo>>(url, method)
|
||||
verify(template, times(1)).exchange(url, method, null,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { template.exchange(url, method, null,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `exchange with reified type parameters, String and HttpEntity`() {
|
||||
val entity = mock<RequestEntity<Foo>>()
|
||||
val entity = mockk<RequestEntity<Foo>>()
|
||||
template.exchange<List<Foo>>(entity)
|
||||
verify(template, times(1)).exchange(entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { template.exchange(entity,
|
||||
object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package org.springframework.web.reactive.function.client
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
||||
/**
|
||||
@@ -30,34 +26,32 @@ import org.springframework.core.ParameterizedTypeReference
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ClientResponseExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var response: ClientResponse
|
||||
val response = mockk<ClientResponse>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with reified type parameters`() {
|
||||
response.bodyToMono<List<Foo>>()
|
||||
verify(response, times(1)).bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { response.bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with reified type parameters`() {
|
||||
response.bodyToFlux<List<Foo>>()
|
||||
verify(response, times(1)).bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { response.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toEntity with reified type parameters`() {
|
||||
response.toEntity<List<Foo>>()
|
||||
verify(response, times(1)).toEntity(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { response.toEntity(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntityList with reified type parameters`() {
|
||||
response.toEntityList<List<Foo>>()
|
||||
verify(response, times(1)).toEntityList(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { response.toEntityList(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,9 @@
|
||||
|
||||
package org.springframework.web.reactive.function.client
|
||||
|
||||
import com.nhaarman.mockito_kotlin.mock
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
||||
@@ -32,33 +27,30 @@ import org.springframework.core.ParameterizedTypeReference
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class WebClientExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var requestBodySpec: WebClient.RequestBodySpec
|
||||
val requestBodySpec = mockk<WebClient.RequestBodySpec>(relaxed = true)
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var responseSpec: WebClient.ResponseSpec
|
||||
val responseSpec = mockk<WebClient.ResponseSpec>(relaxed = true)
|
||||
|
||||
|
||||
@Test
|
||||
fun `RequestBodySpec#body with Publisher and reified type parameters`() {
|
||||
val body = mock<Publisher<List<Foo>>>()
|
||||
val body = mockk<Publisher<List<Foo>>>()
|
||||
requestBodySpec.body(body)
|
||||
verify(requestBodySpec, times(1)).body(body, object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { requestBodySpec.body(body, object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToMono with reified type parameters`() {
|
||||
responseSpec.bodyToMono<List<Foo>>()
|
||||
verify(responseSpec, times(1)).bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { responseSpec.bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToFlux with reified type parameters`() {
|
||||
responseSpec.bodyToFlux<List<Foo>>()
|
||||
verify(responseSpec, times(1)).bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { responseSpec.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,9 @@
|
||||
|
||||
package org.springframework.web.reactive.function.client
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.web.reactive.function.server.ServerRequest
|
||||
import org.springframework.web.reactive.function.server.bodyToFlux
|
||||
@@ -32,22 +29,20 @@ import org.springframework.web.reactive.function.server.bodyToMono
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ServerRequestExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var request: ServerRequest
|
||||
val request = mockk<ServerRequest>(relaxed = true)
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with reified type parameters`() {
|
||||
request.bodyToMono<List<Foo>>()
|
||||
verify(request, times(1)).bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { request.bodyToMono(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with reified type parameters`() {
|
||||
request.bodyToFlux<List<Foo>>()
|
||||
verify(request, times(1)).bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { request.bodyToFlux(object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package org.springframework.web.reactive.function.server
|
||||
|
||||
import com.nhaarman.mockito_kotlin.mock
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.*
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.MediaType.*
|
||||
@@ -32,43 +28,41 @@ import org.springframework.http.MediaType.*
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class ServerResponseExtensionsTests {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var bodyBuilder: ServerResponse.BodyBuilder
|
||||
val bodyBuilder = mockk<ServerResponse.BodyBuilder>(relaxed = true)
|
||||
|
||||
|
||||
@Test
|
||||
fun `BodyBuilder#body with Publisher and reified type parameters`() {
|
||||
val body = mock<Publisher<List<Foo>>>()
|
||||
val body = mockk<Publisher<List<Foo>>>()
|
||||
bodyBuilder.body(body)
|
||||
verify(bodyBuilder, times(1)).body(body, object : ParameterizedTypeReference<List<Foo>>() {})
|
||||
verify { bodyBuilder.body(body, object : ParameterizedTypeReference<List<Foo>>() {}) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `BodyBuilder#bodyToServerSentEvents with Publisher and reified type parameters`() {
|
||||
val body = mock<Publisher<List<Foo>>>()
|
||||
val body = mockk<Publisher<List<Foo>>>()
|
||||
bodyBuilder.bodyToServerSentEvents(body)
|
||||
verify(bodyBuilder, times(1)).contentType(TEXT_EVENT_STREAM)
|
||||
verify { bodyBuilder.contentType(TEXT_EVENT_STREAM) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `BodyBuilder#json`() {
|
||||
bodyBuilder.json()
|
||||
verify(bodyBuilder, times(1)).contentType(APPLICATION_JSON_UTF8)
|
||||
verify { bodyBuilder.contentType(APPLICATION_JSON_UTF8) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `BodyBuilder#xml`() {
|
||||
bodyBuilder.xml()
|
||||
verify(bodyBuilder, times(1)).contentType(APPLICATION_XML)
|
||||
verify { bodyBuilder.contentType(APPLICATION_XML) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `BodyBuilder#html`() {
|
||||
bodyBuilder.html()
|
||||
verify(bodyBuilder, times(1)).contentType(TEXT_HTML)
|
||||
verify { bodyBuilder.contentType(TEXT_HTML) }
|
||||
}
|
||||
|
||||
class Foo
|
||||
|
||||
Reference in New Issue
Block a user