@Test public void t002_testDocumentCreate() throws Exception { mvc.perform(get(API_BASE + "/projects/1/documents") .with(csrf().asHeader()) .with(user("admin").roles("ADMIN"))) .andExpect(status().isOk()) .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(jsonPath("$.messages").isEmpty()); mvc.perform(multipart(API_BASE + "/projects/1/documents") .file("content", "This is a test.".getBytes("UTF-8")) .with(csrf().asHeader()) .with(user("admin").roles("ADMIN")) .param("name", "test.txt") .param("format", "text")) .andExpect(status().isCreated()) .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(jsonPath("$.body.id").value("1")) .andExpect(jsonPath("$.body.name").value("test.txt")); mvc.perform(get(API_BASE + "/projects/1/documents") .with(csrf().asHeader()) .with(user("admin").roles("ADMIN"))) .andExpect(status().isOk()) .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(jsonPath("$.body[0].id").value("1")) .andExpect(jsonPath("$.body[0].name").value("test.txt")) .andExpect(jsonPath("$.body[0].state").value("NEW")); }
.with(csrf().asHeader()) .with(user("admin").roles("ADMIN")) .param("name", "test.txt")
.with(csrf().asHeader()) .with(user("admin").roles("ADMIN")) .param("name", "test.txt")