Request handler:
@PutMapping(value = "/put-file/{requestId}",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public String putFile(@PathVariable String requestId,
@RequestPart(value = "files") MultipartFile[] files) {
assert StringUtils.hasText(requestId);
assert files.length > 0;
return "ok";
}
Success test
@Test
void testPutFileSucceeds() throws IOException {
byte[] file = new ClassPathResource("img.png").getInputStream().readAllBytes();
String result = given()
.multiPart("files", "test.png", file, MediaType.IMAGE_PNG_VALUE)
.contentType(ContentType.MULTIPART)
.when()
.put("/put-file/100")
.then()
.statusCode(202)
.extract()
.response().getBody().asString();
assertEquals("ok", result);
}
Failing test
@Test
void testPutFileShouldSucceedButFails() throws IOException {
byte[] file = new ClassPathResource("img.png").getInputStream().readAllBytes();
String result = given()
.multiPart("files", "test.png", file, MediaType.IMAGE_PNG_VALUE)
.contentType(ContentType.MULTIPART)
.when()
.put("/put-file/{requestId}", "100")
.then()
.statusCode(202)
.extract()
.response().getBody().asString();
assertEquals("ok", result);
}
Expected status code <202> but was <404>
Looks like request path with path params has been parsed incorrectly

And the root cause somewhere in io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl#sendRequest
while invoking io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object...):

Request handler:
Success test
Failing test
Expected status code <202> but was <404>Looks like request path with path params has been parsed incorrectly

And the root cause somewhere in

io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl#sendRequestwhile invoking
io.restassured.module.mockmvc.internal.MockMvcRequestSenderImpl#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object...):