Код: Выделить всё
public class ContributionNew {
private List elementsToAdd;
private Map elementsToUpdate;
private Set idsToDelete;
private Set sources;
private String comment;
}
public class Photo extends MovieInfoDTO {
private MultipartFile photo;
}
@PostMapping(value = "/{id}/contributions/photos")
@ResponseStatus(HttpStatus.CREATED)
public
ResponseEntity createPhotoContribution(
@ApiParam(value = "The movie ID", required = true)
@PathVariable("id") final Long id,
@ApiParam(value = "The contribution", required = true)
@RequestBody @Valid final ContributionNew
contribution
) {
Код: Выделить всё
@Test
public void testCreatePhotoContribution() throws Exception {
ContributionNew
contribution = new ContributionNew();
MockMultipartFile multipartFile = new MockMultipartFile("photo", "C:\\Users\\Jonatan\\Pictures\\2.png",
"image/png", "Spring Framework".getBytes());
Photo.Builder photoBuilder = new Photo.Builder(
multipartFile
);
contribution.getElementsToAdd().add(photoBuilder.build());
mockMvc
.perform(post("/api/v1.0/movies/{id}/contributions/photos", 1)
.contentType(...)
.content(...))
.andExpect(status().isCreated());
}
Подробнее здесь: https://stackoverflow.com/questions/480 ... ckmvc-test
Мобильная версия