Search in sources :

Example 36 with ObjectModel

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

the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeKeepAll.

@Test
public void testDeploymentDesciptorMergeKeepAll() {
    DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
    master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(true);
    assertNotNull(master);
    assertEquals("org.jbpm.domain", master.getPersistenceUnit());
    assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, master.getAuditMode());
    assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
    assertEquals(1, master.getMarshallingStrategies().size());
    assertEquals(0, master.getConfiguration().size());
    assertEquals(0, master.getEnvironmentEntries().size());
    assertEquals(0, master.getEventListeners().size());
    assertEquals(0, master.getGlobals().size());
    assertEquals(0, master.getTaskEventListeners().size());
    assertEquals(0, master.getWorkItemHandlers().size());
    assertTrue(master.getLimitSerializationClasses());
    DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
    slave.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit").auditPersistenceUnit("my.custom.unit2").setLimitSerializationClasses(false);
    assertNotNull(slave);
    assertEquals("my.custom.unit", slave.getPersistenceUnit());
    assertEquals("my.custom.unit2", slave.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, slave.getAuditMode());
    assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
    assertEquals(0, slave.getMarshallingStrategies().size());
    assertEquals(0, slave.getConfiguration().size());
    assertEquals(0, slave.getEnvironmentEntries().size());
    assertEquals(0, slave.getEventListeners().size());
    assertEquals(0, slave.getGlobals().size());
    assertEquals(0, slave.getTaskEventListeners().size());
    assertEquals(0, slave.getWorkItemHandlers().size());
    assertFalse(slave.getLimitSerializationClasses());
    // and now let's merge them
    DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
    DeploymentDescriptor outcome = merger.merge(master, slave, MergeMode.KEEP_ALL);
    assertNotNull(outcome);
    assertEquals("org.jbpm.domain", outcome.getPersistenceUnit());
    assertEquals("org.jbpm.domain", outcome.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, 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 37 with ObjectModel

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

the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeOverrideAll.

@Test
public void testDeploymentDesciptorMergeOverrideAll() {
    DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
    master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(true);
    assertNotNull(master);
    assertEquals("org.jbpm.domain", master.getPersistenceUnit());
    assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, master.getAuditMode());
    assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
    assertEquals(1, master.getMarshallingStrategies().size());
    assertEquals(0, master.getConfiguration().size());
    assertEquals(0, master.getEnvironmentEntries().size());
    assertEquals(0, master.getEventListeners().size());
    assertEquals(0, master.getGlobals().size());
    assertEquals(0, master.getTaskEventListeners().size());
    assertEquals(0, master.getWorkItemHandlers().size());
    assertTrue(master.getLimitSerializationClasses());
    DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
    slave.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit").auditPersistenceUnit("my.custom.unit2").setLimitSerializationClasses(false);
    assertNotNull(slave);
    assertEquals("my.custom.unit", slave.getPersistenceUnit());
    assertEquals("my.custom.unit2", slave.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, slave.getAuditMode());
    assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
    assertEquals(0, slave.getMarshallingStrategies().size());
    assertEquals(0, slave.getConfiguration().size());
    assertEquals(0, slave.getEnvironmentEntries().size());
    assertEquals(0, slave.getEventListeners().size());
    assertEquals(0, slave.getGlobals().size());
    assertEquals(0, slave.getTaskEventListeners().size());
    assertEquals(0, slave.getWorkItemHandlers().size());
    assertFalse(slave.getLimitSerializationClasses());
    // and now let's merge them
    DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
    DeploymentDescriptor outcome = merger.merge(master, slave, MergeMode.OVERRIDE_ALL);
    assertNotNull(outcome);
    assertEquals("my.custom.unit", outcome.getPersistenceUnit());
    assertEquals("my.custom.unit2", outcome.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, outcome.getAuditMode());
    assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, outcome.getRuntimeStrategy());
    assertEquals(0, 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());
    assertFalse(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 38 with ObjectModel

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

the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeMergeCollections.

@Test
public void testDeploymentDesciptorMergeMergeCollections() {
    DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
    master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(true);
    assertNotNull(master);
    assertEquals("org.jbpm.domain", master.getPersistenceUnit());
    assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, master.getAuditMode());
    assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
    assertEquals(1, master.getMarshallingStrategies().size());
    assertEquals(0, master.getConfiguration().size());
    assertEquals(0, master.getEnvironmentEntries().size());
    assertEquals(0, master.getEventListeners().size());
    assertEquals(0, master.getGlobals().size());
    assertEquals(0, master.getTaskEventListeners().size());
    assertEquals(0, master.getWorkItemHandlers().size());
    assertTrue(master.getLimitSerializationClasses());
    DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
    slave.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit(null).auditPersistenceUnit("").addMarshalingStrategy(new ObjectModel("org.jbpm.test.AnotherCustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(false);
    assertNotNull(slave);
    assertEquals(null, slave.getPersistenceUnit());
    assertEquals("", slave.getAuditPersistenceUnit());
    assertEquals(AuditMode.JMS, slave.getAuditMode());
    assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
    assertEquals(1, slave.getMarshallingStrategies().size());
    assertEquals(0, slave.getConfiguration().size());
    assertEquals(0, slave.getEnvironmentEntries().size());
    assertEquals(0, slave.getEventListeners().size());
    assertEquals(0, slave.getGlobals().size());
    assertEquals(0, slave.getTaskEventListeners().size());
    assertEquals(0, slave.getWorkItemHandlers().size());
    assertFalse(slave.getLimitSerializationClasses());
    // and now let's merge them
    DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
    DeploymentDescriptor outcome = merger.merge(master, slave, MergeMode.MERGE_COLLECTIONS);
    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(2, 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());
    assertFalse(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 39 with ObjectModel

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

the class DeploymentDescriptorTest method testWriteDeploymentDescriptorXml.

@Test
public void testWriteDeploymentDescriptorXml() {
    DeploymentDescriptor 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");
    String deploymentDescriptorXml = descriptor.toXml();
    assertNotNull(deploymentDescriptorXml);
    logger.info(deploymentDescriptorXml);
    ByteArrayInputStream stream = new ByteArrayInputStream(deploymentDescriptorXml.getBytes());
    DeploymentDescriptor fromXml = DeploymentDescriptorIO.fromXml(stream);
    assertNotNull(fromXml);
    assertEquals("org.jbpm.domain", fromXml.getPersistenceUnit());
    assertEquals("org.jbpm.domain", fromXml.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, fromXml.getAuditMode());
    assertEquals(PersistenceMode.JPA, fromXml.getPersistenceMode());
    assertEquals(RuntimeStrategy.SINGLETON, fromXml.getRuntimeStrategy());
    assertEquals(1, 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(1, fromXml.getRequiredRoles().size());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ByteArrayInputStream(java.io.ByteArrayInputStream) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 40 with ObjectModel

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

the class DeploymentDescriptorTest method testCreateDeploymentDescriptorWithPrefixedRoles.

@Test
public void testCreateDeploymentDescriptorWithPrefixedRoles() {
    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("view:managers");
    roles.add("execute:experts");
    roles.add("all:everyone");
    roles.add("employees");
    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(4, descriptor.getRequiredRoles().size());
    List<String> toVerify = descriptor.getRequiredRoles();
    assertEquals(4, toVerify.size());
    assertTrue(toVerify.contains("view:managers"));
    assertTrue(toVerify.contains("execute:experts"));
    assertTrue(toVerify.contains("all:everyone"));
    assertTrue(toVerify.contains("employees"));
    toVerify = descriptor.getRequiredRoles(DeploymentDescriptor.TYPE_ALL);
    assertEquals(4, toVerify.size());
    assertTrue(toVerify.contains("managers"));
    assertTrue(toVerify.contains("experts"));
    assertTrue(toVerify.contains("everyone"));
    assertTrue(toVerify.contains("employees"));
    toVerify = descriptor.getRequiredRoles(DeploymentDescriptor.TYPE_EXECUTE);
    assertEquals(2, toVerify.size());
    assertTrue(toVerify.contains("experts"));
    assertTrue(toVerify.contains("employees"));
    toVerify = descriptor.getRequiredRoles(DeploymentDescriptor.TYPE_VIEW);
    assertEquals(2, toVerify.size());
    assertTrue(toVerify.contains("managers"));
    assertTrue(toVerify.contains("employees"));
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) 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