Search in sources :

Example 36 with DeploymentUnit

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

the class QueryServiceEJBIntegrationTest method cleanup.

@After
public void cleanup() {
    if (query != null) {
        try {
            queryService.unregisterQuery(query.getName());
        } catch (QueryNotFoundException e) {
        }
    }
    if (processInstanceId != null) {
        // let's abort process instance to leave the system in clear state
        processService.abortProcessInstance(processInstanceId);
        ProcessInstance pi = processService.getProcessInstance(processInstanceId);
        assertNull(pi);
    }
    int deleted = 0;
    deleted += commandService.execute(new UpdateStringCommand("delete from  NodeInstanceLog nid"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  ProcessInstanceLog pid"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  VariableInstanceLog vsd"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  AuditTaskImpl vsd"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  TaskVariableImpl vsd"));
    System.out.println("Deleted " + deleted);
    cleanupSingletonSessionId();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
}
Also used : UpdateStringCommand(org.jbpm.shared.services.impl.commands.UpdateStringCommand) QueryNotFoundException(org.jbpm.services.api.query.QueryNotFoundException) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) After(org.junit.After)

Example 37 with DeploymentUnit

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

the class UserTaskServiceEJBIntegrationTest method cleanup.

@After
public void cleanup() {
    if (processInstanceId != null) {
        // let's abort process instance to leave the system in clear state
        processService.abortProcessInstance(processInstanceId);
        ProcessInstance pi = processService.getProcessInstance(processInstanceId);
        assertNull(pi);
    }
    int deleted = 0;
    deleted += commandService.execute(new UpdateStringCommand("delete from  NodeInstanceLog nid"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  ProcessInstanceLog pid"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  VariableInstanceLog vsd"));
    deleted += commandService.execute(new UpdateStringCommand("delete from  AuditTaskImpl vsd"));
    System.out.println("Deleted " + deleted);
    cleanupSingletonSessionId();
    if (units != null && !units.isEmpty()) {
        for (DeploymentUnit unit : units) {
            deploymentService.undeploy(unit);
        }
        units.clear();
    }
}
Also used : UpdateStringCommand(org.jbpm.shared.services.impl.commands.UpdateStringCommand) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) After(org.junit.After)

Example 38 with DeploymentUnit

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

the class DeploymentServiceEJBIntegrationTest method testDeploymentOfProcessesVerifyTransientObjectOmitted.

@Test
public void testDeploymentOfProcessesVerifyTransientObjectOmitted() {
    assertNotNull(deploymentService);
    assertNotNull(commandService);
    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());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    DeploymentStore store = new DeploymentStore();
    store.setCommandService(commandService);
    Collection<DeploymentUnit> units = store.getEnabledDeploymentUnits();
    assertNotNull(units);
    assertEquals(1, units.size());
    DeploymentUnit enabled = units.iterator().next();
    assertNotNull(enabled);
    assertTrue(enabled instanceof KModuleDeploymentUnit);
    KModuleDeploymentUnit kmoduleEnabled = (KModuleDeploymentUnit) enabled;
    DeploymentDescriptor dd = kmoduleEnabled.getDeploymentDescriptor();
    assertNotNull(dd);
    // ejb deployment service add transitively Async WorkItem handler that should not be stored as part of deployment store
    assertEquals(0, dd.getWorkItemHandlers().size());
}
Also used : DeploymentStore(org.jbpm.kie.services.impl.store.DeploymentStore) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) QueryContext(org.kie.api.runtime.query.QueryContext) 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 39 with DeploymentUnit

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

the class DeploymentServiceEJBIntegrationTest method testDeploymentOfAllProcesses.

@Test
public void testDeploymentOfAllProcesses() {
    assertNotNull(deploymentService);
    // deploy first unit
    DeploymentUnit deploymentUnitGeneral = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnitGeneral);
    units.add(deploymentUnitGeneral);
    RuntimeManager managerGeneral = deploymentService.getRuntimeManager(deploymentUnitGeneral.getIdentifier());
    assertNotNull(managerGeneral);
    // deploy second unit
    DeploymentUnit deploymentUnitSupport = new KModuleDeploymentUnit(GROUP_ID, "support", VERSION);
    deploymentService.deploy(deploymentUnitSupport);
    units.add(deploymentUnitSupport);
    DeployedUnit deployedGeneral = deploymentService.getDeployedUnit(deploymentUnitGeneral.getIdentifier());
    assertNotNull(deployedGeneral);
    assertNotNull(deployedGeneral.getDeploymentUnit());
    assertNotNull(deployedGeneral.getRuntimeManager());
    RuntimeManager managerSupport = deploymentService.getRuntimeManager(deploymentUnitSupport.getIdentifier());
    assertNotNull(managerSupport);
    DeployedUnit deployedSupport = deploymentService.getDeployedUnit(deploymentUnitSupport.getIdentifier());
    assertNotNull(deployedSupport);
    assertNotNull(deployedSupport.getDeploymentUnit());
    assertNotNull(deployedSupport.getRuntimeManager());
    // execute process that is bundled in first deployment unit
    RuntimeEngine engine = managerGeneral.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());
    // execute process that is in second deployment unit
    RuntimeEngine engineSupport = managerSupport.getRuntimeEngine(EmptyContext.get());
    assertNotNull(engineSupport);
    ProcessInstance supportPI = engineSupport.getKieSession().startProcess("support.process");
    assertEquals(ProcessInstance.STATE_ACTIVE, supportPI.getState());
    List<TaskSummary> tasks = engineSupport.getTaskService().getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    engineSupport.getKieSession().abortProcessInstance(supportPI.getId());
    assertNull(engineSupport.getKieSession().getProcessInstance(supportPI.getState()));
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) 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 40 with DeploymentUnit

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

the class DeploymentServiceEJBIntegrationTest method testDeploymentOfProcesses.

@Test
public void testDeploymentOfProcesses() {
    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());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(5, processes.size());
    processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(5, 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());
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) HashMap(java.util.HashMap) 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) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

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