Search in sources :

Example 1 with Greeting

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"));
}
Also used : Greeting(io.restassured.examples.springmvc.support.Greeting) FileOutputStream(java.io.FileOutputStream) JsonPath(io.restassured.path.json.JsonPath) File(java.io.File) Test(org.junit.Test)

Aggregations

Greeting (io.restassured.examples.springmvc.support.Greeting)1 JsonPath (io.restassured.path.json.JsonPath)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 Test (org.junit.Test)1