我想测试一个 API(Post 方法)。我必须通过更改所有可用参数来测试这个 API。对于测试用例 1 中的 EG,我只更改用户名,在测试用例 2 中,我只更改密码,以后再更改。
我的 API 如下所示:
{
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ibm:params:scim:schemas:extension:bean:agc:2.0:User"
],
"name": {
},
"userName": "GROUPTEST12134",
"password": "Asdfg12@sdd",
"emails": [{
"value": "steve.hok123@awe.com"
}],
"phoneNumbers": [{
"value": "70422330098"
}],
"urn:ibm:params:scim:schemas:extension:bean:agc:2.0:User": {
}
}
我可以通过以下方法成功测试它:
String urlParameters = "{\"schemas\": [\"urn:ietf:params:scim:schemas:core:2.0:User\",\"urn:ibm:params:scim:schemas:extension:bean:agc:2.0:User\"],\"name\": {},\"userName\": \"GROUPTEST12138\",\"password\": \"Asdfg12@sdd\",\"emails\": [{\"value\": \"steve.hok1234@awe.com\"}],\"phoneNumbers\": [{\"value\": \"\"}],\"urn:ibm:params:scim:schemas:extension:bean:agc:2.0:User\": {}}";
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setDoOutput(true);
con.setRequestMethod("PUT");
con.setRequestProperty("Content-Type", "application/scim+json");
con.setRequestProperty("Accept", "application/scim+json");
con.setRequestProperty("realm", "Ideas");
con.setRequestProperty("Authorization", "Bearer " + BearerToken);
但我正在寻找一些我不必管理这个的方法 urlParameters
。
您能否请一些想法如何实现?