org.camunda.bpm.engine.ProcessEngineConfiguration Java Examples

The following examples show how to use org.camunda.bpm.engine.ProcessEngineConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateProcessInstancesSuspendStateTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml",
  "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml"})
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testBatchSuspensionByHistoricProcessInstanceQuery() {
  // given
  ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");


  // when the process instances are suspended
  runtimeService.updateProcessInstanceSuspensionState()
    .byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspend();

  // Update the process instances and they are suspended
  ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
  assertTrue(p1c.isSuspended());
  ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
  assertTrue(p2c.isSuspended());

}
 
Example #2
Source File: ManagementServiceAsyncOperationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Test
public void testSetJobsRetryAsyncWithHistoryProcessQuery() {
  //given
  HistoricProcessInstanceQuery historicProcessInstanceQuery =
      historyService.createHistoricProcessInstanceQuery();

  //when
  Batch batch = managementService.setJobRetriesAsync(null, null,
      historicProcessInstanceQuery, RETRIES);
  completeSeedJobs(batch);
  List<Exception> exceptions = executeBatchJobs(batch);

  // then
  assertThat(exceptions.size(), is(0));
  assertRetries(ids, RETRIES);
  assertHistoricBatchExists(testRule);
}
 
Example #3
Source File: MultiTenancyProcessInstantiationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantIdByHistoricProcessInstanceQuery() {
  // given
  ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
  HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.getProcessDefinitionId());

  identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));

  try {
    // when
    runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId())
      .startBeforeActivity("userTask")
      .historicProcessInstanceQuery(query)
      .execute();

    fail("expected exception");
  } catch (BadUserRequestException e) {
    // then
    assertThat(e.getMessage(), containsString("processInstanceIds is empty"));
  }
}
 
Example #4
Source File: ProcessTaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testUpdateVariablesRemove() {
  // given
  runtimeService.startProcessInstanceByKey(PROCESS_KEY);
  String taskId = taskService.createTaskQuery().singleResult().getId();
  taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);

  // when
  authRule
      .init(scenario)
      .withUser("userId")
      .bindResource("taskId", taskId)
      .start();

  ((TaskServiceImpl) taskService).updateVariables(taskId, null, Arrays.asList(VARIABLE_NAME));

  // then
  if (authRule.assertScenario(scenario)) {
    verifyRemoveVariables();
  }
}
 
Example #5
Source File: UserOperationLogWithoutUserTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = PROCESS_PATH)
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testDeleteHistoricVariable() {
  // given
  String id = runtimeService.startProcessInstanceByKey(PROCESS_KEY).getId();
  runtimeService.setVariable(id, "aVariable", "aValue");
  runtimeService.deleteProcessInstance(id, "none");
  assertEquals(1, historyService.createHistoricVariableInstanceQuery().count());
  String historicVariableId = historyService.createHistoricVariableInstanceQuery().singleResult().getId();
  
  // when
  historyService.deleteHistoricVariableInstance(historicVariableId);

  // then
  assertEquals(0, historyService.createHistoricVariableInstanceQuery().count());
  verifyNoUserOperationLogged();
}
 
Example #6
Source File: KeycloakConfigureAdminGroupAsPathAndUsePathAsId.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminGroupAsPathAndUsePathAsId.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminGroupAsPathAndUsePathAsId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example #7
Source File: KeycloakConfigureAdminUserIdAsUsernameAndUseUsernameAsIdTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminUserIdAsUsernameAndUseUsernameAsIdTest.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminUserIdAsUsernameAndUseUsernameAsId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example #8
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomTenantWhitelistPattern() {
  processEngine = ProcessEngineConfiguration
    .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/api/identity/generic.resource.id.whitelist.camunda.cfg.xml")
    .buildProcessEngine();
  processEngine.getProcessEngineConfiguration().setTenantResourceWhitelistPattern("[a-zA-Z]+");

  String validId = "johnsTenant";
  String invalidId = "john!@#$%";

  try {
    Tenant tenant = processEngine.getIdentityService().newTenant(validId);
    tenant.setId(invalidId);
    processEngine.getIdentityService().saveTenant(tenant);

    fail("Invalid tenant id exception expected!");
  } catch (ProcessEngineException ex) {
    assertEquals(String.format(INVALID_ID_MESSAGE, "Tenant", invalidId), ex.getMessage());
  }
}
 
