forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue2325.java
More file actions
59 lines (52 loc) · 1.62 KB
/
Copy pathIssue2325.java
File metadata and controls
59 lines (52 loc) · 1.62 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package io.jooby.i2325;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.UUID;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
public class Issue2325 {
@ServerTest
public void shouldNamedParamWorkWithCustomValueConverter(ServerTestRunner runner) {
runner.define(app -> {
app.converter(new VC2325());
app.mvc(new C2325());
}).ready(http -> {
UUID uuid = UUID.randomUUID();
// With custom converter
http.get("/2325?id=" + uuid, rsp -> {
assertEquals("MyID:" + uuid, rsp.body().string());
});
// With bean converter
http.get("/2325?value=" + uuid, rsp -> {
assertEquals("MyID:" + uuid, rsp.body().string());
});
});
}
@ServerTest
public void shouldFailToConvertWithoutCustomConverter(ServerTestRunner runner) {
runner.define(app -> {
app.mvc(new C2325());
app.error((ctx, cause, code) -> {
ctx.send(cause.getMessage());
});
}).ready(http -> {
UUID uuid = UUID.randomUUID();
// Fail don't know what to do with: id
http.get("/2325?id=" + uuid, rsp -> {
assertEquals("Cannot convert value: 'id', to: '" + MyID2325.class.getName() + "'",
rsp.body().string());
});
});
}
@ServerTest
public void shouldConvertUsingBeanConverter(ServerTestRunner runner) {
runner.define(app -> {
app.mvc(new C2325());
}).ready(http -> {
UUID uuid = UUID.randomUUID();
// With bean converter
http.get("/2325?value=" + uuid, rsp -> {
assertEquals("MyID:" + uuid, rsp.body().string());
});
});
}
}