GH-1015 Fix Kotlin dependencies

GH-1015 Fix Kotlin dependencies
This commit is contained in:
Oleg Zhurakousky
2023-03-20 18:44:52 +01:00
parent 619c454064
commit 98e88e7314
8 changed files with 31 additions and 87 deletions

View File

@@ -28,39 +28,39 @@ import java.util.List
*/
@EnableAutoConfiguration
@Configuration
class KotlinLambdasConfiguration {
open class KotlinLambdasConfiguration {
@Bean
fun uppercase(): Function<String, String> = KotlinComponentFunction()
open fun uppercase(): Function<String, String> = KotlinComponentFunction()
@Bean
fun kotlinFunction(): (String) -> String {
open fun kotlinFunction(): (String) -> String {
return { it.toUpperCase() }
}
@Bean
fun kotlinPojoFunction(): (Person) -> String {
open fun kotlinPojoFunction(): (Person) -> String {
return { it.name.toString()}
}
@Bean
fun kotlinListPojoFunction(): (List<Person>) -> String {
open fun kotlinListPojoFunction(): (List<Person>) -> String {
return {
"List of: " + it.get(0).name
}
}
@Bean
fun kotlinConsumer(): (String) -> Unit {
open fun kotlinConsumer(): (String) -> Unit {
return { println(it) }
}
@Bean
fun kotlinSupplier(): () -> String {
open fun kotlinSupplier(): () -> String {
return { "Hello" }
}
@Bean
fun javaFunction(): Function<String, String> {
open fun javaFunction(): Function<String, String> {
return Function { x -> x }
}

View File

@@ -32,32 +32,32 @@ import java.util.function.Function
*/
@EnableAutoConfiguration
@Configuration
class KotlinSuspendFlowLambdasConfiguration {
open class KotlinSuspendFlowLambdasConfiguration {
@Bean
fun kotlinFunction(): suspend (Flow<String>) -> Flow<String> = { flow ->
open fun kotlinFunction(): suspend (Flow<String>) -> Flow<String> = { flow ->
flow.map { value -> value.toUpperCase() }
}
@Bean
fun kotlinPojoFunction(): suspend (Flow<Person>) -> Flow<String> = { flow ->
open fun kotlinPojoFunction(): suspend (Flow<Person>) -> Flow<String> = { flow ->
flow.map(Person::toString)
}
@Bean
fun kotlinConsumer(): suspend (Flow<String>) -> Unit = { flow ->
open fun kotlinConsumer(): suspend (Flow<String>) -> Unit = { flow ->
flow.collect(::println)
}
@Bean
fun kotlinSupplier(): suspend () -> Flow<String> = {
open fun kotlinSupplier(): suspend () -> Flow<String> = {
flow {
emit("Hello")
}
}
@Bean
fun javaFunction(): Function<Flux<String>, Flux<String>> {
open fun javaFunction(): Function<Flux<String>, Flux<String>> {
return Function { x -> x }
}

View File

@@ -26,20 +26,20 @@ import org.springframework.context.annotation.Configuration
*/
@EnableAutoConfiguration
@Configuration
class KotlinSuspendLambdasConfiguration {
open class KotlinSuspendLambdasConfiguration {
@Bean
fun kotlinFunction(): suspend (Person) -> String {
open fun kotlinFunction(): suspend (Person) -> String {
return { it.name.toString()}
}
@Bean
fun kotlinConsumer(): suspend (String) -> Unit {
open fun kotlinConsumer(): suspend (String) -> Unit {
return { println(it) }
}
@Bean
fun kotlinSupplier(): suspend () -> String {
open fun kotlinSupplier(): suspend () -> String {
return { "Hello" }
}

View File

@@ -41,12 +41,12 @@ import java.net.URI
properties = ["spring.cloud.function.web.path=/functions", "spring.main.web-application-type=reactive"]
)
@ContextConfiguration(classes = [RestApplication::class, HeadersToMessageSuspendTests.TestConfiguration::class])
class HeadersToMessageSuspendTests {
open class HeadersToMessageSuspendTests {
@Autowired
private val rest: TestRestTemplate? = null
@Test
@Throws(Exception::class)
fun testBodyAndCustomHeaderFromMessagePropagation() {
open fun testBodyAndCustomHeaderFromMessagePropagation() {
// test POJO paylod
var postForEntity = rest!!
.exchange(
@@ -75,9 +75,9 @@ class HeadersToMessageSuspendTests {
@EnableAutoConfiguration
@org.springframework.boot.test.context.TestConfiguration
class TestConfiguration {
open class TestConfiguration {
@Bean("stringSuspend")
fun functiono():suspend (employee: Flow<Message<String>>) -> Flow<Message<String>> = { flow: Flow<Message<String>> ->
open fun functiono():suspend (employee: Flow<Message<String>>) -> Flow<Message<String>> = { flow: Flow<Message<String>> ->
flow.map { request ->
val message =
MessageBuilder.withPayload(request.payload)
@@ -88,7 +88,7 @@ class HeadersToMessageSuspendTests {
}
@Bean("employeeSuspend")
fun function1(): suspend (employee: Flow<Message<Employee>>) -> Flow<Message<Employee>> = { flow ->
open fun function1(): suspend (employee: Flow<Message<Employee>>) -> Flow<Message<Employee>> = { flow ->
flow.map { request ->
val message =
MessageBuilder
@@ -101,7 +101,7 @@ class HeadersToMessageSuspendTests {
}
}
class Employee {
open class Employee {
var name: String? = null
var age = 0
}

View File

@@ -41,12 +41,12 @@ import java.net.URI
properties = ["spring.cloud.function.web.path=/functions", "spring.main.web-application-type=reactive"]
)
@ContextConfiguration(classes = [RestApplication::class, HeadersToMessageTests.TestConfiguration::class])
class HeadersToMessageTests {
open class HeadersToMessageTests {
@Autowired
private val rest: TestRestTemplate? = null
@Test
@Throws(Exception::class)
fun testBodyAndCustomHeaderFromMessagePropagation() {
open fun testBodyAndCustomHeaderFromMessagePropagation() {
// test POJO paylod
var postForEntity = rest!!
.exchange(
@@ -74,9 +74,9 @@ class HeadersToMessageTests {
@EnableAutoConfiguration
@org.springframework.boot.test.context.TestConfiguration
class TestConfiguration {
open class TestConfiguration {
@Bean("string")
fun functiono(): (message: Message<String?>) -> Message<String> = { request: Message<String?> ->
open fun functiono(): (message: Message<String?>) -> Message<String?> = { request: Message<String?> ->
val message =
MessageBuilder.withPayload(request.payload)
.setHeader("X-Content-Type", "application/xml")
@@ -85,7 +85,7 @@ class HeadersToMessageTests {
}
@Bean("employee")
fun function1(): (employee: Message<Employee>) -> Message<Employee> = { request ->
open fun function1(): (employee: Message<Employee>) -> Message<Employee> = { request ->
val message =
MessageBuilder
.withPayload(request.payload)
@@ -96,7 +96,7 @@ class HeadersToMessageTests {
}
// used by json converter
class Employee {
open class Employee {
var name: String? = null
var age = 0
}