forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue1599.java
More file actions
52 lines (41 loc) · 1.37 KB
/
Copy pathIssue1599.java
File metadata and controls
52 lines (41 loc) · 1.37 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
package io.jooby;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Issue1599 {
@ServerTest
public void issue1599(ServerTestRunner runner) {
runner.define(app -> {
app.path("/1599", () -> {
app.get("/", ctx -> {
return toMap(ctx.getRoute());
}).tags("local");
app.get("/{id}", ctx -> {
return toMap(ctx.getRoute());
}).attribute("foo", "foo");
})
.produces(MediaType.html)
.attribute("foo", "bar")
.tags("top")
.summary("1599 API");
}).ready(client -> {
client.get("/1599", rsp -> {
assertEquals("{foo=bar, produces=[text/html], consumes=[], tags=[local, top], summary=null}", rsp.body().string());
});
client.get("/1599/123", rsp -> {
assertEquals("{foo=foo, produces=[text/html], consumes=[], tags=[top], summary=null}", rsp.body().string());
});
});
}
private Object toMap(Route route) {
Map<String, Object> map = new LinkedHashMap<>();
map.putAll(route.getAttributes());
map.put("produces", route.getProduces());
map.put("consumes", route.getConsumes());
map.put("tags", route.getTags());
map.put("summary", route.getSummary());
return map;
}
}