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)); }
@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); }
@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); }
@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()); }
@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); }
@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()); }
@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()); }
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)); }
@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()); }
@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()); }
@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()); }
.when().get(PROCESS_INSTANCE_ACTIVIY_INSTANCES_URL); Assert.assertEquals("Should return right number of properties", 11, response.jsonPath().getMap("").size());
@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); }
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)); }
@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); }
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)); }
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)); }
Map<String,Object> selfReference = from(content).getMap("_links.self"); Assert.assertNotNull(selfReference); Assert.assertEquals("/task", selfReference.get("href"));
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\\.$")); } }
@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"); }