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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations