Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lzhoucs committed Mar 25, 2019
1 parent 38e03d5 commit 61f5a6c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Weather> weathers;

public HelloModel(String name, String message, double version, List<Weather> 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<Weather> getWeathers()
{
return weathers;
}

public void setWeathers(List<Weather> weathers)
{
this.weathers = weathers;
}
}

enum Weather
{
SPRING, SUMMER, FALL, WINTER
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)));
}
Expand Down

0 comments on commit 61f5a6c

Please sign in to comment.