Search in sources :

Example 26 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class SupportProcessBaseTest method prepare.

@Before
public void prepare() {
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    List<String> processes = new ArrayList<String>();
    processes.add("repo/processes/support/support.bpmn");
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().addTaskEventListener(new ObjectModel("org.jbpm.services.cdi.test.ext.DebugTaskLifeCycleEventListener"));
    Map<String, String> resources = new HashMap<String, String>();
    resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
    File pom = new File("target/kmodule", "pom.xml");
    pom.getParentFile().mkdir();
    try {
        FileOutputStream fs = new FileOutputStream(pom);
        fs.write(getPom(releaseId).getBytes());
        fs.close();
    } catch (Exception e) {
    }
    KieMavenRepository repository = getKieMavenRepository();
    repository.deployArtifact(releaseId, kJar1, pom);
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Example 27 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project drools by kiegroup.

the class DeploymentDescriptorTest method testEmptyDeploymentDescriptor.

@Test
public void testEmptyDeploymentDescriptor() {
    DeploymentDescriptorImpl descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    descriptor.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.testCustomStrategy", new Object[] { new ObjectModel("java.lang.String", new Object[] { "param1" }), "param2" })).addRequiredRole("experts");
    assertFalse(descriptor.isEmpty());
    InputStream input = this.getClass().getResourceAsStream("/deployment/empty-descriptor.xml");
    DeploymentDescriptor fromXml = DeploymentDescriptorIO.fromXml(input);
    assertNotNull(fromXml);
    assertTrue(((DeploymentDescriptorImpl) fromXml).isEmpty());
    assertNull(fromXml.getPersistenceUnit());
    assertNull(fromXml.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, fromXml.getAuditMode());
    assertEquals(PersistenceMode.JPA, fromXml.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, fromXml.getRuntimeStrategy());
    assertEquals(0, fromXml.getMarshallingStrategies().size());
    assertEquals(0, fromXml.getConfiguration().size());
    assertEquals(0, fromXml.getEnvironmentEntries().size());
    assertEquals(0, fromXml.getEventListeners().size());
    assertEquals(0, fromXml.getGlobals().size());
    assertEquals(0, fromXml.getTaskEventListeners().size());
    assertEquals(0, fromXml.getWorkItemHandlers().size());
    assertEquals(0, fromXml.getRequiredRoles().size());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 28 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project drools by kiegroup.

the class DeploymentDescriptorTest method testCreateDeploymentDescriptorWithSetters.

@Test
public void testCreateDeploymentDescriptorWithSetters() {
    DeploymentDescriptorImpl descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    descriptor.setAuditMode(AuditMode.JMS);
    descriptor.setEnvironmentEntries(null);
    List<ObjectModel> marshallingStrategies = new ArrayList<ObjectModel>();
    marshallingStrategies.add(new ObjectModel("org.jbpm.testCustomStrategy", new Object[] { new ObjectModel("java.lang.String", new Object[] { "param1" }), "param2" }));
    descriptor.setMarshallingStrategies(marshallingStrategies);
    List<String> roles = new ArrayList<String>();
    roles.add("experts");
    descriptor.setRequiredRoles(roles);
    assertNotNull(descriptor);
    assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, descriptor.getRuntimeStrategy());
    assertEquals(1, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(0, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(0, descriptor.getWorkItemHandlers().size());
    assertEquals(1, descriptor.getRequiredRoles().size());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project drools by kiegroup.

the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeOverrideEmpty.

@Test
public void testDeploymentDesciptorMergeOverrideEmpty() {
    DeploymentDescriptor primary = new DeploymentDescriptorImpl("org.jbpm.domain");
    primary.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(true);
    assertNotNull(primary);
    assertEquals("org.jbpm.domain", primary.getPersistenceUnit());
    assertEquals("org.jbpm.domain", primary.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, primary.getAuditMode());
    assertEquals(PersistenceMode.JPA, primary.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, primary.getRuntimeStrategy());
    assertEquals(1, primary.getMarshallingStrategies().size());
    assertEquals(0, primary.getConfiguration().size());
    assertEquals(0, primary.getEnvironmentEntries().size());
    assertEquals(0, primary.getEventListeners().size());
    assertEquals(0, primary.getGlobals().size());
    assertEquals(0, primary.getTaskEventListeners().size());
    assertEquals(0, primary.getWorkItemHandlers().size());
    assertTrue(primary.getLimitSerializationClasses());
    DeploymentDescriptor secondary = new DeploymentDescriptorImpl("org.jbpm.domain");
    secondary.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit(null).auditPersistenceUnit("");
    assertNotNull(secondary);
    assertEquals(null, secondary.getPersistenceUnit());
    assertEquals("", secondary.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, secondary.getAuditMode());
    assertEquals(PersistenceMode.JPA, secondary.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, secondary.getRuntimeStrategy());
    assertEquals(0, secondary.getMarshallingStrategies().size());
    assertEquals(0, secondary.getConfiguration().size());
    assertEquals(0, secondary.getEnvironmentEntries().size());
    assertEquals(0, secondary.getEventListeners().size());
    assertEquals(0, secondary.getGlobals().size());
    assertEquals(0, secondary.getTaskEventListeners().size());
    assertEquals(0, secondary.getWorkItemHandlers().size());
    ((DeploymentDescriptorImpl) secondary).setLimitSerializationClasses(null);
    assertNull(secondary.getLimitSerializationClasses());
    // and now let's merge them
    DeploymentDescriptor outcome = DeploymentDescriptorMerger.merge(primary, secondary, MergeMode.OVERRIDE_EMPTY);
    assertNotNull(outcome);
    assertEquals("org.jbpm.domain", outcome.getPersistenceUnit());
    assertEquals("org.jbpm.domain", outcome.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, outcome.getAuditMode());
    assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, outcome.getRuntimeStrategy());
    assertEquals(1, outcome.getMarshallingStrategies().size());
    assertEquals(0, outcome.getConfiguration().size());
    assertEquals(0, outcome.getEnvironmentEntries().size());
    assertEquals(0, outcome.getEventListeners().size());
    assertEquals(0, outcome.getGlobals().size());
    assertEquals(0, outcome.getTaskEventListeners().size());
    assertEquals(0, outcome.getWorkItemHandlers().size());
    assertTrue(outcome.getLimitSerializationClasses());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 30 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project drools by kiegroup.

the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeHierarchy.

@Test
public void testDeploymentDesciptorMergeHierarchy() {
    DeploymentDescriptor primary = new DeploymentDescriptorImpl("org.jbpm.domain");
    primary.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" }));
    assertNotNull(primary);
    assertEquals("org.jbpm.domain", primary.getPersistenceUnit());
    assertEquals("org.jbpm.domain", primary.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, primary.getAuditMode());
    assertEquals(PersistenceMode.JPA, primary.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, primary.getRuntimeStrategy());
    assertEquals(1, primary.getMarshallingStrategies().size());
    assertEquals(0, primary.getConfiguration().size());
    assertEquals(0, primary.getEnvironmentEntries().size());
    assertEquals(0, primary.getEventListeners().size());
    assertEquals(0, primary.getGlobals().size());
    assertEquals(0, primary.getTaskEventListeners().size());
    assertEquals(0, primary.getWorkItemHandlers().size());
    DeploymentDescriptor secondary = new DeploymentDescriptorImpl("org.jbpm.domain");
    secondary.getBuilder().auditMode(AuditMode.NONE).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit").auditPersistenceUnit("my.custom.unit2");
    assertNotNull(secondary);
    assertEquals("my.custom.unit", secondary.getPersistenceUnit());
    assertEquals("my.custom.unit2", secondary.getAuditPersistenceUnit());
    assertEquals(AuditMode.NONE, secondary.getAuditMode());
    assertEquals(PersistenceMode.JPA, secondary.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, secondary.getRuntimeStrategy());
    assertEquals(0, secondary.getMarshallingStrategies().size());
    assertEquals(0, secondary.getConfiguration().size());
    assertEquals(0, secondary.getEnvironmentEntries().size());
    assertEquals(0, secondary.getEventListeners().size());
    assertEquals(0, secondary.getGlobals().size());
    assertEquals(0, secondary.getTaskEventListeners().size());
    assertEquals(0, secondary.getWorkItemHandlers().size());
    DeploymentDescriptor third = new DeploymentDescriptorImpl("org.jbpm.domain");
    third.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit2").auditPersistenceUnit("my.custom.altered").runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE).addEnvironmentEntry(new NamedObjectModel("IS_JTA", "java.lang.Boolean", new Object[] { "false" }));
    assertNotNull(third);
    assertEquals("my.custom.unit2", third.getPersistenceUnit());
    assertEquals("my.custom.altered", third.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, third.getAuditMode());
    assertEquals(PersistenceMode.JPA, third.getPersistenceMode());
    assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, third.getRuntimeStrategy());
    assertEquals(0, third.getMarshallingStrategies().size());
    assertEquals(0, third.getConfiguration().size());
    assertEquals(1, third.getEnvironmentEntries().size());
    assertEquals(0, third.getEventListeners().size());
    assertEquals(0, third.getGlobals().size());
    assertEquals(0, third.getTaskEventListeners().size());
    assertEquals(0, third.getWorkItemHandlers().size());
    // assemble hierarchy
    List<DeploymentDescriptor> hierarchy = new ArrayList<DeploymentDescriptor>();
    hierarchy.add(third);
    hierarchy.add(secondary);
    hierarchy.add(primary);
    // and now let's merge them
    DeploymentDescriptor outcome = DeploymentDescriptorMerger.merge(hierarchy, MergeMode.MERGE_COLLECTIONS);
    assertNotNull(outcome);
    assertEquals("my.custom.unit2", outcome.getPersistenceUnit());
    assertEquals("my.custom.altered", outcome.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, outcome.getAuditMode());
    assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
    assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, outcome.getRuntimeStrategy());
    assertEquals(1, outcome.getMarshallingStrategies().size());
    assertEquals(0, outcome.getConfiguration().size());
    assertEquals(1, outcome.getEnvironmentEntries().size());
    assertEquals(0, outcome.getEventListeners().size());
    assertEquals(0, outcome.getGlobals().size());
    assertEquals(0, outcome.getTaskEventListeners().size());
    assertEquals(0, outcome.getWorkItemHandlers().size());
}
Also used : NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ObjectModel (org.kie.internal.runtime.conf.ObjectModel)56 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)40 Test (org.junit.Test)34 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)34 ArrayList (java.util.ArrayList)16 ObjectModelResolver (org.kie.internal.runtime.conf.ObjectModelResolver)10 HashMap (java.util.HashMap)9 SimpleCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject)9 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 EmbedingCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject)6 ThirdLevelCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject)6 KieServices (org.kie.api.KieServices)6 DeploymentDescriptorBuilder (org.kie.internal.runtime.conf.DeploymentDescriptorBuilder)6 ReleaseId (org.kie.api.builder.ReleaseId)5 KieMavenRepository (org.kie.scanner.KieMavenRepository)5 File (java.io.File)4 Before (org.junit.Before)4 Cacheable (org.kie.internal.runtime.Cacheable)4