Skip to content

Commit 1dc64ac

Browse files
committed
jooby-apt: add more tests to #3476 and #3477
1 parent 4afc47e commit 1dc64ac

File tree

6 files changed

+82
-9
lines changed

6 files changed

+82
-9
lines changed

modules/jooby-apt/src/main/java/io/jooby/internal/apt/MvcRoute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private String methodReference(boolean kt, String thisRef, String methodName) {
167167
var returnType = getReturnType();
168168
var generics = returnType.getArgumentsString(kt, true, Set.of(TypeKind.TYPEVAR));
169169
if (!generics.isEmpty()) {
170-
return CodeBlock.of(") { ", methodName, generics, "(ctx) }");
170+
return CodeBlock.of(") { ctx -> ", methodName, generics, "(ctx) }");
171171
}
172172
}
173173
return thisRef + methodName + ")";

modules/jooby-kotlin/src/test/kotlin/io/jooby/kt/Idioms.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*/
66
package io.jooby.kt
77

8-
import io.jooby.Context
98
import io.jooby.Jooby
10-
import io.jooby.Reified
119
import io.jooby.RouterOption.IGNORE_CASE
1210
import io.jooby.RouterOption.IGNORE_TRAILING_SLASH
1311
import io.jooby.ServiceKey
@@ -110,8 +108,6 @@ class Idioms :
110108
get("/ctx-access") { ctx.getRequestPath() }
111109
}
112110

113-
get("/") { foo<Any>(ctx) }.setReturnType(Reified.list<Any>(Any::class.java).type)
114-
115111
install(::SubApp)
116112

117113
install("/with-path", ::SubApp)
@@ -129,7 +125,3 @@ class Idioms :
129125
class IdiomsController {}
130126

131127
class IdiomsPojo {}
132-
133-
fun <E> foo(ctx: Context): List<E> {
134-
return listOf()
135-
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Jooby https://jooby.io
3+
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+
* Copyright 2014 Edgar Espina
5+
*/
6+
package i3476
7+
8+
import io.jooby.annotation.GET
9+
import io.jooby.annotation.QueryParam
10+
11+
class C3476 {
12+
@GET("/3476") fun <E> shouldGenerateGenerics(@QueryParam bean: List<E>): List<E> = listOf()
13+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Jooby https://jooby.io
3+
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+
* Copyright 2014 Edgar Espina
5+
*/
6+
package i3476
7+
8+
import io.jooby.jackson.JacksonModule
9+
import io.jooby.junit.ServerTest
10+
import io.jooby.junit.ServerTestRunner
11+
import io.jooby.kt.Kooby
12+
import org.junit.jupiter.api.Assertions.assertEquals
13+
14+
class Issue3476 {
15+
@ServerTest
16+
fun shouldGenerateGoodKotlinRouteMetadata(runner: ServerTestRunner) =
17+
runner
18+
.use {
19+
Kooby {
20+
install(JacksonModule())
21+
mvc(C3476_())
22+
}
23+
}
24+
.ready { client -> client.get("/3476") { rsp -> assertEquals("[]", rsp.body!!.string()) } }
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Jooby https://jooby.io
3+
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+
* Copyright 2014 Edgar Espina
5+
*/
6+
package i3477
7+
8+
import io.jooby.Context
9+
import io.jooby.annotation.GET
10+
import io.jooby.annotation.Transactional
11+
12+
class C3477 {
13+
@GET("/3477") @Transactional(false) fun generateToken(ctx: Context) = ctx.route.attributes
14+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Jooby https://jooby.io
3+
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
4+
* Copyright 2014 Edgar Espina
5+
*/
6+
package i3477
7+
8+
import io.jooby.jackson.JacksonModule
9+
import io.jooby.junit.ServerTest
10+
import io.jooby.junit.ServerTestRunner
11+
import io.jooby.kt.Kooby
12+
import org.junit.jupiter.api.Assertions.assertEquals
13+
14+
class Issue3477 {
15+
@ServerTest
16+
fun shouldGenerateGoodKotlinRouteMetadata(runner: ServerTestRunner) =
17+
runner
18+
.use {
19+
Kooby {
20+
install(JacksonModule())
21+
mvc(C3477_())
22+
}
23+
}
24+
.ready { client ->
25+
client.get("/3477") { rsp ->
26+
assertEquals("{\"Transactional\":false}", rsp.body!!.string())
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)