Skip to content

Commit 1da71c5

Browse files
committed
document bean handling of empty/missing params
1 parent 6f48550 commit 1da71c5

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.jooby.issues;
2+
3+
import java.util.Optional;
4+
5+
import org.jooby.Parser;
6+
import org.jooby.test.ServerFeature;
7+
import org.junit.Test;
8+
9+
public class Issue483 extends ServerFeature {
10+
11+
public static class NullableBean {
12+
13+
String foo;
14+
15+
Optional<String> bar;
16+
17+
@Override
18+
public String toString() {
19+
return foo + bar;
20+
}
21+
}
22+
23+
{
24+
parser(Parser.bean(true));
25+
26+
get("/483", req -> {
27+
return req.params(NullableBean.class).toString();
28+
});
29+
30+
}
31+
32+
@Test
33+
public void documentNullBeanInjection() throws Exception {
34+
request()
35+
.get("/483?foo=foo")
36+
.expect("foonull");
37+
38+
request()
39+
.get("/483?foo=foo&bar")
40+
.expect("fooOptional[]");
41+
42+
request()
43+
.get("/483?foo=foo&bar=bar")
44+
.expect("fooOptional[bar]");
45+
}
46+
47+
}

0 commit comments

Comments
 (0)