Skip to content

Commit

Permalink
fix the defect json cannot handle simple array response
Browse files Browse the repository at this point in the history
  • Loading branch information
JakimLi committed Nov 20, 2019
1 parent 38d4d88 commit 7f38157
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static Map<String, Object> jsonToMap(String content) throws IOException {
});
}

public static List<Map<String, Object>> jsonToList(String content) throws IOException {
public static List<Object> jsonToList(String content) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(content, new TypeReference<List<Map<String, Object>>>() {
return objectMapper.readValue(content, new TypeReference<List<Object>>() {
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public void mock() {
))
.response(text("response"));

server.server()
.get(by(uri("/codes")))
.response(json(newArrayList("ER", "AC", "WB")));

server.server()
.get(and(
by(uri("/cookie")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ Feature: verify json
"""
* verify: '$' same json: responses/jakim.json

Scenario: string array with same json
* uri: /codes
* send: get
* response body:
"""
["ER","AC","WB"]
"""
* verify: '$' same json:
"""
["ER", "AC", "WB"]
"""
* verify: '$' has size: 3


Scenario: same json: with array different order
* uri: /users/list
Expand Down

0 comments on commit 7f38157

Please sign in to comment.