|
6 | 6 |
|
7 | 7 | import static org.assertj.core.api.Assertions.assertThat; |
8 | 8 | import static org.hamcrest.Matchers.containsInAnyOrder; |
| 9 | +import static org.springframework.http.HttpMethod.PATCH; |
9 | 10 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; |
10 | 11 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
11 | 12 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; |
12 | 13 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; |
13 | 14 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
14 | 15 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
15 | 16 |
|
| 17 | +import com.fasterxml.jackson.databind.ObjectMapper; |
16 | 18 | import com.github.database.rider.core.api.dataset.DataSet; |
17 | 19 |
|
18 | 20 | import io.twogether.nbe_5_7_2_02team.browser.template.BrowserTestTemplate; |
|
33 | 35 | import org.junit.jupiter.params.ParameterizedTest; |
34 | 36 | import org.junit.jupiter.params.provider.MethodSource; |
35 | 37 | import org.springframework.beans.factory.annotation.Autowired; |
| 38 | +import org.springframework.http.HttpMethod; |
36 | 39 | import org.springframework.http.MediaType; |
37 | 40 |
|
38 | 41 | import java.util.List; |
39 | 42 | import java.util.Optional; |
40 | 43 | import java.util.stream.Stream; |
| 44 | +import org.springframework.mock.web.MockMultipartFile; |
41 | 45 |
|
42 | 46 | @FlywayReset |
43 | 47 | public class PostBrowserSuccessTest extends BrowserTestTemplate { |
44 | 48 |
|
45 | 49 | @Autowired MemberRepository memberRepository; |
46 | 50 | @Autowired private TagRepository tagRepository; |
47 | 51 | @Autowired private PostRepository postRepository; |
| 52 | + @Autowired private ObjectMapper objectMapper; |
48 | 53 |
|
49 | 54 | @AllArgsConstructor |
50 | 55 | static class PostCreateRequest { |
@@ -292,12 +297,17 @@ void patchPostWithCheckingUnusedTags() throws Exception { |
292 | 297 | request.setContent("NEW CONTENT"); |
293 | 298 | request.setRecruitmentStatus(DONE); |
294 | 299 |
|
| 300 | + MockMultipartFile jsonPart = new MockMultipartFile( |
| 301 | + "post", |
| 302 | + "", |
| 303 | + "application/json", |
| 304 | + objectMapper.writeValueAsBytes(request) |
| 305 | + ); |
| 306 | + |
295 | 307 | // when |
296 | 308 | mockMvc.perform( |
297 | | - patch("/api/posts/" + targetPostId) |
298 | | - .param("title", request.getTitle()) |
299 | | - .param("content", request.getContent()) |
300 | | - .param("recruitmentStatus", request.getRecruitmentStatus().name()) |
| 309 | + multipart(PATCH, "/api/posts/" + targetPostId) |
| 310 | + .file(jsonPart) |
301 | 311 | .contentType(MediaType.MULTIPART_FORM_DATA_VALUE) |
302 | 312 | .header("Authorization", "Bearer " + tokenPair.getAccessToken())) |
303 | 313 | .andExpectAll(status().isOk(), jsonPath("$.id").value(targetPostId)); |
|
0 commit comments