io.restassured.path.json.JsonPath.getString()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中io.restassured.path.json.JsonPath.getString()方法的一些代码示例,展示了JsonPath.getString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPath.getString()方法的具体详情如下:
包路径:io.restassured.path.json.JsonPath
类名称:JsonPath
方法名:getString

JsonPath.getString介绍

[英]Get the result of an Object path expression as a string.
[中]以字符串形式获取对象路径表达式的结果。

代码示例

代码示例来源: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 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

@Test
public void tenantRetrieval() {
 String name = MockProvider.EXAMPLE_TENANT_NAME;
 Response response = given().queryParam("name", name)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .when().get(QUERY_URL);
 InOrder inOrder = inOrder(mockQuery);
 inOrder.verify(mockQuery).tenantName(name);
 inOrder.verify(mockQuery).list();
 String content = response.asString();
 List<String> instances = from(content).getList("");
 assertThat(instances.size(), is(1));
 String returnedId = from(content).getString("[0].id");
 String returnedName = from(content).getString("[0].name");
 assertThat(returnedId, is(MockProvider.EXAMPLE_TENANT_ID));
 assertThat(returnedName, is(MockProvider.EXAMPLE_TENANT_NAME));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testSimpleGroupQuery() {
 String queryName = MockProvider.EXAMPLE_GROUP_NAME;
 Response response = given().queryParam("name", queryName)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .when().get(GROUP_QUERY_URL);
 InOrder inOrder = inOrder(mockQuery);
 inOrder.verify(mockQuery).groupName(queryName);
 inOrder.verify(mockQuery).list();
 String content = response.asString();
 List<String> instances = from(content).getList("");
 Assert.assertEquals("There should be one group returned.", 1, instances.size());
 Assert.assertNotNull("The returned group should not be null.", instances.get(0));
 String returendName = from(content).getString("[0].name");
 String returendType = from(content).getString("[0].type");
 Assert.assertEquals(MockProvider.EXAMPLE_GROUP_NAME, returendName);
 Assert.assertEquals(MockProvider.EXAMPLE_GROUP_TYPE, returendType);
}

代码示例来源: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

@Test
public void testWithoutTenantIdPostParameter() {
 Map<String, Object> queryParameters = new HashMap<String, Object>();
 queryParameters.put("withoutTenantId", true);
 Response response = given()
   .contentType(POST_JSON_CONTENT_TYPE)
   .body(queryParameters)
 .expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .post(JOB_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> jobs = from(content).getList("");
 assertThat(jobs).hasSize(1);
 String returnedTenantId = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testWithoutTenantIdParameter() {
 mockedQuery = setUpMockCaseInstanceQuery(Arrays.asList(MockProvider.createMockCaseInstance(null)));
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(CASE_INSTANCE_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> caseInstances = from(content).getList("");
 assertThat(caseInstances).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testTenantIdListParameter() {
 mockedQuery = setUpMockDefinitionQuery(createMockJobDefinitionsTwoTenants());
 Response response = given()
  .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(JOB_DEFINITION_QUERY_URL);
 verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> jobs = from(content).getList("");
 assertThat(jobs).hasSize(2);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 String returnedTenantId2 = from(content).getString("[1].tenantId");
 assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
 assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testTenantIdListParameter() {
 mockedQuery = setUpMockCaseInstanceQuery(createMockCaseInstancesTwoTenants());
 Response response = given()
  .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(CASE_INSTANCE_QUERY_URL);
 verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> caseInstances = from(content).getList("");
 assertThat(caseInstances).hasSize(2);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 String returnedTenantId2 = from(content).getString("[1].tenantId");
 assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
 assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testWithoutTenantIdParameter() {
 mockedQuery = setUpMockHistoricProcessInstanceQuery(Collections.singletonList(MockProvider.createMockHistoricProcessInstance(null)));
 Response response = given()
  .queryParam("withoutTenantId", true)
  .then().expect()
  .statusCode(Status.OK.getStatusCode())
  .when()
  .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testWithoutTenantIdParameter() {
 mockedQuery = setUpMockHistoricCaseInstanceQuery(Arrays.asList(MockProvider.createMockHistoricCaseInstance(null)));
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testWithoutTenantIdParameter() {
 mockedQuery = setUpMockInstanceQuery(Arrays.asList(MockProvider.createMockInstance(null)));
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(PROCESS_INSTANCE_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testDecisionDefinitionWithoutTenantId() {
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(DECISION_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testDecisionRequirementsDefinitionWithoutTenantId() {
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(DECISION_REQUIREMENTS_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testWithoutTenantIdParameter() {
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(JOB_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> jobs = from(content).getList("");
 assertThat(jobs).hasSize(1);
 String returnedTenantId = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testProcessDefinitionWithoutTenantId() {
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(PROCESS_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testCaseDefinitionWithoutTenantId() {
 Response response = given()
  .queryParam("withoutTenantId", true)
 .then().expect()
  .statusCode(Status.OK.getStatusCode())
 .when()
  .get(CASE_DEFINITION_QUERY_URL);
 verify(mockedQuery).withoutTenantId();
 verify(mockedQuery).list();
 String content = response.asString();
 List<String> definitions = from(content).getList("");
 assertThat(definitions).hasSize(1);
 String returnedTenantId1 = from(content).getString("[0].tenantId");
 assertThat(returnedTenantId1).isEqualTo(null);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testTaskCountByCandidateGroupReport() {
 Response response = given()
  .then()
  .expect()
  .statusCode(Status.OK.getStatusCode())
  .contentType(ContentType.JSON)
  .when()
  .get(CANDIDATE_GROUP_REPORT_URL);
 String content = response.asString();
 List<String> reports = from(content).getList("");
 Assert.assertEquals("There should be one report returned.", 1, reports.size());
 Assert.assertNotNull("The returned report should not be null.", reports.get(0));
 String returnedGroup = from(content).getString("[0].groupName");
 int returnedCount = from(content).getInt("[0].taskCount");
 Assert.assertEquals(EXAMPLE_GROUP_ID, returnedGroup);
 Assert.assertEquals(EXAMPLE_TASK_COUNT_BY_CANDIDATE_GROUP, returnedCount);
}

相关文章