Example #9
Source File: HistoricTaskInstanceQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testWithCandidateGroups() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess");
  String taskId = taskService.createTaskQuery().singleResult().getId();

  // when
  identityService.setAuthenticatedUserId("aAssignerId");
  taskService.addCandidateGroup(taskId, "aGroupId");

  // then
  assertEquals(historyService.createHistoricTaskInstanceQuery().withCandidateGroups().count(), 1);

  // cleanup
  taskService.deleteTask("newTask", true);
}
 
Example #10
Source File: KeycloakConfigureAdminUserIdAsUsernameAndUseMailAsIdTest.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminUserIdAsUsernameAndUseMailAsIdTest.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminUserIdAsUsernameAndUseMailAsId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example #11
Source File: KeycloakConfigureAdminGroupAndUsePathAsId.java    From camunda-bpm-identity-keycloak with Apache License 2.0 6 votes vote down vote up
public static Test suite() {
    return new TestSetup(new TestSuite(KeycloakConfigureAdminGroupAndUsePathAsId.class)) {

    	// @BeforeClass
        protected void setUp() throws Exception {
    		ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration
    				.createProcessEngineConfigurationFromResource("camunda.configureAdminGroupAndUsePathAsId.cfg.xml");
    		configureKeycloakIdentityProviderPlugin(config);
    		PluggableProcessEngineTestCase.cachedProcessEngine = config.buildProcessEngine();
        }
        
        // @AfterClass
        protected void tearDown() throws Exception {
    		PluggableProcessEngineTestCase.cachedProcessEngine.close();
    		PluggableProcessEngineTestCase.cachedProcessEngine = null;
        }
    };
}
 
Example #12
Source File: UpdateProcessInstancesSuspendStateAsyncTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml",
  "org/camunda/bpm/engine/test/api/externaltask/twoExternalTaskProcess.bpmn20.xml"})
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testBatchActivationByHistoricProcessInstanceQuery() {
  // given
  ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("twoExternalTaskProcess");

  // when
  Batch suspendprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).suspendAsync();
  helper.completeSeedJobs(suspendprocess);
  helper.executeJobs(suspendprocess);
  Batch activateprocess = runtimeService.updateProcessInstanceSuspensionState().byHistoricProcessInstanceQuery(historyService.createHistoricProcessInstanceQuery().processInstanceIds(Sets.newHashSet(processInstance1.getId(), processInstance2.getId()))).activateAsync();
  helper.completeSeedJobs(activateprocess);
  helper.executeJobs(activateprocess);


  // then
  ProcessInstance p1c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance1.getId()).singleResult();
  assertFalse(p1c.isSuspended());
  ProcessInstance p2c = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance2.getId()).singleResult();
  assertFalse(p2c.isSuspended());
}
 
Example #13
Source File: MultiTenancyProcessInstantiationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testFailToRestartProcessInstanceSyncWithOtherTenantId() {
  // given
  ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);

  identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO));

  try {
    // when
    runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId())
      .startBeforeActivity("userTask")
      .processInstanceIds(processInstance.getId())
      .execute();

    fail("expected exception");
  } catch (BadUserRequestException e) {
    // then
    assertThat(e.getMessage(), containsString("Historic process instance cannot be found: historicProcessInstanceId is null"));
  }
}
 
Example #14
Source File: EnsureUtil.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static String determineResourceWhitelistPattern(ProcessEngineConfiguration processEngineConfiguration, String resourceType) {
  String resourcePattern = null;

  if (resourceType.equals("User")) {
    resourcePattern = processEngineConfiguration.getUserResourceWhitelistPattern();
  }

  if (resourceType.equals("Group")) {
    resourcePattern =  processEngineConfiguration.getGroupResourceWhitelistPattern();
  }

  if (resourceType.equals("Tenant")) {
    resourcePattern =  processEngineConfiguration.getTenantResourceWhitelistPattern();
  }

  if (resourcePattern != null && !resourcePattern.isEmpty()) {
    return resourcePattern;
  }

  return processEngineConfiguration.getGeneralResourceWhitelistPattern();
}
 
