use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromCustomerPackage.
@Test
public void testDeploymentOfProcessesFromCustomerPackage() {
prepare("customer.repo.processes.general");
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromCustomerPackageDeafultKBase.
@Test
public void testDeploymentOfProcessesFromCustomerPackageDeafultKBase() {
prepare("customer.repo.processes.general");
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION, deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class KModuleDeploymentServiceTest method testDeploymentOfProcessWithDescriptorWitSecurityManager.
@Test(expected = SecurityException.class)
public void testDeploymentOfProcessWithDescriptorWitSecurityManager() {
assertNotNull(deploymentService);
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, "kjar-with-dd", VERSION);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/customtask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/import.bpmn");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE).addWorkItemHandler(new NamedObjectModel("Log", "org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler")).addRequiredRole("experts");
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);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, "kjar-with-dd", VERSION, "KBase-test", "ksession-test2");
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployedGeneral = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployedGeneral);
assertNotNull(deployedGeneral.getDeploymentUnit());
assertNotNull(deployedGeneral.getRuntimeManager());
DeploymentDescriptor descriptor = ((InternalRuntimeManager) deployedGeneral.getRuntimeManager()).getDeploymentDescriptor();
assertNotNull(descriptor);
assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, descriptor.getAuditMode());
assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, descriptor.getRuntimeStrategy());
assertEquals(0, descriptor.getMarshallingStrategies().size());
assertEquals(0, descriptor.getConfiguration().size());
assertEquals(0, descriptor.getEnvironmentEntries().size());
assertEquals(0, descriptor.getEventListeners().size());
assertEquals(0, descriptor.getGlobals().size());
assertEquals(0, descriptor.getTaskEventListeners().size());
assertEquals(1, descriptor.getWorkItemHandlers().size());
assertEquals(1, descriptor.getRequiredRoles().size());
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
manager.getRuntimeEngine(EmptyContext.get());
checkFormsDeployment(deploymentUnit.getIdentifier());
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class KModuleDeploymentServiceTest method testUnDeploymentWithActiveProcesses.
@Test
public void testUnDeploymentWithActiveProcesses() {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployedGeneral = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployedGeneral);
assertNotNull(deployedGeneral.getDeploymentUnit());
assertNotNull(deployedGeneral.getRuntimeManager());
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = engine.getKieSession().startProcess("org.jbpm.writedocument", params);
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
try {
// undeploy should fail due to active process instances
deploymentService.undeploy(deploymentUnit);
fail("Should fail due to active process instance");
} catch (IllegalStateException e) {
}
engine.getKieSession().abortProcessInstance(processInstance.getId());
checkFormsDeployment(deploymentUnit.getIdentifier());
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class KModuleDeploymentServiceTest method testDeploymentOfProcessesOnDefaultKbaseAndKsession.
@Test
public void testDeploymentOfProcessesOnDefaultKbaseAndKsession() {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertNull(deployed.getDeployedAssetLocation("customtask"));
assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION, deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(3, processes.size());
processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(3, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
Map<String, Object> params = new HashMap<String, Object>();
params.put("id", "test");
ProcessInstance processInstance = engine.getKieSession().startProcess("customtask", params);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
checkFormsDeployment(deploymentUnit.getIdentifier());
}
Aggregations