use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class SetJobPriorityAuthorizationTest method testSetJobPriority.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testSetJobPriority() {
// given
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("process");
Job job = engineRule.getManagementService().createJobQuery().singleResult();
// when
authRule.init(scenario).withUser("userId").bindResource("processInstanceId", processInstance.getId()).bindResource("processDefinitionKey", "process").start();
engineRule.getManagementService().setJobPriority(job.getId(), 42);
// then
if (authRule.assertScenario(scenario)) {
Job updatedJob = engineRule.getManagementService().createJobQuery().singleResult();
Assert.assertEquals(42, updatedJob.getPriority());
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceAsyncTest method testMigrate.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testMigrate() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
authRule.init(scenario).withUser("userId").bindResource("sourceDefinitionKey", sourceDefinition.getKey()).bindResource("targetDefinitionKey", targetDefinition.getKey()).bindResource("processInstance", processInstance.getId()).start();
batch = engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).executeAsync();
// then
if (authRule.assertScenario(scenario)) {
Assert.assertEquals(1, engineRule.getManagementService().createBatchQuery().count());
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceAsyncTest method testMigrateWithQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testMigrateWithQuery() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
ProcessInstanceQuery query = engineRule.getRuntimeService().createProcessInstanceQuery();
// when
authRule.init(scenario).withUser("userId").bindResource("sourceDefinitionKey", sourceDefinition.getKey()).bindResource("targetDefinitionKey", targetDefinition.getKey()).bindResource("processInstance", processInstance.getId()).start();
batch = engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceQuery(query).executeAsync();
// then
if (authRule.assertScenario(scenario)) {
Assert.assertEquals(1, engineRule.getManagementService().createBatchQuery().count());
}
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class FallbackSerializerFactoryTest method testFallbackSerializerDoesNotOverrideRegularSerializer.
@Test
public void testFallbackSerializerDoesNotOverrideRegularSerializer() {
// given
// that the process engine is configured with a serializer for a certain format
// and a fallback serializer factory for the same format
ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose");
engineConfiguration.setCustomPreVariableSerializers(Arrays.<TypedValueSerializer>asList(new ExampleConstantSerializer()));
engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());
processEngine = engineConfiguration.buildProcessEngine();
deployOneTaskProcess(processEngine);
// when setting a variable that no regular serializer can handle
ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();
ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValueTyped("var", objectValue));
ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);
// then the fallback serializer is used
Assert.assertNotNull(fetchedValue);
Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
Assert.assertEquals(ExampleConstantSerializer.DESERIALIZED_VALUE, fetchedValue.getValue());
}
use of org.camunda.bpm.engine.runtime.ProcessInstance in project camunda-bpm-platform by camunda.
the class FallbackSerializerFactoryTest method testFallbackSerializer.
@Test
public void testFallbackSerializer() {
// given
// that the process engine is configured with a fallback serializer factory
ProcessEngineConfigurationImpl engineConfiguration = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose");
engineConfiguration.setFallbackSerializerFactory(new ExampleSerializerFactory());
processEngine = engineConfiguration.buildProcessEngine();
deployOneTaskProcess(processEngine);
// when setting a variable that no regular serializer can handle
ObjectValue objectValue = Variables.objectValue("foo").serializationDataFormat(ExampleSerializer.FORMAT).create();
ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", Variables.createVariables().putValueTyped("var", objectValue));
ObjectValue fetchedValue = processEngine.getRuntimeService().getVariableTyped(pi.getId(), "var", true);
// then the fallback serializer is used
Assert.assertNotNull(fetchedValue);
Assert.assertEquals(ExampleSerializer.FORMAT, fetchedValue.getSerializationDataFormat());
Assert.assertEquals("foo", fetchedValue.getValue());
}
Aggregations