Search in sources :

Example 26 with ObjectNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.

the class ProcessDefinitionResourceTest method testIllegalAction.

/**
   * Test executing an unexisting action.
   * 
   * POST repository/process-definitions/{processDefinitionId}
   */
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testIllegalAction() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertFalse(processDefinition.isSuspended());
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "unexistingaction");
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_BAD_REQUEST);
    closeResponse(response);
}
Also used : StringEntity(org.apache.http.entity.StringEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) HttpPut(org.apache.http.client.methods.HttpPut) Deployment(org.activiti.engine.test.Deployment)

Example 27 with ObjectNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.

the class ProcessDefinitionResourceTest method testSuspendProcessDefinitionDelayed.

/**
   * Test suspending a process definition on a certain date.
   * POST repository/process-definitions/{processDefinitionId}
   */
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendProcessDefinitionDelayed() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertFalse(processDefinition.isSuspended());
    ObjectNode requestNode = objectMapper.createObjectNode();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR, 2);
    // Format the date using ISO date format
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    String dateString = formatter.print(cal.getTimeInMillis());
    requestNode.put("action", "suspend");
    requestNode.put("date", dateString);
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
    // Check "OK" status
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertTrue(responseNode.get("suspended").booleanValue());
    // Check if process-definition is not yet suspended
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertFalse(processDefinition.isSuspended());
    // Force suspension by altering time
    cal.add(Calendar.HOUR, 1);
    processEngineConfiguration.getClock().setCurrentTime(cal.getTime());
    waitForJobExecutorToProcessAllJobs(5000, 100);
    // Check if process-definition is suspended
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertTrue(processDefinition.isSuspended());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Calendar(java.util.Calendar) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) HttpPut(org.apache.http.client.methods.HttpPut) Deployment(org.activiti.engine.test.Deployment)

Example 28 with ObjectNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.

the class ExecutionCollectionResourceTest method testSignalEventExecutionsWithvariables.

/**
   * Test signalling all executions with variables
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal-event.bpmn20.xml" })
public void testSignalEventExecutionsWithvariables() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
    ArrayNode variables = objectMapper.createArrayNode();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signalEventReceived");
    requestNode.put("signalName", "alert");
    requestNode.put("variables", variables);
    ObjectNode varNode = objectMapper.createObjectNode();
    variables.add(varNode);
    varNode.put("name", "myVar");
    varNode.put("value", "Variable set when signal event is receieved");
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPut, HttpStatus.SC_NO_CONTENT));
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
    Map<String, Object> vars = runtimeService.getVariables(waitingExecution.getId());
    assertEquals(1, vars.size());
    assertEquals("Variable set when signal event is receieved", vars.get("myVar"));
}
Also used : StringEntity(org.apache.http.entity.StringEntity) Execution(org.activiti.engine.runtime.Execution) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) HttpPut(org.apache.http.client.methods.HttpPut) Deployment(org.activiti.engine.test.Deployment)

Example 29 with ObjectNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.

the class ExecutionCollectionResourceTest method testSignalEventExecutions.

/**
   *  Test signalling all executions
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal-event.bpmn20.xml" })
public void testSignalEventExecutions() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signalEventReceived");
    requestNode.put("signalName", "alert");
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_COLLECTION));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPut, HttpStatus.SC_NO_CONTENT));
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
}
Also used : StringEntity(org.apache.http.entity.StringEntity) Execution(org.activiti.engine.runtime.Execution) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HttpPut(org.apache.http.client.methods.HttpPut) Deployment(org.activiti.engine.test.Deployment)

Example 30 with ObjectNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode in project Activiti by Activiti.

the class ExecutionResourceTest method testSignalEventExecutionWithvariables.

/**
   * Test signalling a single execution, with signal event.
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-signal-event.bpmn20.xml" })
public void testSignalEventExecutionWithvariables() throws Exception {
    Execution signalExecution = runtimeService.startProcessInstanceByKey("processOne");
    assertNotNull(signalExecution);
    ArrayNode variables = objectMapper.createArrayNode();
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "signalEventReceived");
    requestNode.put("signalName", "alert");
    requestNode.put("variables", variables);
    ObjectNode varNode = objectMapper.createObjectNode();
    variables.add(varNode);
    varNode.put("name", "myVar");
    varNode.put("value", "Variable set when signal event is receieved");
    Execution waitingExecution = runtimeService.createExecutionQuery().activityId("waitState").singleResult();
    assertNotNull(waitingExecution);
    // Sending signal event causes the execution to end (scope-execution for the catching event)
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, waitingExecution.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
    // Check if process is moved on to the other wait-state
    waitingExecution = runtimeService.createExecutionQuery().activityId("anotherWaitState").singleResult();
    assertNotNull(waitingExecution);
    assertEquals(signalExecution.getId(), waitingExecution.getId());
    Map<String, Object> vars = runtimeService.getVariables(waitingExecution.getId());
    assertEquals(1, vars.size());
    assertEquals("Variable set when signal event is receieved", vars.get("myVar"));
}
Also used : StringEntity(org.apache.http.entity.StringEntity) Execution(org.activiti.engine.runtime.Execution) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) HttpPut(org.apache.http.client.methods.HttpPut) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2465 JsonNode (com.fasterxml.jackson.databind.JsonNode)564 Test (org.junit.Test)559 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)514 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)379 IOException (java.io.IOException)221 ArrayList (java.util.ArrayList)123 Map (java.util.Map)111 HashMap (java.util.HashMap)107 List (java.util.List)98 StringEntity (org.apache.http.entity.StringEntity)94 Deployment (org.activiti.engine.test.Deployment)85 Test (org.testng.annotations.Test)81 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)69 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)65 HttpPost (org.apache.http.client.methods.HttpPost)57 AbstractRpcLwM2MIntegrationTest (org.thingsboard.server.transport.lwm2m.rpc.AbstractRpcLwM2MIntegrationTest)54 TextNode (com.fasterxml.jackson.databind.node.TextNode)52 File (java.io.File)51 Task (org.activiti.engine.task.Task)51