use of org.apache.http.entity.StringEntity 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"));
}
use of org.apache.http.entity.StringEntity 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());
}
use of org.apache.http.entity.StringEntity 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"));
}
use of org.apache.http.entity.StringEntity in project Activiti by Activiti.
the class ExecutionResourceTest method testIllegalExecutionAction.
/**
* Test executing an illegal action on an execution.
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testIllegalExecutionAction() throws Exception {
Execution execution = runtimeService.startProcessInstanceByKey("processOne");
assertNotNull(execution);
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "badaction");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, execution.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_BAD_REQUEST);
closeResponse(response);
}
use of org.apache.http.entity.StringEntity in project Activiti by Activiti.
the class ProcessInstanceCollectionResourceTest method testStartProcessExceptions.
/**
* Test starting a process instance, covering all edge-cases.
*/
public void testStartProcessExceptions() throws Exception {
ObjectNode requestNode = objectMapper.createObjectNode();
// Try starting without id and key
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION));
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
// Try starting with both id and key
requestNode = objectMapper.createObjectNode();
requestNode.put("processDefinitionId", "123");
requestNode.put("processDefinitionKey", "456");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
// Try starting with both message and key
requestNode = objectMapper.createObjectNode();
requestNode.put("processDefinitionId", "123");
requestNode.put("message", "456");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
// Try starting with unexisting process definition key
requestNode = objectMapper.createObjectNode();
requestNode.put("processDefinitionKey", "123");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
// Try starting with unexisting process definition id
requestNode = objectMapper.createObjectNode();
requestNode.put("processDefinitionId", "123");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
// Try starting with unexisting message
requestNode = objectMapper.createObjectNode();
requestNode.put("message", "unexistingmessage");
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
}
Aggregations