File tree Expand file tree Collapse file tree
modules/jooby-apt/src/test/java/tests/instance Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 tests .instance ;
7+
8+ import io .jooby .annotation .GET ;
9+ import jakarta .inject .Inject ;
10+
11+ public class DIController {
12+ private final NoDIController controller ;
13+
14+ @ Inject
15+ public DIController (NoDIController controller ) {
16+ this .controller = controller ;
17+ }
18+
19+ @ GET ("/di" )
20+ public String di () {
21+ return controller .noDI ();
22+ }
23+ }
Original file line number Diff line number Diff line change 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 tests .instance ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+
10+ import org .junit .jupiter .api .Test ;
11+
12+ import io .jooby .apt .ProcessorRunner ;
13+
14+ public class DefaultControllerTest {
15+
16+ @ Test
17+ public void shouldGenerateDIDefaultConstructor () throws Exception {
18+ new ProcessorRunner (new DIController (new NoDIController ()))
19+ .withSourceCode (
20+ source -> {
21+ assertThat (source )
22+ .containsIgnoringWhitespaces (
23+ """
24+ public DIController_() {
25+ this(DIController.class);
26+ }
27+ """ );
28+ });
29+ }
30+
31+ @ Test
32+ public void shouldGenerateDefaultConstructorWithoutDI () throws Exception {
33+ new ProcessorRunner (new NoDIController ())
34+ .withSourceCode (
35+ source -> {
36+ assertThat (source )
37+ .containsIgnoringWhitespaces (
38+ """
39+ public NoDIController_() {
40+ this(io.jooby.SneakyThrows.singleton(NoDIController::new));
41+ }
42+ """ );
43+ });
44+ }
45+ }
Original file line number Diff line number Diff line change 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 tests .instance ;
7+
8+ import io .jooby .annotation .GET ;
9+
10+ public class NoDIController {
11+
12+ @ GET ("/no-di" )
13+ public String noDI () {
14+ return "no-di" ;
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments