diff --git a/samples/junit5/src/main/java/com/example/junit5/SampleJUnit5Application.java b/samples/junit5/src/main/java/com/example/junit5/SampleJUnit5Application.java index 0cf9aa375..b3f8f2f44 100644 --- a/samples/junit5/src/main/java/com/example/junit5/SampleJUnit5Application.java +++ b/samples/junit5/src/main/java/com/example/junit5/SampleJUnit5Application.java @@ -21,63 +21,90 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Arrays; +import java.util.List; + +import static com.example.junit5.SampleJUnit5Application.Weather.SPRING; +import static com.example.junit5.SampleJUnit5Application.Weather.WINTER; + @SpringBootApplication -public class SampleJUnit5Application { - - public static void main(String[] args) { - new SpringApplication(SampleJUnit5Application.class).run(args); - } - - @RestController - private static class SampleController { - - @RequestMapping("/hello") - public HelloModel index() { - return new HelloModel("hello", "hello world!", 1.0); - } - } - - public static class HelloModel { - private String name; - private String message; - private double version; - - public HelloModel(String name, String message, double version) - { - this.name = name; - this.message = message; - this.version = version; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public String getMessage() - { - return message; - } - - public void setMessage(String message) - { - this.message = message; - } - - public double getVersion() - { - return version; - } - - public void setVersion(double version) - { - this.version = version; - } - } +public class SampleJUnit5Application +{ + + public static void main(String[] args) + { + new SpringApplication(SampleJUnit5Application.class).run(args); + } + + @RestController + private static class SampleController + { + + @RequestMapping("/hello") + public HelloModel index() + { + return new HelloModel("hello", "hello world!", 1.0, Arrays.asList(SPRING, WINTER)); + } + } + + public static class HelloModel + { + private String name; + private String message; + private double version; + private List weathers; + + public HelloModel(String name, String message, double version, List weathers) + { + this.name = name; + this.message = message; + this.version = version; + this.weathers = weathers; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public double getVersion() + { + return version; + } + + public void setVersion(double version) + { + this.version = version; + } + + public List getWeathers() + { + return weathers; + } + + public void setWeathers(List weathers) + { + this.weathers = weathers; + } + } + enum Weather + { + SPRING, SUMMER, FALL, WINTER + } } diff --git a/samples/junit5/src/test/java/com/example/junit5/SampleJUnit5ApplicationTests.java b/samples/junit5/src/test/java/com/example/junit5/SampleJUnit5ApplicationTests.java index 37441dfe8..06ce2f4e4 100644 --- a/samples/junit5/src/test/java/com/example/junit5/SampleJUnit5ApplicationTests.java +++ b/samples/junit5/src/test/java/com/example/junit5/SampleJUnit5ApplicationTests.java @@ -49,7 +49,8 @@ public void sample() throws Exception { .responseFields( fieldWithPath("name").type(JsonFieldType.STRING).description("name of the hello"), fieldWithPath("message").type(JsonFieldType.STRING).description("human readable message"), - fieldWithPath("version").type(JsonFieldType.NUMBER).description("version of the hello")) + fieldWithPath("version").type(JsonFieldType.NUMBER).description("version of the hello"), + fieldWithPath("weathers").type(JsonFieldType.ARRAY).description("an array of weathers")) .build() ))); }