Example #15
Source File: ProcessTaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testUpdateVariablesLocalRemove() {
  // given
  runtimeService.startProcessInstanceByKey(PROCESS_KEY);
  String taskId = taskService.createTaskQuery().singleResult().getId();
  taskService.setVariableLocal(taskId, VARIABLE_NAME, VARIABLE_VALUE);

  // when
  authRule
      .init(scenario)
      .withUser("userId")
      .bindResource("taskId", taskId)
      .start();

  ((TaskServiceImpl) taskService).updateVariablesLocal(taskId, null, Arrays.asList(VARIABLE_NAME));

  // then
  if (authRule.assertScenario(scenario)) {
    verifyRemoveVariables();
  }
}
 
Example #16
Source File: AuthorizationCheckRevokesCfgTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCheckDbForCfgValue_auto() {
  final ListQueryParameterObject query = new ListQueryParameterObject();
  final AuthorizationCheck authCheck = query.getAuthCheck();

  final HashMap<String, Object> expectedQueryParams = new HashMap<String, Object>();
  expectedQueryParams.put("userId", AUTHENTICATED_USER_ID);
  expectedQueryParams.put("authGroupIds", AUTHENTICATED_GROUPS);

  // given
  when(mockedConfiguration.getAuthorizationCheckRevokes()).thenReturn(ProcessEngineConfiguration.AUTHORIZATION_CHECK_REVOKE_AUTO);
  when(mockedEntityManager.selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams))).thenReturn(true);

  // if
  authorizationManager.configureQuery(query);

  // then
  assertEquals(true, authCheck.isRevokeAuthorizationCheckEnabled());
  verify(mockedEntityManager, times(1)).selectBoolean(eq("selectRevokeAuthorization"), eq(expectedQueryParams));
}
 
Example #17
Source File: InMemProcessEngineConfiguration.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
@Bean
public ProcessEngineConfigurationImpl processEngineConfiguration() throws Exception {

  SpringProcessWithCoverageEngineConfiguration config = new SpringProcessWithCoverageEngineConfiguration();

  
  try {
    Method setApplicationContext = SpringProcessEngineConfiguration.class.getDeclaredMethod("setApplicationContext", ApplicationContext.class);
    if (setApplicationContext != null) {
      setApplicationContext.invoke(config, applicationContext);
    }
  } catch (NoSuchMethodException e) {
    // expected for Camunda < 7.8.0
  }
  config.setExpressionManager(expressionManager());
  config.setTransactionManager(transactionManager());
  config.setDataSource(dataSource());
  config.setDatabaseSchemaUpdate("true");
  config.setHistory(ProcessEngineConfiguration.HISTORY_FULL);
  config.setJobExecutorActivate(false);
  config.init();
  return config;

}
 
Example #18
Source File: ManagementServiceAsyncOperationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Test
public void shouldSetInvocationsPerBatchTypeForJobsByProcessInstanceIds() {
  // given
  engineRule.getProcessEngineConfiguration()
      .getInvocationsPerBatchJobByBatchType()
      .put(Batch.TYPE_SET_JOB_RETRIES, 42);

  HistoricProcessInstanceQuery historicProcessInstanceQuery =
      historyService.createHistoricProcessInstanceQuery();

  //when
  Batch batch = managementService.setJobRetriesAsync(null, null,
      historicProcessInstanceQuery, RETRIES);

  // then
  Assertions.assertThat(batch.getInvocationsPerBatchJob()).isEqualTo(42);

  // clear
  engineRule.getProcessEngineConfiguration()
      .setInvocationsPerBatchJobByBatchType(new HashMap<>());
}
 
Example #19
Source File: ModifyVariableInSameTransactionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testDeleteAndInsertTheSameVariableByteArray() {
  BpmnModelInstance bpmnModel =
      Bpmn.createExecutableProcess("serviceTaskProcess")
      .startEvent()
      .userTask("userTask")
      .serviceTask("service")
        .camundaClass(DeleteAndInsertVariableDelegate.class)
      .userTask("userTask1")
      .endEvent()
      .done();
  ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(bpmnModel);
  VariableMap variables = Variables.createVariables().putValue("listVar", Arrays.asList(new int[] { 1, 2, 3 }));
  ProcessInstance instance = engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(), variables);

  Task task = engineRule.getTaskService().createTaskQuery().singleResult();
  engineRule.getTaskService().complete(task.getId());

  VariableInstance variable = engineRule.getRuntimeService().createVariableInstanceQuery().processInstanceIdIn(instance.getId()).variableName("listVar").singleResult();
  assertNotNull(variable);
  assertEquals("stringValue", variable.getValue());
  HistoricVariableInstance historicVariable = engineRule.getHistoryService().createHistoricVariableInstanceQuery().singleResult();
  assertEquals(variable.getName(), historicVariable.getName());
  assertEquals(HistoricVariableInstance.STATE_CREATED, historicVariable.getState());
}
 
