本文整理了Java中io.restassured.path.json.JsonPath.from()
方法的一些代码示例,展示了JsonPath.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPath.from()
方法的具体详情如下:
包路径:io.restassured.path.json.JsonPath
类名称:JsonPath
方法名:from
[英]Instantiate a new JsonPath instance.
[中]实例化一个新的JsonPath实例。
代码示例来源:origin: camunda/camunda-bpm-platform
public static JsonPath from(String json) {
return JsonPath.from(json).using(new DefaultJackson2ObjectMapperFactory() {
public ObjectMapper create(Class cls, String charset) {
return JacksonConfigurator.configureObjectMapper(super.create(cls, charset));
}
});
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyDeploymentValues(Deployment mockDeployment, String responseContent) {
JsonPath path = from(responseContent);
verifyStandardDeploymentValues(mockDeployment, path);
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void checkProcessInstanceResult(String content, int idx) {
//resultType should be set to process definition
String resultType = from(content).get("[" + idx + "].resultType");
Assert.assertEquals(MessageCorrelationResultType.ProcessDefinition.name(), resultType);
//process instance should be filled and execution should be null
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, from(content).get("[" + idx + "].processInstance.id"));
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, from(content).get("[" + idx + "].processInstance.definitionId"));
Assert.assertNull(from(content).get("[" + idx + "].execution"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void checkResult(String content) {
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, from(content).get("[" + 0 + "].id"));
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, from(content).get("[" + 0+ "].definitionId"));
Assert.assertEquals(MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID, from(content).get("[" + 1 + "].id"));
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, from(content).get("[" + 1+ "].definitionId"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void checkExecutionResult(String content, int idx) {
//resultType should be execution
String resultType = from(content).get("[" + idx + "].resultType").toString();
assertEquals(MessageCorrelationResultType.Execution.name(), resultType);
//execution should be filled and process instance should be null
assertEquals(MockProvider.EXAMPLE_EXECUTION_ID, from(content).get("[" + idx + "].execution.id"));
assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, from(content).get("[" + idx + "].execution.processInstanceId"));
assertNull(from(content).get("[" + idx + "].processInstance"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void verifyExampleUserResponse(Response response) {
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one user returned.", 1, instances.size());
Assert.assertNotNull("The returned user should not be null.", instances.get(0));
String returendLastName = from(content).getString("[0].lastName");
String returnedFirstName = from(content).getString("[0].firstName");
String returnedEmail = from(content).getString("[0].email");
Assert.assertEquals(MockProvider.EXAMPLE_USER_FIRST_NAME, returnedFirstName);
Assert.assertEquals(MockProvider.EXAMPLE_USER_LAST_NAME, returendLastName);
Assert.assertEquals(MockProvider.EXAMPLE_USER_EMAIL, returnedEmail);
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyDeploymentLink(Deployment mockDeployment, String responseContent) {
List<Map<String, String>> returnedLinks = from(responseContent).getList("links");
assertEquals(1, returnedLinks.size());
Map<String, String> returnedLink = returnedLinks.get(0);
assertEquals(HttpMethod.GET, returnedLink.get("method"));
assertTrue(returnedLink.get("href").endsWith(RESOURCE_URL + "/" + mockDeployment.getId()));
assertEquals("self", returnedLink.get("rel"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyTaskCommentLink(Comment mockTaskComment, String responseContent) {
List<Map<String, String>> returnedLinks = from(responseContent).getList("links");
assertEquals(1, returnedLinks.size());
Map<String, String> returnedLink = returnedLinks.get(0);
assertEquals(HttpMethod.GET, returnedLink.get("method"));
assertTrue(returnedLink.get("href").endsWith(SINGLE_TASK_COMMENTS_URL.replace("{id}", mockTaskComment.getTaskId()) + "/" + mockTaskComment.getId()));
assertEquals("self", returnedLink.get("rel"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyTaskAttachmentLink(Attachment mockTaskAttachment, String responseContent) {
List<Map<String, String>> returnedLinks = from(responseContent).getList("links");
assertEquals(1, returnedLinks.size());
Map<String, String> returnedLink = returnedLinks.get(0);
assertEquals(HttpMethod.GET, returnedLink.get("method"));
assertTrue(returnedLink.get("href").endsWith(SINGLE_TASK_ATTACHMENTS_URL.replace("{id}", mockTaskAttachment.getTaskId()) + "/" + mockTaskAttachment.getId()));
assertEquals("self", returnedLink.get("rel"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyTenantIdListParameterResponse(Response response) {
String content = response.asString();
List<String> historicDetails = from(content).getList("");
assertThat(historicDetails).hasSize(4);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
String returnedTenantId3 = from(content).getString("[2].tenantId");
String returnedTenantId4 = from(content).getString("[3].tenantId");
assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
assertThat(returnedTenantId3).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
assertThat(returnedTenantId4).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyCmmnDeploymentValues(Deployment mockDeployment, String responseContent) {
JsonPath path = from(responseContent);
verifyStandardDeploymentValues(mockDeployment, path);
Map<String, HashMap<String, Object>> deployedCaseDefinitions = path.getMap(PROPERTY_DEPLOYED_CASE_DEFINITIONS);
assertEquals(1, deployedCaseDefinitions.size());
HashMap caseDefinitionDto = deployedCaseDefinitions.get(EXAMPLE_CASE_DEFINITION_ID);
assertNotNull(caseDefinitionDto);
verifyCmnDeployment(caseDefinitionDto);
assertNull(path.get(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS));
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyDmnDeploymentValues(Deployment mockDeployment, String responseContent) {
JsonPath path = from(responseContent);
verifyStandardDeploymentValues(mockDeployment, path);
Map<String, HashMap<String, Object>> deployedDecisionDefinitions = path.getMap(PROPERTY_DEPLOYED_DECISION_DEFINITIONS);
assertEquals(1, deployedDecisionDefinitions.size());
HashMap decisionDefinitionDto = deployedDecisionDefinitions.get(EXAMPLE_DECISION_DEFINITION_ID);
assertNotNull(decisionDefinitionDto);
verifyDmnDeployment(decisionDefinitionDto);
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_CASE_DEFINITIONS));
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyBpmnDeploymentValues(Deployment mockDeployment, String responseContent) {
JsonPath path = from(responseContent);
verifyStandardDeploymentValues(mockDeployment, path);
Map<String, HashMap<String, Object>> deployedProcessDefinitionDtos = path.getMap(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS);
assertEquals(1, deployedProcessDefinitionDtos.size());
HashMap processDefinitionDto = deployedProcessDefinitionDtos.get(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
assertNotNull(processDefinitionDto);
verifyBpmnDeployment(processDefinitionDto);
assertNull(path.get(PROPERTY_DEPLOYED_CASE_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testCaseActivityIdListParameter() {
Response response = given()
.queryParam("caseActivityIdIn", MockProvider.EXAMPLE_CASE_ACTIVITY_ID_LIST)
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.get(HISTORIC_CASE_INSTANCE_RESOURCE_URL);
verify(mockedQuery).caseActivityIdIn(MockProvider.EXAMPLE_CASE_ACTIVITY_ID, MockProvider.ANOTHER_EXAMPLE_CASE_ACTIVITY_ID);
verify(mockedQuery).list();
String content = response.asString();
List<String> historicCaseInstances = from(content).getList("");
assertThat(historicCaseInstances).hasSize(1);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testIncompleteExecution() {
setUpMockExecutionQuery(createIncompleteMockExecutions());
Response response = expect().statusCode(Status.OK.getStatusCode())
.when().get(EXECUTION_QUERY_URL);
String content = response.asString();
String returnedProcessInstanceId = from(content).getString("[0].processInstanceId");
Assert.assertNull("Should be null, as it is also null in the original execution on the server.",
returnedProcessInstanceId);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testIncompleteProcessDefinition() {
setUpMockDefinitionQuery(createIncompleteMockDefinitions());
Response response = expect().statusCode(Status.OK.getStatusCode())
.when().get(PROCESS_DEFINITION_QUERY_URL);
String content = response.asString();
String returnedResourceName = from(content).getString("[0].resource");
Assert.assertNull("Should be null, as it is also null in the original process definition on the server.",
returnedResourceName);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Test
public void testIncompleteProcessInstance() {
setUpMockInstanceQuery(createIncompleteMockInstances());
Response response = expect().statusCode(Status.OK.getStatusCode())
.when().get(PROCESS_INSTANCE_QUERY_URL);
String content = response.asString();
String returnedBusinessKey = from(content).getString("[0].businessKey");
Assert.assertNull("Should be null, as it is also null in the original process instance on the server.",
returnedBusinessKey);
}
代码示例来源:origin: camunda/camunda-bpm-platform
private void verifyDeploymentValuesEmptyDefinitions(Deployment mockDeployment, String responseContent) {
JsonPath path = from(responseContent);
verifyStandardDeploymentValues(mockDeployment, path);
assertNull(path.get(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_CASE_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_DEFINITIONS));
assertNull(path.get(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS));
}
代码示例来源:origin: camunda/camunda-bpm-platform
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);
}
代码示例来源:origin: camunda/camunda-bpm-platform
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);
}
内容来源于网络,如有侵权,请联系作者删除!