【发布时间】:2017-09-29 17:13:47
【问题描述】:
我有一个简单的测试,我正在测试 json 的 POST 是否成功。这是我的测试:
int expectedCodeResponse = 201;
Map<String, String> params = new HashMap<String, String>();
params.put("batchPublicId", "001");
params.put("fileSize", "2");
params.put("location", "{\\\"bucket\\\":\\\"blabla\\\"}");
params.put("title", "testInvoice");
JSONObject parameter = new JSONObject(params);
OkHttpClient httpClient = new OkHttpClient();
RequestBody body = RequestBody.create(JSON, parameter.toString());
Request request = new Request.Builder()
.url(environmentUrls.get("base_url") + "/invoices")
.post(body)
.addHeader("content-type", "application/json; charset=utf-8")
.build();
Response response = httpClient.newCall(request).execute();
Assert.assertEquals(response.code(), expectedCodeResponse);
现在它不再起作用了,因为 fileSize 不再是 String,而是 int。我该如何解决这个问题?
【问题讨论】: