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

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

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

JsonPath.getMap介绍

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

代码示例

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

private void verifyDeploymentWithDefinitionsValues(Deployment mockDeployment, String responseContent) {
 JsonPath path = from(responseContent);
 verifyStandardDeploymentValues(mockDeployment, path);
 Map<String, HashMap<String, Object>> deployedProcessDefinitions = path.getMap(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS);
 Map<String, HashMap<String, Object>> deployedCaseDefinitions = path.getMap(PROPERTY_DEPLOYED_CASE_DEFINITIONS);
 Map<String, HashMap<String, Object>>  deployedDecisionDefinitions = path.getMap(PROPERTY_DEPLOYED_DECISION_DEFINITIONS);
 Map<String, HashMap<String, Object>>  deployedDecisionRequirementsDefinitions = path.getMap(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS);
 assertEquals(1, deployedProcessDefinitions.size());
 assertNotNull(deployedProcessDefinitions.get(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID));
 assertEquals(1, deployedCaseDefinitions.size());
 assertNotNull(deployedCaseDefinitions.get(EXAMPLE_CASE_DEFINITION_ID));
 assertEquals(1, deployedDecisionDefinitions.size());
 assertNotNull(deployedDecisionDefinitions.get(EXAMPLE_DECISION_DEFINITION_ID));
 assertEquals(1, deployedDecisionRequirementsDefinitions.size());
 assertNotNull(deployedDecisionRequirementsDefinitions.get(EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID));
}

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

@Test
public void testGetVariablesWithNullValue() {
 when(caseServiceMock.getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true)).thenReturn(EXAMPLE_VARIABLES_WITH_NULL_VALUE);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY + ".value", nullValue())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY + ".type", equalTo("Null"))
  .when().get(CASE_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
 verify(caseServiceMock).getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true);
}

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

@Test
public void testGetVariables() {
 Response response = given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(String.class.getSimpleName()))
  .when().get(CASE_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
 verify(caseServiceMock).getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true);
}

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

@Test
public void testJavaObjectVariableSerialization() {
 Response response = given().pathParam("id", MockProvider.ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value.property1", equalTo("aPropertyValue"))
  .body(EXAMPLE_VARIABLE_KEY + ".value.property2", equalTo(true))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT)))
  .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ExampleVariableObject.class.getName()))
  .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json"))
  .when().get(PROCESS_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

@Test
public void testJavaObjectVariableSerialization() {
 when(caseServiceMock.getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true)).thenReturn(EXAMPLE_OBJECT_VARIABLES);
 Response response = given().pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value.property1", equalTo("aPropertyValue"))
  .body(EXAMPLE_VARIABLE_KEY + ".value.property2", equalTo(true))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(ValueType.OBJECT)))
  .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_OBJECT_TYPE_NAME, equalTo(ExampleVariableObject.class.getName()))
  .body(EXAMPLE_VARIABLE_KEY + ".valueInfo." + SerializableValueType.VALUE_INFO_SERIALIZATION_DATA_FORMAT, equalTo("application/json"))
  .when().get(CASE_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
 verify(caseServiceMock).getVariablesTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, true);
}

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

