Skip to content

Commit

Permalink
jooby-apt: turn off Route.setMvcMethod and Route.setReturnType by def…
Browse files Browse the repository at this point in the history
…ault

- fix #3529
  • Loading branch information
jknack committed Sep 15, 2024
1 parent 6881b6a commit 6ee3281
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/asciidoc/mvc-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@ on them (mostly annotations processors).
|string
|[]
|Add custom handler mapping.

|jooby.mvcMethod
|boolean
|false
|Set the Route.mvcMethod when true.
|===

==== Setting options
Expand Down
3 changes: 2 additions & 1 deletion jooby/src/main/java/io/jooby/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ public boolean isTransactional(boolean defaultValue) {
}

/**
* Method for MVC/Controller. Not available for lambda routes.
* Method for MVC/Controller available when <code>jooby.mvcMethod</code> processor option is set
* to <code>true</code>. Not available for lambda routes.
*
* @return Method for MVC/Controller. Not available for lambda routes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public MvcContext(
this.output = output;
this.debug = Options.boolOpt(processingEnvironment, Options.DEBUG, false);
this.incremental = Options.boolOpt(processingEnvironment, Options.INCREMENTAL, true);
this.returnType = Options.boolOpt(processingEnvironment, Options.RETURN_TYPE, true);
this.mvcMethod = Options.boolOpt(processingEnvironment, Options.MVC_METHOD, true);
this.returnType = Options.boolOpt(processingEnvironment, Options.RETURN_TYPE, false);
this.mvcMethod = Options.boolOpt(processingEnvironment, Options.MVC_METHOD, false);
this.services = Options.boolOpt(processingEnvironment, Options.SERVICES, true);
this.routerPrefix = Options.string(processingEnvironment, Options.ROUTER_PREFIX, "");
this.routerSuffix = Options.string(processingEnvironment, Options.ROUTER_SUFFIX, "_");
Expand Down
4 changes: 2 additions & 2 deletions modules/jooby-apt/src/test/java/tests/ModuleCompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void arrayRoute() throws Exception {

@Test
public void routes() throws Exception {
new ProcessorRunner(new Routes())
new ProcessorRunner(new Routes(), Map.of("jooby.returnType", true))
.withRouter(
app -> {
MockRouter router = new MockRouter(app);
Expand Down Expand Up @@ -263,7 +263,7 @@ public void noTopLevel() throws Exception {

@Test
public void setPrimitiveReturnType() throws Exception {
new ProcessorRunner(new PrimitiveReturnType())
new ProcessorRunner(new PrimitiveReturnType(), Map.of("jooby.returnType", true))
.withRouter(
app -> {
Route route = app.getRoutes().get(0);
Expand Down
4 changes: 3 additions & 1 deletion modules/jooby-apt/src/test/java/tests/i1814/Issue1814.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Map;

import org.junit.jupiter.api.Test;

import io.jooby.apt.ProcessorRunner;
Expand All @@ -17,7 +19,7 @@ public class Issue1814 {

@Test
public void shouldIgnoreWildcardResponseType() throws Exception {
new ProcessorRunner(new C1814())
new ProcessorRunner(new C1814(), Map.of("jooby.returnType", true))
.withRouter(
app -> {
MockRouter router = new MockRouter(app);
Expand Down
3 changes: 2 additions & 1 deletion modules/jooby-apt/src/test/java/tests/i2629/Issue2629.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Test;

Expand All @@ -20,7 +21,7 @@ public class Issue2629 {

@Test
public void shouldSetMvcMethod() throws Exception {
new ProcessorRunner(new C2629())
new ProcessorRunner(new C2629(), Map.of("jooby.mvcMethod", true))
.withRouter(
app -> {
MockRouter router = new MockRouter(app);
Expand Down
4 changes: 3 additions & 1 deletion modules/jooby-apt/src/test/java/tests/i2629/Issue2629b.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Map;

import org.junit.jupiter.api.Test;

import io.jooby.apt.ProcessorRunner;
Expand All @@ -18,7 +20,7 @@ public class Issue2629b {

@Test
public void shouldSetMvcMethod() throws Exception {
new ProcessorRunner(new C2629b())
new ProcessorRunner(new C2629b(), Map.of("jooby.mvcMethod", true))
.withRouter(
app -> {
MockRouter router = new MockRouter(app);
Expand Down
3 changes: 2 additions & 1 deletion modules/jooby-apt/src/test/java/tests/i3490/Issue3490.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.Map;

import org.junit.jupiter.api.Test;

Expand All @@ -17,7 +18,7 @@ public class Issue3490 {

@Test
public void shouldNotGeneratePrimitiveOnKotlinGenerics() throws IOException {
new ProcessorRunner(new C3490())
new ProcessorRunner(new C3490(), Map.of("jooby.returnType", true))
.withSourceCode(
true,
source -> {
Expand Down

0 comments on commit 6ee3281

Please sign in to comment.