use of org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd in project Activiti by Activiti.
the class ProcessInstanceResourceTest method testGetProcessInstance.
/**
* Test getting a single process instance.
*/
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" })
public void testGetProcessInstance() throws Exception {
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder().processDefinitionKey("processOne").businessKey("myBusinessKey").processInstanceName("myProcessName").start();
String url = buildUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId());
CloseableHttpResponse response = executeRequest(new HttpGet(url), HttpStatus.SC_OK);
// Check resulting instance
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(processInstance.getId(), responseNode.get("id").textValue());
assertEquals("myBusinessKey", responseNode.get("businessKey").textValue());
assertEquals("myProcessName", responseNode.get("name").textValue());
assertEquals("processTask", responseNode.get("activityId").textValue());
assertFalse(responseNode.get("suspended").booleanValue());
assertEquals("", responseNode.get("tenantId").textValue());
assertTrue(responseNode.get("url").asText().equals(url));
assertTrue(responseNode.get("processDefinitionUrl").asText().equals(buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId())));
// Check result after tenant has been changed
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId())), HttpStatus.SC_OK);
// Check resulting instance tenant id
responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("myTenant", responseNode.get("tenantId").textValue());
}
use of org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd in project Activiti by Activiti.
the class JobCollectionResourceTest method testGetJobs.
@Deployment(resources = { "org/activiti/rest/service/api/management/JobCollectionResourceTest.testTimerProcess.bpmn20.xml" })
public void testGetJobs() throws Exception {
Calendar hourAgo = Calendar.getInstance();
hourAgo.add(Calendar.HOUR, -1);
Calendar inAnHour = Calendar.getInstance();
inAnHour.add(Calendar.HOUR, 1);
// Start process, forcing error on job-execution
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess", Collections.singletonMap("error", (Object) Boolean.TRUE));
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).timers().singleResult();
assertNotNull(timerJob);
for (int i = 0; i < timerJob.getRetries(); i++) {
// Force execution of job until retries are exhausted
try {
managementService.executeJob(timerJob.getId());
fail();
} catch (ActivitiException expected) {
// Ignore, we expect the exception
}
}
timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).timers().singleResult();
assertEquals(0, timerJob.getRetries());
// Fetch the async-job (which has retries left)
Job asyncJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).withRetriesLeft().singleResult();
// Test fetching all jobs
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION);
assertResultsPresentInDataResponse(url, asyncJob.getId(), timerJob.getId());
// Fetch using job-id
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?id=" + asyncJob.getId();
assertResultsPresentInDataResponse(url, asyncJob.getId());
// Fetch using processInstanceId
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?processInstanceId=" + processInstance.getId();
assertResultsPresentInDataResponse(url, asyncJob.getId(), timerJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?processInstanceId=unexisting";
assertResultsPresentInDataResponse(url);
// Fetch using executionId
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?executionId=" + asyncJob.getExecutionId();
assertResultsPresentInDataResponse(url, asyncJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?executionId=" + timerJob.getExecutionId();
assertResultsPresentInDataResponse(url, timerJob.getId());
// Fetch using processDefinitionId
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?processDefinitionId=" + processInstance.getProcessDefinitionId();
assertResultsPresentInDataResponse(url, asyncJob.getId(), timerJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?processDefinitionId=unexisting";
assertResultsPresentInDataResponse(url);
// Fetch using withRetriesLeft
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?withRetriesLeft=true";
assertResultsPresentInDataResponse(url, asyncJob.getId());
// Fetch using executable
// url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?executable=true";
// assertResultsPresentInDataResponse(url, asyncJob.getId());
// Fetch using timers only
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?timersOnly=true";
assertResultsPresentInDataResponse(url, timerJob.getId());
// Combining messagesOnly with timersOnly should result in exception
closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?timersOnly=true&messagesOnly=true"), HttpStatus.SC_BAD_REQUEST));
// Fetch using dueBefore
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?dueBefore=" + getISODateString(inAnHour.getTime());
assertResultsPresentInDataResponse(url, timerJob.getId(), asyncJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?dueBefore=" + getISODateString(hourAgo.getTime());
assertResultsPresentInDataResponse(url);
// Fetch using dueAfter
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?dueAfter=" + getISODateString(hourAgo.getTime());
assertResultsPresentInDataResponse(url, timerJob.getId(), asyncJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?dueAfter=" + getISODateString(inAnHour.getTime());
assertResultsPresentInDataResponse(url);
// Fetch using withException
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?withException=true";
assertResultsPresentInDataResponse(url, timerJob.getId());
// Fetch with exceptionMessage
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?exceptionMessage=" + encode(timerJob.getExceptionMessage());
assertResultsPresentInDataResponse(url, timerJob.getId());
// Fetch with empty exceptionMessage
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?exceptionMessage=";
assertResultsPresentInDataResponse(url);
// Without tenant id, before tenant update
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?withoutTenantId=true";
assertResultsPresentInDataResponse(url, timerJob.getId(), asyncJob.getId());
// Set tenant on deployment
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
// Without tenant id, after tenant update
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?withoutTenantId=true";
assertResultsPresentInDataResponse(url);
// Tenant id
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?tenantId=myTenant";
assertResultsPresentInDataResponse(url, timerJob.getId(), asyncJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?tenantId=anotherTenant";
assertResultsPresentInDataResponse(url);
// Tenant id like
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?tenantIdLike=" + encode("%enant");
assertResultsPresentInDataResponse(url, timerJob.getId(), asyncJob.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB_COLLECTION) + "?tenantIdLike=anotherTenant";
assertResultsPresentInDataResponse(url);
}
use of org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd in project Activiti by Activiti.
the class TaskCollectionResourceTest method testGetTasks.
/**
* Test getting a collection of tasks.
* GET runtime/tasks
*/
@Deployment
public void testGetTasks() throws Exception {
try {
Calendar adhocTaskCreate = Calendar.getInstance();
adhocTaskCreate.set(Calendar.MILLISECOND, 0);
Calendar processTaskCreate = Calendar.getInstance();
processTaskCreate.add(Calendar.HOUR, 2);
processTaskCreate.set(Calendar.MILLISECOND, 0);
Calendar inBetweenTaskCreation = Calendar.getInstance();
inBetweenTaskCreation.add(Calendar.HOUR, 1);
processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime());
Task adhocTask = taskService.newTask();
adhocTask.setAssignee("gonzo");
adhocTask.setOwner("owner");
adhocTask.setDelegationState(DelegationState.PENDING);
adhocTask.setDescription("Description one");
adhocTask.setName("Name one");
adhocTask.setDueDate(adhocTaskCreate.getTime());
adhocTask.setPriority(100);
adhocTask.setCategory("some-category");
taskService.saveTask(adhocTask);
taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT);
processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey");
Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
processTask.setParentTaskId(adhocTask.getId());
processTask.setPriority(50);
processTask.setDueDate(processTaskCreate.getTime());
taskService.saveTask(processTask);
// Check filter-less to fetch all tasks
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION);
assertResultsPresentInDataResponse(url, adhocTask.getId(), processTask.getId());
// Name filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?name=" + encode("Name one");
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Name like filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?nameLike=" + encode("%one");
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Description filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?description=" + encode("Description one");
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?description=" + encode("Description two");
assertEmptyResultsPresentInDataResponse(url);
// Description like filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?descriptionLike=" + encode("%one");
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?descriptionLike=" + encode("%two");
assertEmptyResultsPresentInDataResponse(url);
// Priority filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?priority=100";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Mininmum Priority filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?minimumPriority=70";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Maximum Priority filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?maximumPriority=70";
assertResultsPresentInDataResponse(url, processTask.getId());
// Owner filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?owner=owner";
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?owner=kermit";
assertEmptyResultsPresentInDataResponse(url);
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?ownerLike=" + encode("%ner");
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?ownerLike=" + encode("kerm%");
assertEmptyResultsPresentInDataResponse(url);
// Assignee filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assignee=gonzo";
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assignee=kermit";
assertEmptyResultsPresentInDataResponse(url);
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assigneeLike=" + encode("gon%");
assertResultsPresentInDataResponse(url, adhocTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?assigneeLike=" + encode("kerm%");
assertEmptyResultsPresentInDataResponse(url);
// Unassigned filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?unassigned=true";
assertResultsPresentInDataResponse(url, processTask.getId());
// Delegation state filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?delegationState=pending";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Candidate user filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?candidateUser=kermit";
assertResultsPresentInDataResponse(url, processTask.getId());
// Candidate group filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?candidateGroup=sales";
assertResultsPresentInDataResponse(url, processTask.getId());
// Involved user filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?involvedUser=misspiggy";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Process instance filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processInstanceId=" + processInstance.getId();
assertResultsPresentInDataResponse(url, processTask.getId());
// Process instance id in list filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processInstanceIdIn=" + adhocTask.getId() + "," + processInstance.getId();
assertResultsPresentInDataResponse(url, processTask.getId());
// Execution filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?executionId=" + processInstance.getId();
assertResultsPresentInDataResponse(url, processTask.getId());
// Process instance businesskey filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processInstanceBusinessKey=myBusinessKey";
assertResultsPresentInDataResponse(url, processTask.getId());
// CeatedOn filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdOn=" + getISODateString(adhocTaskCreate.getTime());
assertResultsPresentInDataResponse(url, adhocTask.getId());
// CreatedAfter filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdAfter=" + getISODateString(inBetweenTaskCreation.getTime());
assertResultsPresentInDataResponse(url, processTask.getId());
// CreatedBefore filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?createdBefore=" + getISODateString(inBetweenTaskCreation.getTime());
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Subtask exclusion
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?excludeSubTasks=true";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Task definition key filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?taskDefinitionKey=processTask";
assertResultsPresentInDataResponse(url, processTask.getId());
// Task definition key like filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?taskDefinitionKeyLike=" + encode("process%");
assertResultsPresentInDataResponse(url, processTask.getId());
// Duedate filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueDate=" + getISODateString(adhocTaskCreate.getTime());
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Due after filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueAfter=" + getISODateString(inBetweenTaskCreation.getTime());
assertResultsPresentInDataResponse(url, processTask.getId());
// Due before filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?dueBefore=" + getISODateString(inBetweenTaskCreation.getTime());
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Without tenantId filtering before tenant set
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?withoutTenantId=true";
assertResultsPresentInDataResponse(url, adhocTask.getId(), processTask.getId());
// Process definition
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processDefinitionKey=" + processInstance.getProcessDefinitionKey();
assertResultsPresentInDataResponse(url, processTask.getId());
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?processDefinitionId=" + processInstance.getProcessDefinitionId();
assertResultsPresentInDataResponse(url, processTask.getId());
// Set tenant on deployment
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
// Without tenantId filtering after tenant set, only adhoc task should remain
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?withoutTenantId=true";
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Tenant id filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?tenantId=myTenant";
assertResultsPresentInDataResponse(url, processTask.getId());
// Tenant id like filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?tenantIdLike=" + encode("%enant");
assertResultsPresentInDataResponse(url, processTask.getId());
// Category filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?category=" + encode("some-category");
assertResultsPresentInDataResponse(url, adhocTask.getId());
// Suspend process-instance to have a supended task
runtimeService.suspendProcessInstanceById(processInstance.getId());
// Suspended filering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?active=false";
assertResultsPresentInDataResponse(url, processTask.getId());
// Active filtering
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COLLECTION) + "?active=true";
assertResultsPresentInDataResponse(url, adhocTask.getId());
} finally {
// Clean adhoc-tasks even if test fails
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
if (task.getExecutionId() == null) {
taskService.deleteTask(task.getId(), true);
}
}
}
}
use of org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd in project Activiti by Activiti.
the class TaskResourceTest method testGetProcessTask.
/**
* Test getting a single task, spawned by a process.
* GET runtime/tasks/{taskId}
*/
@Deployment
public void testGetProcessTask() throws Exception {
Calendar now = Calendar.getInstance();
processEngineConfiguration.getClock().setCurrentTime(now.getTime());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setDueDate(task.getId(), now.getTime());
taskService.setOwner(task.getId(), "owner");
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
String url = buildUrl(RestUrls.URL_TASK, task.getId());
CloseableHttpResponse response = executeRequest(new HttpGet(url), HttpStatus.SC_OK);
// Check resulting task
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertEquals(task.getId(), responseNode.get("id").asText());
assertEquals(task.getAssignee(), responseNode.get("assignee").asText());
assertEquals(task.getOwner(), responseNode.get("owner").asText());
assertEquals(task.getFormKey(), responseNode.get("formKey").asText());
assertEquals(task.getDescription(), responseNode.get("description").asText());
assertEquals(task.getName(), responseNode.get("name").asText());
assertEquals(task.getDueDate(), getDateFromISOString(responseNode.get("dueDate").asText()));
assertEquals(task.getCreateTime(), getDateFromISOString(responseNode.get("createTime").asText()));
assertEquals(task.getPriority(), responseNode.get("priority").asInt());
assertTrue(responseNode.get("parentTaskId").isNull());
assertTrue(responseNode.get("delegationState").isNull());
assertEquals("", responseNode.get("tenantId").textValue());
assertTrue(responseNode.get("executionUrl").asText().equals(buildUrl(RestUrls.URL_EXECUTION, task.getExecutionId())));
assertTrue(responseNode.get("processInstanceUrl").asText().equals(buildUrl(RestUrls.URL_PROCESS_INSTANCE, task.getProcessInstanceId())));
assertTrue(responseNode.get("processDefinitionUrl").asText().equals(buildUrl(RestUrls.URL_PROCESS_DEFINITION, task.getProcessDefinitionId())));
assertTrue(responseNode.get("url").asText().equals(url));
// Set tenant on deployment
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
response = executeRequest(new HttpGet(url), HttpStatus.SC_OK);
responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertEquals("myTenant", responseNode.get("tenantId").asText());
}
use of org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd in project Activiti by Activiti.
the class HistoricActivityInstanceCollectionResourceTest method testQueryActivityInstances.
/**
* Test querying historic activity instance.
* GET history/historic-activity-instances
*/
@Deployment(resources = { "org/activiti/rest/service/api/twoTaskProcess.bpmn20.xml" })
public void testQueryActivityInstances() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
// Set tenant on deployment
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKeyAndTenantId("oneTaskProcess", "myTenant");
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_ACTIVITY_INSTANCES);
assertResultsPresentInDataResponse(url + "?activityId=processTask", 2, "processTask");
assertResultsPresentInDataResponse(url + "?activityId=processTask&finished=true", 1, "processTask");
assertResultsPresentInDataResponse(url + "?activityId=processTask&finished=false", 1, "processTask");
assertResultsPresentInDataResponse(url + "?activityId=processTask2", 1, "processTask2");
assertResultsPresentInDataResponse(url + "?activityId=processTask3", 0);
assertResultsPresentInDataResponse(url + "?activityName=Process%20task", 2, "processTask");
assertResultsPresentInDataResponse(url + "?activityName=Process%20task2", 1, "processTask2");
assertResultsPresentInDataResponse(url + "?activityName=Process%20task3", 0);
assertResultsPresentInDataResponse(url + "?activityType=userTask", 3, "processTask", "processTask2");
assertResultsPresentInDataResponse(url + "?activityType=startEvent", 2, "theStart");
assertResultsPresentInDataResponse(url + "?activityType=receiveTask", 0);
assertResultsPresentInDataResponse(url + "?processInstanceId=" + processInstance.getId(), 3, "theStart", "processTask", "processTask2");
assertResultsPresentInDataResponse(url + "?processInstanceId=" + processInstance2.getId(), 2, "theStart", "processTask");
assertResultsPresentInDataResponse(url + "?processDefinitionId=" + processInstance.getProcessDefinitionId(), 5, "theStart", "processTask", "processTask2");
assertResultsPresentInDataResponse(url + "?taskAssignee=kermit", 2, "processTask");
assertResultsPresentInDataResponse(url + "?taskAssignee=fozzie", 1, "processTask2");
assertResultsPresentInDataResponse(url + "?taskAssignee=fozzie2", 0);
// Without tenant ID, only activities for processinstance1
assertResultsPresentInDataResponse(url + "?withoutTenantId=true", 3);
// Tenant id
assertResultsPresentInDataResponse(url + "?tenantId=myTenant", 2, "theStart", "processTask");
assertResultsPresentInDataResponse(url + "?tenantId=anotherTenant");
// Tenant id like
assertResultsPresentInDataResponse(url + "?tenantIdLike=" + encode("%enant"), 2, "theStart", "processTask");
assertResultsPresentInDataResponse(url + "?tenantIdLike=anotherTenant");
}
Aggregations