Search in sources :

Example 96 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit 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 97 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit 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 98 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit 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 99 with KModuleDeploymentUnit

use of org.jbpm.kie.services.impl.KModuleDeploymentUnit 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)

Example 100 with KModuleDeploymentUnit

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

the class FilteredKModuleDeploymentServiceTest method testSerializationClassesLimitedInDeploymentItself.

@Test
public void testSerializationClassesLimitedInDeploymentItself() {
    String groupId = "org.test";
    String artifactId = "jbpm-kie-services-filter-test";
    String version = VERSION;
    FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(artifactId).setVersion(version).addClass(Building.class, House.class, Person.class, OtherPerson.class, Thing.class).createKieJarAndDeployToMaven();
    KModuleDeploymentUnit limitDeploymentUnit = new KModuleDeploymentUnit(groupId, artifactId, version);
    FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(artifactId + "-all").setVersion(version).addClass(Building.class, House.class, Person.class, OtherPerson.class, Thing.class).createKieJarAndDeployToMaven();
    KModuleDeploymentUnit allDeploymentUnit = new KModuleDeploymentUnit(groupId, artifactId + "-all", version);
    configureServices();
    DeploymentDescriptor depDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(true).get();
    limitDeploymentUnit.setDeploymentDescriptor(depDesc);
    deploymentService.deploy(limitDeploymentUnit);
    verifyDeployedUnitContainsCorrectClasses(limitDeploymentUnit);
    depDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(false).get();
    allDeploymentUnit.setDeploymentDescriptor(depDesc);
    deploymentService.deploy(allDeploymentUnit);
    verifyDeployedUnitContainsCorrectClasses(allDeploymentUnit);
}
Also used : Building(org.jbpm.kie.test.objects.Building) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) House(org.jbpm.kie.test.objects.House) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Person(org.jbpm.kie.test.objects.Person) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) Thing(org.jbpm.kie.test.objects.Thing) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

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