Alina Grebenkina
04/26/2022, 3:00 PMGillian Buijs
05/04/2022, 4:35 PMMarco Pierucci
05/05/2022, 4:00 PMAndré Martins
05/05/2022, 4:18 PMval (result, duration) = measureTimedValue {
try {
foo()
} catch (ex: Throwable) {
ex
}
}
when(result) {
is Throwable -> println("Error ${duration.inWholeMilliseconds} ms")
else -> println("Success ${duration.inWholeMilliseconds} ms")
}
Kristian Nedrevold
05/05/2022, 6:41 PMmbonnin
05/09/2022, 2:32 PMJarkko Miettinen
05/10/2022, 10:24 AMKevin Del Castillo
05/10/2022, 10:15 PMAndrzej Sawoniewicz
05/13/2022, 2:17 PMstvn
05/14/2022, 1:40 PMfulstaph
05/14/2022, 2:21 PMclass ApplicationTest {
@Test
fun testRoot() = testApplication {
val response = client.get("/")
assertEquals(HttpStatusCode.OK, response.status)
}
}
basically this sample test is failing because it seems like testApplication
tries to init hikari conn pool. If I run database everything is ok. Can I substitute this w/ in memory database somehow? Or better yet, drop the DB connection altogether and use service layer mock?
Sorry if the question is dumb, I have no experience with JVM ecosystem, would be glad to get any suggestions.ESchouten
05/16/2022, 8:48 PMdave
05/17/2022, 9:06 AMBingZi233
05/17/2022, 11:31 PMKristian Nedrevold
05/20/2022, 10:46 PMAlexis Cala Martínez
05/23/2022, 11:00 PMThanabodee Charoenpiriyakij
05/31/2022, 11:10 AMIwan Aucamp
06/02/2022, 3:31 PMkenkyee
06/02/2022, 3:41 PMAndromadus Naruto
06/07/2022, 5:27 AMdleuck
06/08/2022, 5:26 AMAndrzej Sawoniewicz
06/09/2022, 2:56 PMGopal S Akshintala
06/14/2022, 1:46 PMCody Mikol
06/14/2022, 6:30 PMPaul-Arthur Thiery
06/15/2022, 1:35 PMUnresolved Reference
for every single import in my .kt
files. Using the builtin Intellij compiler works fine however ! Is this a known issue ?IsaacMart
06/17/2022, 4:51 AMPartho Paul
06/21/2022, 5:13 AMgetDynamoDbClient().use { ddb ->
return@use ddb.getItem(dbRequest)
}
Upon running this, I’m getting java.lang.IncompatibleClassChangeError: Found interface kotlin.time.TimeMark, but class was expected
error. I’m doing it as it’s shown in https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/kotlin/services/dynamodb/src/main/kotlin/com/kotlin/dynamodb/GetItem.kt. Am I doing anything wrong?
Kotlin version: 1.7.0, Ktor version: 2.0.2, aws version: 0.16.0
TIAitzik kasovitch
06/27/2022, 8:14 AMv79
06/27/2022, 8:10 PMAlex Stelmachonak
06/28/2022, 3:35 PMinterface HttpResponseBody {
val asString: String
inline fun <reified T : Any> asInstanceOf(format: BodyFormat): T =
when (format) {
BodyFormat.JSON -> jacksonObjectMapper().readValue(asString)
}
}
so I can utilize the jackson-kotlin support of reified type parameters to not pass class instance to the deserialization method and be able to use it like this
response.body.asInstanceOf<User>(BodyFormat.JSON)
But reified
only works in inline
functions and I can't inline the function in interface. I was looking for not ugly way to workaround that and have similar implementation in place. So far I found two ways of doing this:
1. Convert HttpResponseBody
to abstract class, so inline
and reified
are working.
2. Convert asInstanceOf
method to the extension method of the HttpResponseBody
interface.
Both are working, but doesn't fit nicely with my other codebase (which I probably need to refactor), but I wanted to ask may be I am missing some other solutions?Alex Stelmachonak
06/28/2022, 3:35 PMinterface HttpResponseBody {
val asString: String
inline fun <reified T : Any> asInstanceOf(format: BodyFormat): T =
when (format) {
BodyFormat.JSON -> jacksonObjectMapper().readValue(asString)
}
}
so I can utilize the jackson-kotlin support of reified type parameters to not pass class instance to the deserialization method and be able to use it like this
response.body.asInstanceOf<User>(BodyFormat.JSON)
But reified
only works in inline
functions and I can't inline the function in interface. I was looking for not ugly way to workaround that and have similar implementation in place. So far I found two ways of doing this:
1. Convert HttpResponseBody
to abstract class, so inline
and reified
are working.
2. Convert asInstanceOf
method to the extension method of the HttpResponseBody
interface.
Both are working, but doesn't fit nicely with my other codebase (which I probably need to refactor), but I wanted to ask may be I am missing some other solutions?mitch
06/28/2022, 9:50 PMinterface HttpResponseBody {
fun <T> instanceOf(bodyFormat: BodyFormat, clazz: Class<T>): T
}
inline fun <reified T> HttpResponseBody.instanceOf(bodyFormat: BodyFormat) = instanceOf(bodyFormat, T::class.java)
Alex Stelmachonak
06/28/2022, 9:57 PMreadValue
requires generic type to be reified
, which is not possible.
If I just do T::class.java
it kind of works, but looses the benefits of Kotlin classes additional runtime data. I.e. I can't just use data class without extra @JsonProperty
annotations.DALDEI
07/02/2022, 8:26 AM