@Test
public void testGetLocalVariables() {
 Response response = given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(String.class.getSimpleName()))
  .when().get(EXECUTION_LOCAL_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

@Test
public void testGetVariables() {
 Response response = given().pathParam("id", MockProvider.EXAMPLE_PROCESS_INSTANCE_ID)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(String.class.getSimpleName()))
  .when().get(PROCESS_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

private void verifyDrdDeploymentValues(Deployment mockDeployment, String responseContent) {
 JsonPath path = from(responseContent);
 verifyStandardDeploymentValues(mockDeployment, path);
 Map<String, HashMap<String, Object>>  deployedDecisionDefinitions =
  path.getMap(PROPERTY_DEPLOYED_DECISION_DEFINITIONS);
 Map<String, HashMap<String, Object>> deployedDecisionRequirementsDefinitions =
  path.getMap(PROPERTY_DEPLOYED_DECISION_REQUIREMENTS_DEFINITIONS);
 assertEquals(1, deployedDecisionDefinitions.size());
 HashMap decisionDefinitionDto = deployedDecisionDefinitions.get(EXAMPLE_DECISION_DEFINITION_ID);
 assertNotNull(decisionDefinitionDto);
 verifyDmnDeployment(decisionDefinitionDto);
 assertEquals(1, deployedDecisionRequirementsDefinitions.size());
 HashMap decisionRequirementsDefinitionDto = deployedDecisionRequirementsDefinitions.get(EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID);
 assertNotNull(decisionRequirementsDefinitionDto);
 verifyDrdDeployment(decisionRequirementsDefinitionDto);
 assertNull(path.get(PROPERTY_DEPLOYED_PROCESS_DEFINITIONS));
 assertNull(path.get(PROPERTY_DEPLOYED_CASE_DEFINITIONS));
}

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

@Test
public void testGetVariablesWithNullValue() {
 Response response = given().pathParam("id", EXAMPLE_PROCESS_INSTANCE_ID_WITH_NULL_VALUE_AS_VARIABLE)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY + ".value", nullValue())
  .body(EXAMPLE_ANOTHER_VARIABLE_KEY + ".type", equalTo("Null"))
  .when().get(PROCESS_INSTANCE_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

@Test
public void testGetLocalVariables() {
 when(taskServiceMock.getVariablesLocalTyped(EXAMPLE_TASK_ID, true)).thenReturn(EXAMPLE_VARIABLES);
 Response response = given().pathParam("id", EXAMPLE_TASK_ID)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(EXAMPLE_VARIABLE_VALUE.getType())))
  .when().get(SINGLE_TASK_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

@Test
public void testGetVariables() {
 when(taskServiceMock.getVariablesTyped(EXAMPLE_TASK_ID, true)).thenReturn(EXAMPLE_VARIABLES);
 Response response = given().pathParam("id", EXAMPLE_TASK_ID)
  .header("accept", MediaType.APPLICATION_JSON)
  .then().expect().statusCode(Status.OK.getStatusCode())
  .body(EXAMPLE_VARIABLE_KEY, notNullValue())
  .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
  .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo(VariableTypeHelper.toExpectedValueTypeName(EXAMPLE_VARIABLE_VALUE.getType())))
  .when().get(SINGLE_TASK_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
}

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

.when().get(PROCESS_INSTANCE_ACTIVIY_INSTANCES_URL);
Assert.assertEquals("Should return right number of properties", 11, response.jsonPath().getMap("").size());

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

@Test
public void testGetLocalVariables() {
 Response response = given()
   .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID)
  .then()
   .expect()
    .statusCode(Status.OK.getStatusCode())
    .body(EXAMPLE_VARIABLE_KEY, notNullValue())
    .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
    .body(EXAMPLE_VARIABLE_KEY + ".type", equalTo("String"))
  .when()
   .get(CASE_EXECUTION_LOCAL_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
 verify(caseServiceMock).getVariablesLocalTyped(MockProvider.EXAMPLE_CASE_EXECUTION_ID, true);
}

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

@Test
public void testGetVariables() {
 Response response = given()
   .pathParam("id", MockProvider.EXAMPLE_CASE_EXECUTION_ID)
  .then()
   .expect()
    .statusCode(Status.OK.getStatusCode())
    .body(EXAMPLE_VARIABLE_KEY, notNullValue())
    .body(EXAMPLE_VARIABLE_KEY + ".value", equalTo(EXAMPLE_VARIABLE_VALUE.getValue()))
    .body(EXAMPLE_VARIABLE_KEY + ".type",
      equalTo(VariableTypeHelper.toExpectedValueTypeName(EXAMPLE_VARIABLE_VALUE.getType())))
  .when()
   .get(CASE_EXECUTION_VARIABLES_URL);
 Assert.assertEquals("Should return exactly one variable", 1, response.jsonPath().getMap("").size());
 verify(caseServiceMock).getVariablesTyped(MockProvider.EXAMPLE_CASE_EXECUTION_ID, true);
}

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

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

Map<String,Object> selfReference = from(content).getMap("_links.self");
Assert.assertNotNull(selfReference);
Assert.assertEquals("/task", selfReference.get("href"));

代码示例来源:origin: org.apache.james/james-server-webadmin-data

private void assertBadRequest(String toDomain, Function<RequestSpecification, Response> op) {
    Map<String, Object> errors = op.apply(given().body(toDomain).when())
        .then()
          .statusCode(HttpStatus.BAD_REQUEST_400)
          .contentType(ContentType.JSON)
        .extract()
          .body()
          .jsonPath()
          .getMap(".");
    assertThat(errors)
        .containsEntry("statusCode", HttpStatus.BAD_REQUEST_400)
        .containsEntry("type", "InvalidArgument")
        .hasEntrySatisfying("message", o -> assertThat((String) o).matches("^The domain .* is invalid\\.$"));
  }
}

代码示例来源:origin: org.apache.james/james-server-webadmin-data

@Test
void getNotRegisteredForwardShouldReturnNotFound() {
  Map<String, Object> errors = when()
    .get("unknown@domain.travel")
  .then()
    .statusCode(HttpStatus.NOT_FOUND_404)
    .contentType(ContentType.JSON)
    .extract()
    .body()
    .jsonPath()
    .getMap(".");
  assertThat(errors)
    .containsEntry("statusCode", HttpStatus.NOT_FOUND_404)
    .containsEntry("type", "InvalidArgument")
    .containsEntry("message", "The forward does not exist");
}

相关文章