Search in sources :

Example 31 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit 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)

Example 32 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit 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 33 with DeployedUnit

use of org.jbpm.services.api.model.DeployedUnit 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 34 with DeployedUnit

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

the class DeploymentServiceEJBWithSyncIntegrationTest method testUndeploymentOfProcessesBySync.

@Test
public void testUndeploymentOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(2);
    DeploymentStore store = new DeploymentStore();
    store.setCommandService(commandService);
    Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(unit);
    units.add(unit);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    countDownListener.waitTillCompleted(1000);
    store.disableDeploymentUnit(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
}
Also used : DeploymentStore(org.jbpm.kie.services.impl.store.DeploymentStore) CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Example 35 with DeployedUnit

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

the class DeploymentServiceEJBWithSyncIntegrationTest method testDeploymentOfProcessesBySync.

@Test
public void testDeploymentOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(1);
    DeploymentStore store = new DeploymentStore();
    store.setCommandService(commandService);
    Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(0, deployed.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    store.enableDeploymentUnit(unit);
    units.add(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
}
Also used : DeploymentStore(org.jbpm.kie.services.impl.store.DeploymentStore) CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Test(org.junit.Test)

Aggregations

DeployedUnit (org.jbpm.services.api.model.DeployedUnit)69 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)42 Test (org.junit.Test)41 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)38 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)37 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)32 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)30 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)28 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)20 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)19 QueryContext (org.kie.api.runtime.query.QueryContext)19 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)18 KieSession (org.kie.api.runtime.KieSession)17 HashMap (java.util.HashMap)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)13 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)13 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)10 ArrayList (java.util.ArrayList)8 CoundDownDeploymentListener (org.jbpm.kie.services.test.objects.CoundDownDeploymentListener)8 File (java.io.File)7