use of org.activiti.engine.test.Deployment 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.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ExecutionResourceTest method testGetExecution.
/**
* Test getting a single execution.
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testGetExecution() throws Exception {
Execution parentExecution = runtimeService.startProcessInstanceByKey("processOne");
Execution childExecution = runtimeService.createExecutionQuery().activityId("processTask").singleResult();
assertNotNull(childExecution);
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())), HttpStatus.SC_OK);
// Check resulting parent execution
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(parentExecution.getId(), responseNode.get("id").textValue());
assertTrue(responseNode.get("activityId").isNull());
assertFalse(responseNode.get("suspended").booleanValue());
assertTrue(responseNode.get("parentUrl").isNull());
assertFalse(responseNode.get("suspended").booleanValue());
assertTrue(responseNode.get("url").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())));
assertTrue(responseNode.get("processInstanceUrl").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, parentExecution.getId())));
// Check resulting child execution
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, childExecution.getId())), HttpStatus.SC_OK);
responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(childExecution.getId(), responseNode.get("id").textValue());
assertEquals("processTask", responseNode.get("activityId").textValue());
assertFalse(responseNode.get("suspended").booleanValue());
assertFalse(responseNode.get("suspended").booleanValue());
assertTrue(responseNode.get("url").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, childExecution.getId())));
assertTrue(responseNode.get("parentUrl").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION, parentExecution.getId())));
assertTrue(responseNode.get("processInstanceUrl").asText().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, parentExecution.getId())));
}
use of org.activiti.engine.test.Deployment 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.activiti.engine.test.Deployment 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.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ProcessInstanceCollectionResourceTest method testGetProcessInstancesByBusinessKeyAndIncludeVariables.
// check if process instance query with business key with and without includeProcess Variables
// related to https://activiti.atlassian.net/browse/ACT-1992
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" })
public void testGetProcessInstancesByBusinessKeyAndIncludeVariables() throws Exception {
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("myVar1", "myVar1");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey", variables);
String processId = processInstance.getId();
// check that the right process is returned with no variables
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?businessKey=myBusinessKey";
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK);
JsonNode rootNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertTrue(rootNode.size() > 0);
assertEquals(1, rootNode.get("data").size());
JsonNode dataNode = rootNode.get("data").get(0);
assertEquals(processId, dataNode.get("id").asText());
assertEquals(processInstance.getProcessDefinitionId(), dataNode.get("processDefinitionId").asText());
assertTrue(dataNode.get("processDefinitionUrl").asText().contains(processInstance.getProcessDefinitionId()));
JsonNode variableNodes = dataNode.get("variables");
assertEquals(0, variableNodes.size());
// check that the right process is returned along with the variables when includeProcessvariable is set
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?businessKey=myBusinessKey&includeProcessVariables=true";
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK);
rootNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertTrue(rootNode.size() > 0);
assertEquals(1, rootNode.get("data").size());
dataNode = rootNode.get("data").get(0);
assertEquals(processId, dataNode.get("id").textValue());
assertEquals(processInstance.getProcessDefinitionId(), dataNode.get("processDefinitionId").asText());
assertTrue(dataNode.get("processDefinitionUrl").asText().contains(processInstance.getProcessDefinitionId()));
variableNodes = dataNode.get("variables");
assertEquals(1, variableNodes.size());
variableNodes = dataNode.get("variables");
assertEquals(1, variableNodes.size());
assertNotNull(variableNodes.get(0).get("name"));
assertNotNull(variableNodes.get(0).get("value"));
assertEquals("myVar1", variableNodes.get(0).get("name").asText());
assertEquals("myVar1", variableNodes.get(0).get("value").asText());
}
Aggregations