Example #20
Source File: ManagedProcessEngineFactoryImplIntegrationTest.java    From camunda-bpm-platform-osgi with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 40000L)
public void shutdownProcessEngine() throws IOException, InterruptedException {
  Hashtable<String, Object> props = new Hashtable<String, Object>();
  props.put("databaseSchemaUpdate", ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP);
  props.put("jdbcUrl", "jdbc:h2:mem:camunda;DB_CLOSE_DELAY=-1");
  props.put("jobExecutorActivate", "true");
  props.put("processEngineName", "TestEngine");
  org.osgi.service.cm.Configuration config = configAdmin.createFactoryConfiguration(ManagedProcessEngineFactory.SERVICE_PID, null);
  config.update(props);
  //give the engine some time to be created
  Thread.sleep(10000L);
  config.delete();
  Thread.sleep(5000L);
  ServiceReference<ProcessEngine> reference = null;
  do {
    Thread.sleep(500L);
    reference = ctx.getServiceReference(ProcessEngine.class);
  } while (reference != null);
}
 
Example #21
Source File: BoundedNumberOfMaxResultsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Test
public void shouldReturnResultWhenMaxResultsLimitNotExceeded() {
  // given
  BpmnModelInstance process = Bpmn.createExecutableProcess("process")
      .startEvent("startEvent")
      .endEvent()
      .done();

  testHelper.deploy(process);

  runtimeService.startProcessInstanceByKey("process");

  HistoricProcessInstanceQuery historicProcessInstanceQuery =
      historyService.createHistoricProcessInstanceQuery();

  // when
  List<HistoricProcessInstance> historicProcessInstances =
      historicProcessInstanceQuery.listPage(0, 10);

  // then
  assertThat(historicProcessInstances.size()).isEqualTo(1);
}
 
Example #22
Source File: StandaloneTaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testUpdateVariablesLocalAddRemove() {
  // given
  createTask(taskId);

  // when
  authRule
      .init(scenario)
      .withUser("userId")
      .bindResource("taskId", taskId)
      .start();

  ((TaskServiceImpl) taskService).updateVariablesLocal(taskId, getVariables(), Arrays.asList(VARIABLE_NAME));

  // then
  if (authRule.assertScenario(scenario)) {
    verifyRemoveVariable();
  }
}
 
Example #23
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/conditional/EventSubProcessStartConditionalEventTest.testVariableCondition.bpmn20.xml")
public void testVariableConditionWithHistory() {
  // given process with event sub process conditional start event
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY,
      Variables.createVariables()
      .putValue(VARIABLE_NAME, 1)
      .putValue("donotloseme", "here"));

  // assume
  tasksAfterVariableIsSet = taskService.createTaskQuery().processInstanceId(procInst.getId()).list();
  assertEquals(1, tasksAfterVariableIsSet.size());

  // then
  assertEquals(2, historyService.createHistoricVariableInstanceQuery().count());
  assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName(VARIABLE_NAME).count());
  assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("donotloseme").count());
}
 
Example #24
Source File: RuntimeServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Calling.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testCascadingDeleteSubprocessInstanceSkipIoMappings.Called.bpmn20.xml" })
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Test
public void testCascadingDeleteSubprocessInstanceWithoutSkipIoMappings() {

  // given a process instance
  ProcessInstance instance = runtimeService.startProcessInstanceByKey("callingProcess");

  ProcessInstance instance2 = runtimeService.createProcessInstanceQuery().superProcessInstanceId(instance.getId()).singleResult();

  // when the process instance is deleted and we do not skip the io mappings
  runtimeService.deleteProcessInstance(instance.getId(), "test_purposes", false, true, false);

  // then
  testRule.assertProcessEnded(instance.getId());
  assertEquals(2, historyService.createHistoricVariableInstanceQuery().processInstanceId(instance2.getId()).list().size());
  assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("inputMappingExecuted").count());
  assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableName("outputMappingExecuted").count());
}
 
