Search in sources :

Example 91 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithoutAuditTest method testStartAndAbortProcess.

@Test
public void testStartAndAbortProcess() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNotNull(pi);
    processService.abortProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId);
    assertNull(pi);
}
Also used : ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 92 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithoutAuditTest method testStartAndSignalProcesses.

@Test
public void testStartAndSignalProcesses() {
    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);
    // first start first instance
    long processInstanceId1 = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
    assertNotNull(processInstanceId1);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId1);
    assertNotNull(pi);
    // then start second instance
    long processInstanceId2 = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.signal");
    assertNotNull(processInstanceId2);
    ProcessInstance pi2 = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId2);
    assertNotNull(pi2);
    List<Long> instances = new ArrayList<Long>();
    instances.add(processInstanceId1);
    instances.add(processInstanceId2);
    // and lastly cancel both
    processService.signalProcessInstances(deploymentUnit.getIdentifier(), instances, "MySignal", null);
    pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId1);
    assertNull(pi);
    pi2 = processService.getProcessInstance(deploymentUnit.getIdentifier(), processInstanceId2);
    assertNull(pi2);
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 93 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class ProcessServiceImplWithoutAuditTest method testStartProcessWithCorrelationKey.

@Test
public void testStartProcessWithCorrelationKey() {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "customtask", key);
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(deploymentUnit.getIdentifier(), key);
    assertNull(pi);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 94 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class QueryServiceImplTest method prepareJPAModule.

protected void prepareJPAModule(KieServices ks, KieMavenRepository repository) {
    // jpa module
    ReleaseId releaseIdJPA = ks.newReleaseId("org.jbpm.test", "persistence-test", "1.0.0");
    File kjarJPA = new File("src/test/resources/kjar-jpa/persistence-test.jar");
    File pomJPA = new File("src/test/resources/kjar-jpa/pom.xml");
    repository.installArtifact(releaseIdJPA, kjarJPA, pomJPA);
    deploymentUnitJPA = new KModuleDeploymentUnit("org.jbpm.test", "persistence-test", "1.0.0");
}
Also used : ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) File(java.io.File)

Example 95 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.

the class RuntimeDataServiceImplTaskLookupTest 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");
    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/BPMN2-UserTasksAssignedToGroup.bpmn2");
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
    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);
}
Also used : FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) File(java.io.File) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Aggregations

KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)170 Test (org.junit.Test)131 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)97 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)83 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)55 HashMap (java.util.HashMap)46 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)42 ArrayList (java.util.ArrayList)34 QueryContext (org.kie.api.runtime.query.QueryContext)34 ReleaseId (org.kie.api.builder.ReleaseId)29 KieServices (org.kie.api.KieServices)26 File (java.io.File)22 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)22 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)21 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)19 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)19 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)19 Before (org.junit.Before)18 FileOutputStream (java.io.FileOutputStream)17 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)17