use of io.restassured.examples.springmvc.support.Greeting in project rest-assured by rest-assured.
the class MultiPartFileUploadITest method object_serialization_works.
@Test
public void object_serialization_works() throws IOException {
File file = folder.newFile("something");
IOUtils.write("Something3210", new FileOutputStream(file));
Greeting greeting = new Greeting();
greeting.setFirstName("John");
greeting.setLastName("Doe");
String content = RestAssuredMockMvc.given().multiPart("controlName1", file, "mime-type1").multiPart("controlName2", greeting, "application/json").when().post("/multiFileUpload").then().root("[%d]").body("size", withArgs(0), is(13)).body("name", withArgs(0), equalTo("controlName1")).body("originalName", withArgs(0), equalTo("something")).body("mimeType", withArgs(0), equalTo("mime-type1")).body("content", withArgs(0), equalTo("Something3210")).body("size", withArgs(1), greaterThan(10)).body("name", withArgs(1), equalTo("controlName2")).body("originalName", withArgs(1), equalTo("file")).body("mimeType", withArgs(1), equalTo("application/json")).body("content", withArgs(1), notNullValue()).extract().path("[1].content");
JsonPath jsonPath = new JsonPath(content);
assertThat(jsonPath.getString("firstName"), equalTo("John"));
assertThat(jsonPath.getString("lastName"), equalTo("Doe"));
}
Aggregations