本文整理汇总了Java中com.jayway.restassured.path.json.JsonPath.get方法的典型用法代码示例。如果您正苦于以下问题:Java JsonPath.get方法的具体用法?Java JsonPath.get怎么用?Java JsonPath.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jayway.restassured.path.json.JsonPath
的用法示例。
在下文中一共展示了JsonPath.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyTaskAttachmentValues
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void verifyTaskAttachmentValues(Attachment mockTaskAttachment, String responseContent, boolean urlExist) {
JsonPath path = from(responseContent);
String returnedId = path.get("id");
String returnedTaskId = path.get("taskId");
String returnedName = path.get("name");
String returnedType = path.get("type");
String returnedDescription = path.get("description");
String returnedUrl = path.get("url");
Attachment mockAttachment = mockTaskAttachments.get(0);
assertEquals(mockAttachment.getId(), returnedId);
assertEquals(mockAttachment.getTaskId(), returnedTaskId);
assertEquals(mockAttachment.getName(), returnedName);
assertEquals(mockAttachment.getType(), returnedType);
assertEquals(mockAttachment.getDescription(), returnedDescription);
if (urlExist) {
assertEquals(mockAttachment.getUrl(), returnedUrl);
}
}
示例2: loadGeneralSettings
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void loadGeneralSettings(JsonPath testSuiteJsonPath) {
Map<String, String> generalSettings = testSuiteJsonPath.get(JSONPATH_GENERAL_SETTINGS);
if (generalSettings.containsKey(JSON_FIELD_HTTP_METHOD)) {
try {
httpMethod = Method.valueOf(generalSettings.get(JSON_FIELD_HTTP_METHOD));
} catch (IllegalArgumentException oEx) {
throw new HeatException("HTTP method '" + generalSettings.get(JSON_FIELD_HTTP_METHOD) + "' not supported");
}
}
if (generalSettings.containsKey(SUITE_DESCRIPTION_PATH)) {
suiteDescription = generalSettings.get(SUITE_DESCRIPTION_PATH);
}
}
示例3: loadPreloadedSection
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void loadPreloadedSection(JsonPath testSuiteJsonPath) {
preloadVariables = testSuiteJsonPath.get(JSONPATH_PRELOAD_SECTION);
if (preloadVariables != null && !preloadVariables.isEmpty()) {
logUtils.debug("PRELOAD VARIABLES PRESENT");
placeholderHandler = new PlaceholderHandler();
for (Map.Entry<String, Object> entry : preloadVariables.entrySet()) {
preloadVariables.put(entry.getKey(), placeholderHandler.placeholderProcessString(entry.getValue().toString()));
logUtils.debug("PRELOADED VARIABLE: '{}' = '{}'", entry.getKey(), entry.getValue());
}
}
}
示例4: getTestCaseIterator
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private Iterator<Object[]> getTestCaseIterator(JsonPath testSuiteJsonPath) {
List<Object> testCases = testSuiteJsonPath.get(JSONPATH_TEST_CASES);
List<Object[]> listOfArray = new ArrayList<>();
for (Iterator<Object> testCasesIterator = testCases.iterator(); testCasesIterator.hasNext();) {
Object[] array = new Object[1];
array[0] = testCasesIterator.next();
listOfArray.add(array);
}
tcArrayIterator = listOfArray.iterator();
return tcArrayIterator;
}
示例5: findDatasetIdFromGlobalId
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
/**
* Assumes you have turned on experimental non-public search
* https://github.com/IQSS/dataverse/issues/1299
*
* curl -X PUT -d true
* http://localhost:8080/api/admin/settings/:SearchApiNonPublicAllowed
*
* @return The Integer found or null.
*/
private static Integer findDatasetIdFromGlobalId(String globalId, String apiToken) {
Response searchForGlobalId = given()
.get("api/search?key=" + apiToken
+ "&q=dsPersistentId:\""
+ globalId.replace(":", "\\:")
+ "\"&show_entity_ids=true");
JsonPath jsonPath = JsonPath.from(searchForGlobalId.body().asString());
int id;
try {
id = jsonPath.get("data.items[0].entity_id");
} catch (IllegalArgumentException ex) {
return null;
}
return id;
}
示例6: getTokenAPI
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private String getTokenAPI() {
Response response = given()
.parameters(Constant.USERNAME, credentials.getAdminUserName(), Constant.PASSWORD,
credentials.getAdminUserPassword(), Constant.AUTHENTICATION, Constant.LOCAL)
.post("/login");
String json = response.asString();
JsonPath jp = new JsonPath(json);
return jp.get(Constant.TOKEN);
}
示例7: createLink
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private String createLink(String url) {
// @formatter:off
JsonPath result = given()
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
.formParameter(PARAMETER_URL, url)
.post("/api/v1" + LinkController.LINKS)
.then()
.statusCode(CREATED.getStatusCode())
.body(PARAMETER_HASH, not(empty()))
.extract().body().jsonPath();
// @formatter:on
return result.get("hash");
}
示例8: getServerIdsForGroup
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
/**
* Given a RHQ Group this will return a the resource Ids in this
* Group.
*
* @param groupId - the group's RHQ id.
* @return a list of resourceIds in this group.
*/
public List<Integer> getServerIdsForGroup(Integer groupId) {
Response response =
given()
.header(acceptJson)
.pathParam("groupId", groupId) //$NON-NLS-1$
.expect()
.statusCode(200)
.when()
.get("/group/{groupId}/resources"); //$NON-NLS-1$
JsonPath jsonPath = response.jsonPath();
List<Integer> resourceIds = jsonPath.get("resourceId"); //$NON-NLS-1$
return resourceIds;
}
示例9: verifyStandardDeploymentValues
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void verifyStandardDeploymentValues(Deployment mockDeployment, JsonPath path) {
String returnedId = path.get("id");
String returnedName = path.get("name");
Date returnedDeploymentTime = DateTimeUtil.parseDate(path.<String>get("deploymentTime"));
assertEquals(mockDeployment.getId(), returnedId);
assertEquals(mockDeployment.getName(), returnedName);
assertEquals(mockDeployment.getDeploymentTime(), returnedDeploymentTime);
}
示例10: verifyDeploymentResource
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void verifyDeploymentResource(Resource mockDeploymentResource, Response response) {
String content = response.asString();
JsonPath path = from(content);
String returnedId = path.get("id");
String returnedName = path.get("name");
String returnedDeploymentId = path.get("deploymentId");
assertEquals(mockDeploymentResource.getId(), returnedId);
assertEquals(mockDeploymentResource.getName(), returnedName);
assertEquals(mockDeploymentResource.getDeploymentId(), returnedDeploymentId);
}
示例11: verifyTaskCommentValues
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void verifyTaskCommentValues(Comment mockTaskComment, String responseContent) {
JsonPath path = from(responseContent);
String returnedId = path.get("id");
String returnedUserId = path.get("userId");
String returnedTaskId = path.get("taskId");
Date returnedTime = DateTimeUtil.parseDate(path.<String>get("time"));
String returnedFullMessage = path.get("message");
assertEquals(mockTaskComment.getId(), returnedId);
assertEquals(mockTaskComment.getTaskId(), returnedTaskId);
assertEquals(mockTaskComment.getUserId(), returnedUserId);
assertEquals(mockTaskComment.getTime(), returnedTime);
assertEquals(mockTaskComment.getFullMessage(), returnedFullMessage);
}
示例12: loadJsonSchemaForOutputValidation
import com.jayway.restassured.path.json.JsonPath; //导入方法依赖的package包/类
private void loadJsonSchemaForOutputValidation(JsonPath testSuiteJsonPath) {
jsonSchemas = testSuiteJsonPath.get(JSONPATH_JSONSCHEMAS);
}