Search in sources :

Example 41 with DeploymentUnit

use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.

the class DeploymentServiceEJBIntegrationTest method testDuplicatedDeployment.

@Test
public void testDuplicatedDeployment() {
    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());
    try {
        // duplicated deployment of the same deployment unit should fail
        deploymentService.deploy(deploymentUnit);
    } catch (Exception e) {
        assertTrue(e.getMessage().endsWith("Unit with id org.jbpm.test:test-module:1.0.0-SNAPSHOT is already deployed"));
    }
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Example 42 with DeploymentUnit

use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.

the class DeploymentServiceEJBIntegrationTest method testDeploymentOfProcessesWithActivation.

@Test
public void testDeploymentOfProcessesWithActivation() {
    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());
    assertTrue(deployed.isActive());
    assertEquals(0, ((DeployedUnitImpl) deployed).getDeployedClasses().size());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    // then deactivate it
    deploymentService.deactivate(deploymentUnit.getIdentifier());
    deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertFalse(deployed.isActive());
    processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(0, processes.size());
    // and not activate it again
    deploymentService.activate(deploymentUnit.getIdentifier());
    deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertTrue(deployed.isActive());
    processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeployedUnitImpl(org.jbpm.kie.services.impl.DeployedUnitImpl) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Example 43 with DeploymentUnit

use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.

the class ClientProcessServiceWithCustomDataEJBTest method cleanup.

@After
public void cleanup() {
    if (processInstanceId != null) {
        // let's abort process instance to leave the system in clear state
        processService.abortProcessInstance(processInstanceId);
    }
    Thread.currentThread().setContextClassLoader(originClassLoader);
    cleanupSingletonSessionId();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
    close();
}
Also used : DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) After(org.junit.After)

Example 44 with DeploymentUnit

use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.

the class AbstractEJBServicesTest method cleanup.

@After
public void cleanup() {
    cleanupSingletonSessionId();
    List<DeploymentUnit> units = archive.getUnits();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
}
Also used : DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) After(org.junit.After)

Example 45 with DeploymentUnit

use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.

the class AbstractRuntimeEJBServicesTest method cleanup.

@After
@Override
public void cleanup() {
    List<Long> pids = archive.getPids();
    List<Long> all = (List<Long>) ((ArrayList<Long>) pids).clone();
    for (Long pid : all) {
        ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(pid);
        if (pi == null || pi.getState() != ProcessInstance.STATE_ACTIVE) {
            pids.remove(pid);
        }
    }
    if (!pids.isEmpty()) {
        processService.abortProcessInstances(pids);
    }
    pids.clear();
    cleanupSingletonSessionId();
    List<DeploymentUnit> units = archive.getUnits();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            // clear audit logs
            RuntimeManager manager = deploymentService.getRuntimeManager(unit.getIdentifier());
            RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
            engine.getAuditService().clear();
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
    kieJar = null;
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) ArrayList(java.util.ArrayList) List(java.util.List) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) After(org.junit.After)

Aggregations

DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)104 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)88 Test (org.junit.Test)53 After (org.junit.After)35 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)34 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)28 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)25 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)19 HashMap (java.util.HashMap)16 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)15 ArrayList (java.util.ArrayList)14 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)13 QueryContext (org.kie.api.runtime.query.QueryContext)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)12 KieServices (org.kie.api.KieServices)10 ReleaseId (org.kie.api.builder.ReleaseId)10 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)9 AbstractEJBServicesTest (org.jbpm.test.container.AbstractEJBServicesTest)8 Collection (java.util.Collection)6 DeployedUnitImpl (org.jbpm.kie.services.impl.DeployedUnitImpl)6