Example #25
Source File: RuntimeServiceAsyncOperationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Deployment(resources = {
    "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
@Test
public void testDeleteProcessInstancesAsyncWithHistoryQuery() {
  // given
  List<String> processIds = startTestProcesses(2);
  HistoricProcessInstanceQuery historicProcessInstanceQuery =
      historyService.createHistoricProcessInstanceQuery()
          .processInstanceIds(new HashSet<>(processIds));

  // when
  Batch batch = runtimeService.deleteProcessInstancesAsync(null, null,
      historicProcessInstanceQuery, "", false, false);

  completeSeedJobs(batch);
  executeBatchJobs(batch);

  // then
  assertHistoricTaskDeletionPresent(processIds, "deleted", testRule);
  assertHistoricBatchExists(testRule);
  assertProcessInstancesAreDeleted();
}
 
Example #26
Source File: EmbeddedProcessApplicationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDeployAppWithCustomEngine() {

    TestApplicationWithCustomEngine processApplication = new TestApplicationWithCustomEngine();
    processApplication.deploy();

    ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("embeddedEngine");
    assertNotNull(processEngine);
    assertEquals("embeddedEngine", processEngine.getName());

    ProcessEngineConfiguration configuration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();

    // assert engine properties specified
    assertTrue(configuration.isJobExecutorDeploymentAware());
    assertTrue(configuration.isJobExecutorPreferTimerJobs());
    assertTrue(configuration.isJobExecutorAcquireByDueDate());
    assertEquals(5, configuration.getJdbcMaxActiveConnections());

    processApplication.undeploy();

  }
 
Example #27
Source File: BatchSetRemovalTimeRule.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void starting(Description description) {
  getProcessEngineConfiguration()
    .setHistoryRemovalTimeProvider(new DefaultHistoryRemovalTimeProvider())
    .setHistoryRemovalTimeStrategy(ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_START)
    .initHistoryRemovalTime();

  DefaultDmnEngineConfiguration dmnEngineConfiguration =
      getProcessEngineConfiguration().getDmnEngineConfiguration();

  ResetDmnConfigUtil.reset(dmnEngineConfiguration)
      .enableFeelLegacyBehavior(true)
      .init();

  ClockUtil.setCurrentTime(CURRENT_DATE);

  super.starting(description);
}
 
Example #28
Source File: RuntimeServiceAsyncOperationsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Deployment(resources = {
    "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
@Test
public void testDeleteProcessInstancesAsyncWithRuntimeAndHistoryQuery() {
  // given
  List<String> processIds = startTestProcesses(2);
  HistoricProcessInstanceQuery historicProcessInstanceQuery =
      historyService.createHistoricProcessInstanceQuery()
          .processInstanceId(processIds.get(0));

  ProcessInstanceQuery processInstanceQuery =
      runtimeService.createProcessInstanceQuery().processInstanceId(processIds.get(1));

  // when
  Batch batch = runtimeService.deleteProcessInstancesAsync(null, processInstanceQuery,
      historicProcessInstanceQuery, "", false, false);

  completeSeedJobs(batch);
  executeBatchJobs(batch);

  // then
  assertHistoricTaskDeletionPresent(processIds, "deleted", testRule);
  assertHistoricBatchExists(testRule);
  assertProcessInstancesAreDeleted();
}
 
Example #29
Source File: StandaloneTaskAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testRemoveVariable() {
  // given
  createTask(taskId);

  taskService.setVariable(taskId, VARIABLE_NAME, VARIABLE_VALUE);

  // when
  authRule
      .init(scenario)
      .withUser("userId")
      .bindResource("taskId", taskId)
      .start();

  taskService.removeVariable(taskId, VARIABLE_NAME);

  // then
  if (authRule.assertScenario(scenario)) {
    verifyRemoveVariable();
  }
}
 
Example #30
Source File: BoundedNumberOfMaxResultsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Test
public void shouldSyncUpdateExternalTaskRetriesProcInstQueryByHistProcInstQuery() {
  // given
  testHelper.deploy(externalTaskProcess);

  runtimeService.startProcessInstanceByKey("process");

  HistoricProcessInstanceQuery historicProcessInstanceQuery = engineRule.getHistoryService()
      .createHistoricProcessInstanceQuery();

  try {
    // when
    engineRule.getExternalTaskService().updateRetries()
        .historicProcessInstanceQuery(historicProcessInstanceQuery)
        .set(5);
    // then: no exception
  } catch (BadUserRequestException e) {
    fail("No exception expected!");
  }
}