use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testGetProcessDefinition.
/**
* Test getting a single process definition.
* GET repository/process-definitions/{processDefinitionResource}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testGetProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertEquals(processDefinition.getId(), responseNode.get("id").textValue());
assertEquals(processDefinition.getKey(), responseNode.get("key").textValue());
assertEquals(processDefinition.getCategory(), responseNode.get("category").textValue());
assertEquals(processDefinition.getVersion(), responseNode.get("version").intValue());
assertEquals(processDefinition.getDescription(), responseNode.get("description").textValue());
assertEquals(processDefinition.getName(), responseNode.get("name").textValue());
assertFalse(responseNode.get("graphicalNotationDefined").booleanValue());
// Check URL's
assertEquals(httpGet.getURI().toString(), responseNode.get("url").asText());
assertEquals(processDefinition.getDeploymentId(), responseNode.get("deploymentId").textValue());
assertTrue(responseNode.get("deploymentUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, processDefinition.getDeploymentId())));
assertTrue(URLDecoder.decode(responseNode.get("resource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName())));
assertTrue(responseNode.get("diagramResource").isNull());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testGetProcessDefinitionWithGraphicalNotation.
/**
* Test getting a single process definition with a graphical notation defined.
* GET repository/process-definitions/{processDefinitionResource}
*/
@Deployment
public void testGetProcessDefinitionWithGraphicalNotation() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertEquals(processDefinition.getId(), responseNode.get("id").textValue());
assertEquals(processDefinition.getKey(), responseNode.get("key").textValue());
assertEquals(processDefinition.getCategory(), responseNode.get("category").textValue());
assertEquals(processDefinition.getVersion(), responseNode.get("version").intValue());
assertEquals(processDefinition.getDescription(), responseNode.get("description").textValue());
assertEquals(processDefinition.getName(), responseNode.get("name").textValue());
assertTrue(responseNode.get("graphicalNotationDefined").booleanValue());
// Check URL's
assertEquals(httpGet.getURI().toString(), responseNode.get("url").asText());
assertEquals(processDefinition.getDeploymentId(), responseNode.get("deploymentId").textValue());
assertTrue(responseNode.get("deploymentUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, processDefinition.getDeploymentId())));
assertTrue(URLDecoder.decode(responseNode.get("resource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName())));
assertTrue(URLDecoder.decode(responseNode.get("diagramResource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName())));
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testSuspendAlreadySuspendedProcessDefinition.
/**
* Test suspending already suspended process definition.
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendAlreadySuspendedProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertTrue(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "suspend");
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_CONFLICT);
closeResponse(response);
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ExecutionVariableResourceTest method testGetExecutionVariable.
/**
* Test getting an execution variable. GET
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testGetExecutionVariable() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne");
runtimeService.setVariable(processInstance.getId(), "variable", "processValue");
Execution childExecution = runtimeService.createExecutionQuery().parentId(processInstance.getId()).singleResult();
assertNotNull(childExecution);
runtimeService.setVariableLocal(childExecution.getId(), "variable", "childValue");
// Get local scope variable
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, childExecution.getId(), "variable")), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("local", responseNode.get("scope").asText());
assertEquals("childValue", responseNode.get("value").asText());
assertEquals("variable", responseNode.get("name").asText());
assertEquals("string", responseNode.get("type").asText());
// Get global scope variable
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, childExecution.getId(), "variable") + "?scope=global"), HttpStatus.SC_OK);
responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("global", responseNode.get("scope").asText());
assertEquals("processValue", responseNode.get("value").asText());
assertEquals("variable", responseNode.get("name").asText());
assertEquals("string", responseNode.get("type").asText());
// Illegal scope
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, processInstance.getId(), "variable") + "?scope=illegal"), HttpStatus.SC_BAD_REQUEST);
closeResponse(response);
// Unexisting process
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, "unexisting", "variable")), HttpStatus.SC_NOT_FOUND);
closeResponse(response);
// Unexisting variable
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE, processInstance.getId(), "unexistingVariable")), HttpStatus.SC_NOT_FOUND);
closeResponse(response);
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class ExecutionVariableResourceTest method testGetExecutionVariableData.
/**
* Test getting execution variable data.
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ExecutionResourceTest.process-with-subprocess.bpmn20.xml" })
public void testGetExecutionVariableData() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne");
runtimeService.setVariableLocal(processInstance.getId(), "var", "This is a binary piece of text".getBytes());
Execution childExecution = runtimeService.createExecutionQuery().parentId(processInstance.getId()).singleResult();
assertNotNull(childExecution);
runtimeService.setVariableLocal(childExecution.getId(), "var", "This is a binary piece of text in the child execution".getBytes());
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE_DATA, childExecution.getId(), "var")), HttpStatus.SC_OK);
String actualResponseBytesAsText = IOUtils.toString(response.getEntity().getContent());
closeResponse(response);
assertEquals("This is a binary piece of text in the child execution", actualResponseBytesAsText);
assertEquals("application/octet-stream", response.getEntity().getContentType().getValue());
// Test global scope
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_VARIABLE_DATA, childExecution.getId(), "var") + "?scope=global"), HttpStatus.SC_OK);
actualResponseBytesAsText = IOUtils.toString(response.getEntity().getContent());
closeResponse(response);
assertEquals("This is a binary piece of text", actualResponseBytesAsText);
assertEquals("application/octet-stream", response.getEntity().getContentType().getValue());
}
Aggregations