查询参数不解码

时间:2017-09-13 08:02:01

标签: java json rest web-services

我有这条路径将从firefox Rest客户端发送到java Rest

http://localhost:8080/rest/resources/grouped?filter=%7B%22boolValue%22%3Atrue%2C%22id%22%3A25%2C%22filterType%22%3A32%7D&filter=%7B%22id%22%3A47%2C%22filterType%22%3A57%2C%22multiValue%22%3A%5B40%2C39%2C37%2C38%2C23%2C24%5D%7D&filter=%7B%22id%22%3A18%2C%22filterType%22%3A89%2C%22multiValue%22%3A%5B3%5D%7D&organizeBy=designation&pageNo=1&pageSize=10

并查询后面的params数据?正在转变为 {"boolValue":true,"id":25,"filterType":32}这是必需的,但是当我从测试用例方法发送相同数据时,它没有解码。它将与编码

相同

测试用例方法是

@RunAsClient
@Test(description = "Filter resources by exp(exp6, exp5, exp3, exp4, exp1, exp2), archive(include) and roles(manager) and organize by designation using page no 1 and page size 10.")
public void shouldFilterResByExpArcRolesWhenOrgByDesigUsingPageNo1AndPageSize10() {
    given().spec(spec)
        .get("/resources/grouped?filter=%7B%22boolValue%22%3Atrue%2C%22id%22%3A25%2C%22filterType%22%3A32%7D&filter=%7B%22id%22%3A47%2C%22filterType%22%3A57%2C%22multiValue%22%3A%5B40%2C39%2C37%2C38%2C23%2C24%5D%7D&filter=%7B%22id%22%3A18%2C%22filterType%22%3A89%2C%22multiValue%22%3A%5B3%5D%7D&organizeBy=designation&pageNo=1&pageSize=10")
        .then()
        .assertThat()
        .body("totalcount", equalTo(2))
        .body("resourceGroups.size()", equalTo(2))
        .body("resourceGroups[0].grplength", equalTo(1))
        .body("resourceGroups[1].grplength", equalTo(1))
        .body("resourceGroups[0].resources[0].name", equalTo("Jayden Brock"))
        .body("resourceGroups[1].resources[0].name", equalTo("Chris Rose"))
        .statusCode(HttpStatus.SC_OK);

问题是什么?

是RestAPI

@GET
@Path("/grouped")
@Produces(MediaType.APPLICATION_JSON)
public Response listGroupedData(@QueryParam(Constants.PARAM_FILTER) List<MapRequestParam> filtersParams,
        @QueryParam(Constants.PARAM_ORGANIZE_BY) String organiseBy,
        @QueryParam(Constants.PARAM_PAGE_NO) Integer pageNo,
        @QueryParam(Constants.PARAM_PAGE_SIZE) Integer pageSize) throws RBaseException

以下是MapRequestParam

public class MapRequestParam {

ObjectMapper mapper = new ObjectMapper();
String jsonstr;

public MapRequestParam(String jsonstr) {
    this.jsonstr = jsonstr;
}

public Map<String, Object> getMap() throws JsonParseException, JsonMappingException, IOException {
    return mapper.readValue(this.jsonstr, new TypeReference<Map<String, Object>>() {});
}
}

我在MaprequestParam构造函数中编码了params not decoding params

0 个答案:

没有答案