Skip to content

Commit

Permalink
Update Kotlin to 1.5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ihostage committed Jun 10, 2021
1 parent 8a17bac commit 99021a7
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 54 deletions.
8 changes: 2 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ allprojects {
repositories {
mavenCentral()
}
}

subprojects {
apply<JacocoPlugin>()

jacoco {
toolVersion = Versions.jacoco
}
Expand Down Expand Up @@ -54,10 +50,10 @@ val jacocoAggregateReport by tasks.creating(JacocoReport::class) {
xml.isEnabled = true
}
additionalClassDirs(files(subprojects.flatMap { project ->
listOf("scala", "kotlin").map { project.buildDir.path + "/classes/$it/main" }
listOf("scala", "kotlin", "kotlin-2.13").map { project.buildDir.path + "/classes/$it/main" }
}))
additionalSourceDirs(files(subprojects.flatMap { project ->
listOf("scala", "kotlin").map { project.file("src/main/$it").absolutePath }
listOf("scala", "kotlin", "kotlin-2.13").map { project.file("src/main/$it").absolutePath }
}))
dependsOn(jacocoAggregateMerge)
}
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@Suppress("ObjectPropertyName")
object Versions {
const val kotlin = "1.4.21"
const val `kotlinx-coroutines` = "1.4.2"
const val kotlin = "1.5.10"
const val `kotlinx-coroutines` = "1.5.0"
const val scalaBinary = "2.13"
const val akkaStreamKafka = "2.0.5"
const val lagom = "1.6.4"
const val lagomPac4j = "2.1.0"
const val play = "2.8.2"
const val ktlint = "0.32.0"
const val `ktlint-plugin` = "8.0.0"
const val jacoco = "0.8.4"
const val ktlint = "0.41.0"
const val `ktlint-plugin` = "10.1.0"
const val jacoco = "0.8.7"
const val junit5 = "5.3.2"
const val assertj = "3.11.1"
const val `kafka-junit5` = "3.1.0"
Expand Down
8 changes: 5 additions & 3 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ plugins {

val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions.jvmTarget = "1.8"
compileKotlin.kotlinOptions.freeCompilerArgs += "-Xjvm-default=enable"
compileKotlin.kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"

val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions.jvmTarget = "1.8"
compileTestKotlin.kotlinOptions.freeCompilerArgs += "-Xjvm-default=enable"
compileTestKotlin.kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"

dependencies {
implementation(kotlin("stdlib-jdk8"))
Expand Down Expand Up @@ -64,7 +64,9 @@ configurations {
ktlint {
version.set(Versions.ktlint)
outputToConsole.set(true)
reporters.set(setOf(ReporterType.CHECKSTYLE))
reporters {
reporter(ReporterType.CHECKSTYLE)
}
}

tasks.withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.taymyr.lagom.javadsl.api.transport

import com.google.common.net.MediaType
import com.lightbend.lagom.javadsl.api.transport.MessageProtocol

import java.util.Optional.of

/**
Expand Down Expand Up @@ -57,10 +56,10 @@ object MessageProtocols {
*/
@JvmStatic
fun fromFile(file: String, def: MessageProtocol?): MessageProtocol? {
return when (file.substringAfterLast('.', "").toLowerCase()) {
return when (file.substringAfterLast('.', "").lowercase()) {
"json" -> JSON
"yaml", "yml" -> YAML
else -> def
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ class SimpleTopicProducer<T> internal constructor(
} else {
this.producerSettings = producerSettings
}
val overflowStrategy = when (if (config.hasPath(overflowStrategyPath))
config.getString(overflowStrategyPath) else "dropHead") {
val overflowStrategy = when (
if (config.hasPath(overflowStrategyPath)) config.getString(overflowStrategyPath) else "dropHead"
) {
"dropHead" -> OverflowStrategy.dropHead()
"backpressure" -> OverflowStrategy.backpressure()
"dropBuffer" -> OverflowStrategy.dropBuffer()
"dropNew" -> OverflowStrategy.dropNew()
"dropTail" -> OverflowStrategy.dropTail()
"fail" -> OverflowStrategy.fail()
else -> throw IllegalArgumentException("Unknown value overflow-strategy, " +
"expected [dropHead, backpressure, dropBuffer, dropNew, dropTail, fail]")
else -> throw IllegalArgumentException(
"Unknown value overflow-strategy, expected [dropHead, backpressure, dropBuffer, dropNew, dropTail, fail]"
)
}
val minBackoff = if (config.hasPath(minBackoffPath))
config.getDuration(minBackoffPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class SimpleTopicProducersRegistry @Inject constructor(
} else {
log.error(
"""
Can not register simple topic producer for topic ${topicCall.topicId()}.
Reason was that it was expected a topicHolder of type ${MethodTopicHolder::class.java.name}
but ${topicCall?.topicHolder()?.javaClass?.name} was found instead.
""".trimIndent()
Can not register simple topic producer for topic ${topicCall.topicId()}.
Reason was that it was expected a topicHolder of type ${MethodTopicHolder::class.java.name}
but ${topicCall?.topicHolder()?.javaClass?.name} was found instead.
""".trimIndent()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ import org.pac4j.lagom.javadsl.SecuredService
class ServiceCallBuildersTest {

private val client = object : BaseClient<Credentials, CommonProfile>() {
override fun internalInit() { }
override fun internalInit() {}
override fun redirect(context: WebContext?): HttpAction = HttpAction.redirect(context, "/")
override fun getLogoutAction(context: WebContext?, currentProfile: CommonProfile?, targetUrl: String?): RedirectAction = RedirectAction.redirect("/")
override fun getLogoutAction(
context: WebContext?,
currentProfile: CommonProfile?,
targetUrl: String?
): RedirectAction = RedirectAction.redirect("/")

override fun getCredentials(context: WebContext?): Credentials {
fun isAnonymous(): Boolean = try { context?.getRequestHeader("anonymous") != null } catch (e: TechnicalException) { false }
fun isAnonymous(): Boolean = try {
context?.getRequestHeader("anonymous") != null
} catch (e: TechnicalException) {
false
}

return if (isAnonymous()) AnonymousCredentials()
else UsernamePasswordCredentials("login", "password").apply { userProfile = CommonProfile() }
Expand All @@ -52,7 +61,7 @@ class ServiceCallBuildersTest {
}
runBlocking {
val actualResult = simpleService.testMethod()
.invoke().await()
.invoke().await()
assertThat(actualResult).isEqualTo(expectedResult)
}
}
Expand All @@ -73,8 +82,8 @@ class ServiceCallBuildersTest {
}
runBlocking {
val actualResult = simpleService.testMethod()
.handleRequestHeader { headers -> headers.withHeader(expectedHeaderName, expectedHeaderValue) }
.await()
.handleRequestHeader { headers -> headers.withHeader(expectedHeaderName, expectedHeaderValue) }
.await()
assertThat(actualResult).isEqualTo(expectedResult)
}
}
Expand All @@ -92,8 +101,8 @@ class ServiceCallBuildersTest {
}
runBlocking {
val actualResult = simpleService.testMethod()
.handleRequestHeader { headers -> headers }
.await()
.handleRequestHeader { headers -> headers }
.await()
assertThat(actualResult).isEqualTo(expectedResult)
}
}
Expand All @@ -106,18 +115,19 @@ class ServiceCallBuildersTest {
val expectedHeaderValue = "headerValue"
val simpleService = object : TestService, SecuredService {
override fun getSecurityConfig(): Config = pac4jConfig
override fun testMethod(): ServiceCall<NotUsed, String> = authorizedHeaderServiceCall { headers, _, profile ->
assertThat(profile).isInstanceOf(CommonProfile::class.java)
val expectedHeader = headers.getHeader(expectedHeaderName)
assertThat(expectedHeader.isPresent)
assertThat(expectedHeader.get()).isEqualTo(expectedHeaderValue)
Pair.create(ResponseHeader.OK, expectedResult)
}
override fun testMethod(): ServiceCall<NotUsed, String> =
authorizedHeaderServiceCall { headers, _, profile ->
assertThat(profile).isInstanceOf(CommonProfile::class.java)
val expectedHeader = headers.getHeader(expectedHeaderName)
assertThat(expectedHeader.isPresent)
assertThat(expectedHeader.get()).isEqualTo(expectedHeaderValue)
Pair.create(ResponseHeader.OK, expectedResult)
}
}
runBlocking {
val actualResult = simpleService.testMethod()
.handleRequestHeader { headers -> headers.withHeader(expectedHeaderName, expectedHeaderValue) }
.await()
.handleRequestHeader { headers -> headers.withHeader(expectedHeaderName, expectedHeaderValue) }
.await()
assertThat(actualResult).isEqualTo(expectedResult)
}
}
Expand Down Expand Up @@ -149,17 +159,20 @@ class ServiceCallBuildersTest {
val expectedHeaderValue = "headerValue"
val simpleService = object : TestService, SecuredService {
override fun getSecurityConfig(): Config = pac4jConfig
override fun testMethod(): ServiceCall<NotUsed, String> = authenticatedHeaderServiceCall { headers, _, profile ->
assertThat(profile).isInstanceOf(AnonymousProfile::class.java)
val expectedHeader = headers.getHeader(expectedHeaderName)
assertThat(expectedHeader.isPresent)
assertThat(expectedHeader.get()).isEqualTo(expectedHeaderValue)
Pair.create(ResponseHeader.OK, expectedResult)
}
override fun testMethod(): ServiceCall<NotUsed, String> =
authenticatedHeaderServiceCall { headers, _, profile ->
assertThat(profile).isInstanceOf(AnonymousProfile::class.java)
val expectedHeader = headers.getHeader(expectedHeaderName)
assertThat(expectedHeader.isPresent)
assertThat(expectedHeader.get()).isEqualTo(expectedHeaderValue)
Pair.create(ResponseHeader.OK, expectedResult)
}
}
runBlocking {
val actualResult = simpleService.testMethod()
.handleRequestHeader { it.withHeader(expectedHeaderName, expectedHeaderValue).withHeader("anonymous", "yes") }
.handleRequestHeader {
it.withHeader(expectedHeaderName, expectedHeaderValue).withHeader("anonymous", "yes")
}
.await()
assertThat(actualResult).isEqualTo(expectedResult)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ interface TestService : Service {

fun testMethod(): ServiceCall<NotUsed, String>

@JvmDefault
override fun descriptor(): Descriptor {
return named("test-service")
.withCalls(
restCall<NotUsed, String>(Method.GET, "/test", TestService::testMethod.javaMethod)
)
.withCalls(
restCall<NotUsed, String>(Method.GET, "/test", TestService::testMethod.javaMethod)
)
}
}

0 comments on commit 99021a7

Please sign in to comment.