use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithoutAuditTest method testStartProcess.
@Test
public void testStartProcess() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceImplWithoutAuditTest method testStartProcessAndChangeVariables.
@Test
public void testStartProcessAndChangeVariables() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "test");
params.put("approval_reviewComment", "need review");
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(pi);
// get variable by name
Object variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_document");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("test", variableValue);
// get all variables
Map<String, Object> variables = processService.getProcessInstanceVariables(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(variables);
assertEquals(2, variables.size());
assertTrue(variables.containsKey("approval_document"));
assertTrue(variables.containsKey("approval_reviewComment"));
assertEquals("test", variables.get("approval_document"));
assertEquals("need review", variables.get("approval_reviewComment"));
// now change single variable
processService.setProcessVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment", "updated review comment");
// let's verify it
variableValue = processService.getProcessInstanceVariable(deploymentUnit.getIdentifier(), processInstanceId, "approval_reviewComment");
assertNotNull(variableValue);
assertTrue(variableValue instanceof String);
assertEquals("updated review comment", variableValue);
// and lastly let's update both variables
params = new HashMap<String, Object>();
params.put("approval_document", "updated document");
params.put("approval_reviewComment", "final review");
processService.setProcessVariables(deploymentUnit.getIdentifier(), processInstanceId, params);
variables = processService.getProcessInstanceVariables(deploymentUnit.getIdentifier(), processInstanceId);
assertNotNull(variables);
assertEquals(2, variables.size());
assertTrue(variables.containsKey("approval_document"));
assertTrue(variables.containsKey("approval_reviewComment"));
assertEquals("updated document", variables.get("approval_document"));
assertEquals("final review", variables.get("approval_reviewComment"));
processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
assertNull(pi);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ProcessServiceWithEntitiesTest method testStartProcessAndGetVariables.
@Test
public void testStartProcessAndGetVariables() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
Map<String, Object> params = new HashMap<String, Object>();
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "processvarentity", params);
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
Map<String, Object> variables = processService.getProcessInstanceVariables(processInstanceId);
assertNotNull(variables);
assertEquals(1, variables.size());
assertTrue(variables.containsKey("caseDetails"));
VariableEntity varEntity = (VariableEntity) variables.get("caseDetails");
// make sure getting mapped variables does NOT throw LazyInitializationException
Set<MappedVariable> mappedVariables = varEntity.getMappedVariables();
try {
assertEquals(1, mappedVariables.size());
MappedVariable mappedVariable = mappedVariables.iterator().next();
assertEquals("example.CaseDetail", mappedVariable.getVariableType());
} catch (LazyInitializationException e) {
fail("Unable to retrieve mapped variables : " + e.getMessage());
}
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class QueryServiceImplTest method prepare.
@Before
public void prepare() {
System.setProperty("org.jbpm.ht.callback", "custom");
System.setProperty("org.jbpm.ht.custom.callback", "org.jbpm.kie.services.test.objects.TestUserGroupCallbackImpl");
this.dataSourceJNDIname = getDataSourceJNDI();
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/EmptyHumanTask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/BPMN2-UserTask.bpmn2");
processes.add("repo/processes/general/SimpleHTProcess.bpmn2");
processes.add("repo/processes/general/AdHocSubProcess.bpmn2");
processes.add("repo/processes/general/ExcludedOwner.bpmn2");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addRequiredRole("view:managers");
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, pom);
assertNotNull(deploymentService);
deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
prepareJPAModule(ks, repository);
assertNotNull(processService);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method prepare.
@Before
public void prepare() {
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/EmptyHumanTask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/BPMN2-UserTask.bpmn2");
processes.add("repo/processes/general/timer-process.bpmn2");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addEventListener(new ObjectModel("mvel", "org.jbpm.kie.test.util.CountDownListenerFactory.get(\"securityTest\", \"timer\", 1)")).addRequiredRole("view:managers").addRequiredRole("execute:employees");
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, pom);
assertNotNull(deploymentService);
deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
identityProvider.setRoles(Arrays.asList("employees"));
}
Aggregations