forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue2352.java
More file actions
44 lines (38 loc) · 1.3 KB
/
Copy pathIssue2352.java
File metadata and controls
44 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package io.jooby.i2352;
import static org.junit.jupiter.api.Assertions.assertEquals;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
import okhttp3.MultipartBody;
public class Issue2352 {
@ServerTest
public void shouldNotIgnoreAnnotationOnParam(ServerTestRunner runner) {
runner.define(app -> {
app.mvc(new C2352());
app.error((ctx, cause, code) -> {
ctx.send(cause.getMessage());
});
}).ready(http -> {
String name = getClass().getSimpleName();
http.post("/2352/nonnull", new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("noname", name)
.build(), rsp -> {
assertEquals(400, rsp.code());
assertEquals("Missing value: 'name'", rsp.body().string());
});
http.post("/2352/nonnull", new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("name", name)
.build(), rsp -> {
assertEquals(name, rsp.body().string());
});
http.post("/2352/nullable", new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("noname", name)
.build(), rsp -> {
assertEquals(200, rsp.code());
assertEquals("null", rsp.body().string());
});
});
}
}