Skip to content

Commit bd72080

Browse files
committed
Change unit test for MVC apps not to use MockRouter.
1 parent d7105a0 commit bd72080

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

modules/jooby-cli/src/main/java/io/jooby/cli/CreateCmd.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public class CreateCmd extends Cmd {
109109
String server;
110110
boolean stork = !gradle && this.stork;
111111
if (interactive) {
112-
gradle = yesNo(ctx.readLine("Use Gradle (yes/No): "));
112+
gradle = yesNo(ctx.readLine("Use Gradle (yes/no): "));
113113

114-
kotlin = yesNo(ctx.readLine("Use Kotlin (yes/No): "));
114+
kotlin = yesNo(ctx.readLine("Use Kotlin (yes/no): "));
115115

116116
packageName = ctx.readLine("Enter a groupId/package: ");
117117

@@ -120,9 +120,9 @@ public class CreateCmd extends Cmd {
120120
version = "1.0.0";
121121
}
122122

123-
mvc = yesNo(ctx.readLine("Use MVC (yes/No): "));
123+
mvc = yesNo(ctx.readLine("Use MVC (yes/no): "));
124124

125-
openapi = yesNo(ctx.readLine("Configure OpenAPI (yes/No): "));
125+
openapi = yesNo(ctx.readLine("Configure OpenAPI (yes/no): "));
126126

127127
server = server(ctx.readLine("Choose a server (jetty, netty or undertow): "));
128128

@@ -131,7 +131,7 @@ public class CreateCmd extends Cmd {
131131
.equals("stork");
132132
}
133133

134-
docker = yesNo(ctx.readLine("Generates Dockerfile (yes/No): "));
134+
docker = yesNo(ctx.readLine("Generates Dockerfile (yes/no): "));
135135
} else {
136136
String[] parts = name.split(":");
137137
switch (parts.length) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package {{package}};
22

3+
{{#unless mvc}}
34
import io.jooby.MockRouter;
45
import io.jooby.StatusCode;
6+
{{/unless}}
57
import org.junit.jupiter.api.Test;
68

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

911
public class UnitTest {
1012
@Test
1113
public void welcome() {
14+
{{#if mvc}}
15+
Controller controller = new Controller();
16+
assertEquals("Welcome to Jooby!", controller.sayHi());
17+
{{else}}
1218
MockRouter router = new MockRouter(new App());
1319
router.get("/", rsp -> {
1420
assertEquals("Welcome to Jooby!", rsp.value());
1521
assertEquals(StatusCode.OK, rsp.getStatusCode());
1622
});
23+
{{/if}}
1724
}
1825
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package {{package}}
22

3+
{{#unless mvc}}
34
import io.jooby.MockRouter
45
import io.jooby.StatusCode
6+
{{/unless}}
57
import org.junit.jupiter.api.Test
68

79
import org.junit.jupiter.api.Assertions.assertEquals
810

911
class UnitTest {
1012
@Test
1113
fun welcome() {
14+
{{#if mvc}}
15+
val controller = Controller()
16+
assertEquals("Welcome to Jooby!", controller.sayHi())
17+
{{else}}
1218
val router = MockRouter(App())
1319
router.get("/") { rsp ->
1420
assertEquals("Welcome to Jooby!", rsp.value())
1521
assertEquals(StatusCode.OK, rsp.getStatusCode())
1622
}
23+
{{/if}}
1724
}
1825
}

0 commit comments

Comments
 (0)