Refactoring for better Indentation and Formatting
This commit is contained in:
parent
733c7e76b9
commit
9d464b4f45
@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class UnsupportedMediaTypeApplication {
|
public class UnsupportedMediaTypeApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(UnsupportedMediaTypeApplication.class, args);
|
SpringApplication.run(UnsupportedMediaTypeApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,9 @@ public class User implements Serializable {
|
|||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
public User(){
|
public User(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(Integer id, String name, Integer age, String address){
|
public User(Integer id, String name, Integer age, String address) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.age = age;
|
this.age = age;
|
||||||
@ -55,11 +54,13 @@ public class User implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User{" +
|
return "User{"
|
||||||
"id=" + id +
|
+ "id=" + id
|
||||||
", name='" + name + '\'' +
|
+ ", name='" + name + '\''
|
||||||
", age=" + age +
|
+ ", age=" + age
|
||||||
", address='" + address + '\'' +
|
+ ", address='" + address + '\''
|
||||||
'}';
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,38 +21,38 @@ public class ApplicationUnitTest {
|
|||||||
public void JsonTestCase() throws Exception {
|
public void JsonTestCase() throws Exception {
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
||||||
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
||||||
.content("{\n" +
|
.content( "{\n"
|
||||||
" \"name\": \"Andy\",\n" +
|
+ " \"name\": \"Andy\",\n"
|
||||||
" \"age\": 1,\n" +
|
+ " \"age\": 1,\n"
|
||||||
" \"address\": \"Hello world\"\n" +
|
+ " \"address\": \"Hello world\"\n"
|
||||||
"}"))
|
+ "}"))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void JsonFailTestCase() throws Exception {// Because no content-type added
|
public void JsonFailTestCase() throws Exception {// Because no content-type added
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
||||||
.content("{\n" +
|
.content( "{\n"
|
||||||
" \"name\": \"Andy\",\n" +
|
+ " \"name\": \"Andy\",\n"
|
||||||
" \"age\": 1,\n" +
|
+ " \"age\": 1,\n"
|
||||||
" \"address\": \"Hello world\"\n" +
|
+ " \"address\": \"Hello world\"\n"
|
||||||
"}"))
|
+ "}"))
|
||||||
.andExpect(status().isUnsupportedMediaType());
|
.andExpect(status().isUnsupportedMediaType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void XmlTestCase() throws Exception {
|
public void XmlTestCase() throws Exception {
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
||||||
.contentType(MediaType.APPLICATION_XML_VALUE)
|
.contentType(MediaType.APPLICATION_XML_VALUE)
|
||||||
.content("<user><name>Andy</name><age>1</age><address>Hello world</address></user>"))
|
.content("<user><name>Andy</name><age>1</age><address>Hello world</address></user>"))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void StringFailTestCase() throws Exception { // Because content-type is not supported
|
public void StringFailTestCase() throws Exception { // Because content-type is not supported
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
mockMvc.perform(MockMvcRequestBuilders.post("/user/")
|
||||||
.contentType(MediaType.TEXT_PLAIN_VALUE)
|
.contentType(MediaType.TEXT_PLAIN_VALUE)
|
||||||
.content("<user><name>Andy</name><age>1</age><address>Hello world</address></user>"))
|
.content("<user><name>Andy</name><age>1</age><address>Hello world</address></user>"))
|
||||||
.andExpect(status().isUnsupportedMediaType());
|
.andExpect(status().isUnsupportedMediaType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user