Search in sources :

Example 46 with KModuleDeploymentUnit

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

the class ProcessServiceImplTest 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(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 47 with KModuleDeploymentUnit

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

the class DeploymentStoreTest method testEnableAndGetActiveDeploymentsWithTransientNamedObject.

@Test
public void testEnableAndGetActiveDeploymentsWithTransientNamedObject() {
    Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
    DeploymentDescriptor descriptor = unit.getDeploymentDescriptor();
    if (descriptor == null) {
        descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    }
    // add transient named object model that should not be persisted
    descriptor.getBuilder().addWorkItemHandler(new TransientNamedObjectModel("ejb", "async", "org.jbpm.executor.impl.wih.AsyncWorkItemHandler", new Object[] { "jndi:java:module/ExecutorServiceEJBImpl", "org.jbpm.executor.commands.PrintOutCommand" })).addEventListener(new TransientObjectModel("ejb", "not.existing.listener"));
    unit.setDeploymentDescriptor(descriptor);
    store.enableDeploymentUnit(unit);
    enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(1, enabled.size());
    DeploymentUnit unitEnabled = enabled.iterator().next();
    assertTrue(unitEnabled instanceof KModuleDeploymentUnit);
    DeploymentDescriptor descriptorEnabled = ((KModuleDeploymentUnit) unitEnabled).getDeploymentDescriptor();
    assertNotNull(descriptorEnabled);
    assertEquals(0, descriptorEnabled.getWorkItemHandlers().size());
    assertEquals(0, descriptorEnabled.getEventListeners().size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) TransientObjectModel(org.jbpm.runtime.manager.impl.deploy.TransientObjectModel) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) TransientNamedObjectModel(org.jbpm.runtime.manager.impl.deploy.TransientNamedObjectModel) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 48 with KModuleDeploymentUnit

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

the class DeploymentStoreTest method testEnableAndGetActiveDeployments.

@Test
public void testEnableAndGetActiveDeployments() {
    Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
    store.enableDeploymentUnit(unit);
    enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(1, enabled.size());
}
Also used : KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 49 with KModuleDeploymentUnit

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

the class ProcessInstanceAdminServiceImplTest method prepare.

@Before
public void prepare() {
    configureServices();
    logger.debug("Preparing kjar");
    KieServices ks = KieServices.Factory.get();
    // version 1 of kjar
    ReleaseId releaseId = ks.newReleaseId(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
    List<String> processes = new ArrayList<String>();
    processes.add("repo/processes/general/humanTask.bpmn");
    processes.add("repo/processes/general/BPMN2-IntermediateCatchEventTimerDuration.bpmn2");
    processes.add("repo/processes/errors/BPMN2-BrokenScriptTask.bpmn2");
    processes.add("repo/processes/errors/BPMN2-UserTaskWithRollback.bpmn2");
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
    File pom = new File("target/admin", "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.installArtifact(releaseId, kJar1, pom);
    processAdminService = new ProcessInstanceAdminServiceImpl();
    ((ProcessInstanceAdminServiceImpl) processAdminService).setProcessService(processService);
    ((ProcessInstanceAdminServiceImpl) processAdminService).setRuntimeDataService(runtimeDataService);
    ((ProcessInstanceAdminServiceImpl) processAdminService).setCommandService(new TransactionalCommandService(emf));
    ((ProcessInstanceAdminServiceImpl) processAdminService).setIdentityProvider(identityProvider);
    // now let's deploy to runtime both kjars
    deploymentUnit = new KModuleDeploymentUnit(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
}
Also used : ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) TransactionalCommandService(org.jbpm.shared.services.impl.TransactionalCommandService) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Example 50 with KModuleDeploymentUnit

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

the class ProcessInstanceMigrationServiceImplTest method prepare.

@Before
public void prepare() {
    configureServices();
    logger.debug("Preparing kjar");
    KieServices ks = KieServices.Factory.get();
    // version 1 of kjar
    ReleaseId releaseId = ks.newReleaseId(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V1);
    List<String> processes = new ArrayList<String>();
    processes.add("migration/v1/AddTaskAfterActive-v1.bpmn2");
    processes.add("migration/v1/RemoveActiveTask-v1.bpmn2");
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
    File pom = new File("target/migration-v1", "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.installArtifact(releaseId, kJar1, pom);
    // version 2 of kjar
    ReleaseId releaseId2 = ks.newReleaseId(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V2);
    processes = new ArrayList<String>();
    processes.add("migration/v2/AddTaskAfterActive-v2.bpmn2");
    processes.add("migration/v2/RemoveActiveTask-v2.bpmn2");
    InternalKieModule kJar2 = createKieJar(ks, releaseId2, processes);
    File pom2 = new File("target/migration-v2", "pom.xml");
    pom2.getParentFile().mkdirs();
    try {
        FileOutputStream fs = new FileOutputStream(pom2);
        fs.write(getPom(releaseId2).getBytes());
        fs.close();
    } catch (Exception e) {
    }
    repository = getKieMavenRepository();
    repository.installArtifact(releaseId2, kJar2, pom2);
    migrationService = new ProcessInstanceMigrationServiceImpl();
    // now let's deploy to runtime both kjars
    deploymentUnitV1 = new KModuleDeploymentUnit(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V1);
    deploymentService.deploy(deploymentUnitV1);
    units.add(deploymentUnitV1);
    deploymentUnitV2 = new KModuleDeploymentUnit(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V2);
    deploymentService.deploy(deploymentUnitV2);
    units.add(deploymentUnitV2);
}
Also used : ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) 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