use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class SubTaskTest method testSubTaskDeleteOnProcessInstanceDelete.
public void testSubTaskDeleteOnProcessInstanceDelete() {
Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setAssignee(task.getId(), "test");
Task subTask1 = taskService.newTask();
subTask1.setName("Sub task 1");
subTask1.setParentTaskId(task.getId());
subTask1.setAssignee("test");
taskService.saveTask(subTask1);
Task subTask2 = taskService.newTask();
subTask2.setName("Sub task 2");
subTask2.setParentTaskId(task.getId());
subTask2.setAssignee("test");
taskService.saveTask(subTask2);
List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list();
assertThat(tasks).hasSize(3);
runtimeService.deleteProcessInstance(processInstance.getId(), "none");
tasks = taskService.createTaskQuery().taskAssignee("test").list();
assertThat(tasks).hasSize(0);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
assertThat(historicTasks).hasSize(3);
historyService.deleteHistoricProcessInstance(processInstance.getId());
historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
assertThat(historicTasks).hasSize(0);
}
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class VerifyDatabaseOperationsTest method tearDown.
@Override
protected void tearDown() throws Exception {
processEngineConfiguration.getPerformanceSettings().setEnableEagerExecutionTreeFetching(oldExecutionTreeFetchValue);
processEngineConfiguration.getPerformanceSettings().setEnableExecutionRelationshipCounts(oldExecutionRelationshipCountValue);
processEngineConfiguration.setEnableProcessDefinitionInfoCache(oldenableProcessDefinitionInfoCacheValue);
((DefaultHistoryManager) processEngineConfiguration.getHistoryManager()).setHistoryLevel(oldHistoryLevel);
((CommandExecutorImpl) processEngineConfiguration.getCommandExecutor()).setFirst(oldFirstCommandInterceptor);
;
processEngineConfiguration.addSessionFactory(oldDbSqlSessionFactory);
// Validate (cause this tended to be screwed up)
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().list();
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertThat(historicActivityInstance.getStartTime() != null).isTrue();
assertThat(historicActivityInstance.getEndTime() != null).isTrue();
}
ActivitiProfiler.getInstance().reset();
for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
super.tearDown();
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class MultiTenantProcessEngineTest method startProcessInstances.
private void startProcessInstances(String userId) {
System.out.println();
System.out.println("Starting process instance for user " + userId);
tenantInfoHolder.setCurrentUserId(userId);
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/engine/test/cfg/multitenant/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/engine/test/cfg/multitenant/jobTest.bpmn20.xml").deploy();
System.out.println("Process deployed! Deployment id is " + deployment.getId());
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("data", "Hello from " + userId);
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", vars);
List<Task> tasks = processEngine.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).list();
System.out.println("Got " + tasks.size() + " tasks");
System.out.println("Got " + processEngine.getHistoryService().createHistoricProcessInstanceQuery().count() + " process instances in the system");
// Start a process instance with a Job
processEngine.getRuntimeService().startProcessInstanceByKey("jobTest");
tenantInfoHolder.clearCurrentUserId();
tenantInfoHolder.clearCurrentTenantId();
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentPersistenceTest method testDeploymentPersistence.
public void testDeploymentPersistence() {
Deployment deployment = repositoryService.createDeployment().name("strings").addString("org/activiti/test/HelloWorld.string", "hello world").addString("org/activiti/test/TheAnswer.string", "42").deploy();
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
assertThat(deployments).hasSize(1);
deployment = deployments.get(0);
assertThat(deployment.getName()).isEqualTo("strings");
assertThat(deployment.getDeploymentTime()).isNotNull();
String deploymentId = deployment.getId();
List<String> resourceNames = repositoryService.getDeploymentResourceNames(deploymentId);
Set<String> expectedResourceNames = new HashSet<String>();
expectedResourceNames.add("org/activiti/test/HelloWorld.string");
expectedResourceNames.add("org/activiti/test/TheAnswer.string");
assertThat(new HashSet<String>(resourceNames)).isEqualTo(expectedResourceNames);
InputStream resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/HelloWorld.string");
assertThat(IoUtil.readInputStream(resourceStream, "test")).isEqualTo("hello world".getBytes());
resourceStream = repositoryService.getResourceAsStream(deploymentId, "org/activiti/test/TheAnswer.string");
assertThat(IoUtil.readInputStream(resourceStream, "test")).isEqualTo("42".getBytes());
repositoryService.deleteDeployment(deploymentId);
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ProcessRuntimeImplTest method should_throwActivitiObjectNotFoundException_when_canReadFalse.
@Test
public void should_throwActivitiObjectNotFoundException_when_canReadFalse() {
String processDefinitionId = "processDefinitionId";
String processDefinitionKey = "processDefinitionKey";
ProcessDefinitionEntityImpl processDefinition = new ProcessDefinitionEntityImpl();
processDefinition.setId(processDefinitionId);
processDefinition.setKey(processDefinitionKey);
processDefinition.setAppVersion(1);
List<ProcessDefinition> findProcessDefinitionResult = singletonList(processDefinition);
Deployment latestDeploymentEntity = new DeploymentEntityImpl();
DeploymentImpl deployment = new DeploymentImpl();
deployment.setVersion(1);
given(deploymentConverter.from(latestDeploymentEntity)).willReturn(deployment);
given(commandExecutor.execute(any())).willReturn(findProcessDefinitionResult).willReturn(latestDeploymentEntity);
given(securityPoliciesManager.canRead(processDefinitionKey)).willReturn(false);
Throwable exception = catchThrowable(() -> processRuntime.processDefinition(processDefinitionId));
assertThat(exception).isInstanceOf(ActivitiObjectNotFoundException.class).hasMessage("Unable to find process definition for the given id:'processDefinitionId'");
}
Aggregations