Search in sources :

Example 36 with DeployedUnit

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

the class EDeploymentTest method testUndeploy.

@Test
public void testUndeploy() {
    DeploymentUnit basicKieJar = archive.deployBasicKieJar();
    DeployedUnit deployed = deploymentService.getDeployedUnit(basicKieJar.getIdentifier());
    Assertions.assertThat(deployed).isNotNull();
    archive.undeployDeploymentUnit(basicKieJar);
    DeployedUnit undeployed = deploymentService.getDeployedUnit(basicKieJar.getIdentifier());
    Assertions.assertThat(undeployed).isNull();
}
Also used : DeployedUnit(org.jbpm.services.api.model.DeployedUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) Test(org.junit.Test) AbstractEJBServicesTest(org.jbpm.test.container.AbstractEJBServicesTest)

Example 37 with DeployedUnit

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

the class DeploymentServiceWithSyncTest method testDeactivateAndActivateOfProcessesBySync.

@Test
public void testDeactivateAndActivateOfProcessesBySync() throws Exception {
    CoundDownDeploymentListener countDownListener = configureListener(2, false, false, true, true);
    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());
    assertTrue(deployed.iterator().next().isActive());
    store.deactivateDeploymentUnit(unit);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    assertFalse(deployed.iterator().next().isActive());
    store.activateDeploymentUnit(unit);
    countDownListener.reset(1);
    countDownListener.waitTillCompleted(10000);
    deployed = deploymentService.getDeployedUnits();
    assertNotNull(deployed);
    assertEquals(1, deployed.size());
    assertTrue(deployed.iterator().next().isActive());
}
Also used : CoundDownDeploymentListener(org.jbpm.kie.services.test.objects.CoundDownDeploymentListener) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 38 with DeployedUnit

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

the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromOrderPackage.

@Test
public void testDeploymentOfProcessesFromOrderPackage() {
    prepare("order.repo.processes.general");
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", deployed.getDeploymentUnit().getIdentifier());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "Import");
    assertNotNull(process);
}
Also used : 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 39 with DeployedUnit

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

the class FilteredKModuleDeploymentServiceTest method verifyDeployedUnitContainsCorrectClasses.

private void verifyDeployedUnitContainsCorrectClasses(DeploymentUnit deploymentUnit) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    DeploymentDescriptor descriptor = ((KModuleDeploymentUnit) deployedUnit.getDeploymentUnit()).getDeploymentDescriptor();
    boolean limitClasses = descriptor.getLimitSerializationClasses();
    boolean unAnnotatedClassesFound = false;
    for (Class<?> depdClass : deployedUnit.getDeployedClasses()) {
        Annotation[] declAnnos = depdClass.getDeclaredAnnotations();
        boolean xmlOrRemotAnnoFound = false;
        for (Annotation depdClassAnno : declAnnos) {
            Class annoType = depdClassAnno.annotationType();
            if (XmlRootElement.class.equals(annoType) || Remotable.class.equals(annoType)) {
                xmlOrRemotAnnoFound = true;
                break;
            }
        }
        assertTrue("Expected to find annotations on " + depdClass.getSimpleName(), (xmlOrRemotAnnoFound && limitClasses) || !limitClasses);
        if (!xmlOrRemotAnnoFound) {
            unAnnotatedClassesFound = true;
        }
    }
    assertTrue("Expected to find unannotated classes in " + deployedUnit.getDeploymentUnit().getIdentifier(), (limitClasses && !unAnnotatedClassesFound) || (!limitClasses && unAnnotatedClassesFound));
    if (limitClasses) {
        try {
            JAXBContext.newInstance(deployedUnit.getDeployedClasses().toArray(new Class[0]));
        } catch (JAXBException e) {
            e.printStackTrace();
            fail("JAXBContext creation with deployed unit classes failed: " + e.getMessage());
        }
    }
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) JAXBException(javax.xml.bind.JAXBException) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) Remotable(org.kie.api.remote.Remotable) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Annotation(java.lang.annotation.Annotation)

Example 40 with DeployedUnit

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

the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromCustomerPackage.

@Test
public void testDeploymentOfProcessesFromCustomerPackage() {
    prepare("customer.repo.processes.general");
    assertNotNull(deploymentService);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployed);
    assertNotNull(deployed.getDeploymentUnit());
    assertNotNull(deployed.getRuntimeManager());
    assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", deployed.getDeploymentUnit().getIdentifier());
    assertNotNull(runtimeDataService);
    Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
    assertNotNull(processes);
    assertEquals(1, processes.size());
    processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
    assertNotNull(processes);
    assertEquals(2, processes.size());
    ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
    assertNotNull(process);
}
Also used : 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) 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