Search in sources :

Example 6 with JPAPlaceholderResolverStrategy

use of org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy in project jbpm by kiegroup.

the class ProcessInstanceTest method testJPAStrategy.

@Test
@BZ("1062346")
public void testJPAStrategy() {
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(getEmf()).addEnvironmentEntry(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new ObjectMarshallingStrategy[] { // order does matter
    new JPAPlaceholderResolverStrategy(getEmf()), new SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT) }).addAsset(ResourceFactory.newClassPathResource(VARIABLE_PERSISTENCE, getClass()), ResourceType.BPMN2).get();
    createRuntimeManager(Strategy.SINGLETON, new HashMap<String, ResourceType>(), environment, "custom-rm");
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    DocumentVariable dv = new DocumentVariable();
    dv.setContent("empty");
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("document", dv);
    ProcessInstance pi = engine.getKieSession().startProcess(VARIABLE_PERSISTENCE_ID, params);
    EntityManager em = getEmf().createEntityManager();
    List<DocumentVariable> documents = em.createQuery("from DocumentVariable").getResultList();
    Assertions.assertThat(documents).hasSize(1);
    Assertions.assertThat(documents.get(0).getContent()).isEqualTo("content-changed");
    engine.getKieSession().abortProcessInstance(pi.getId());
}
Also used : SerializablePlaceholderResolverStrategy(org.drools.core.marshalling.impl.SerializablePlaceholderResolverStrategy) DocumentVariable(org.jbpm.test.entity.DocumentVariable) JPAPlaceholderResolverStrategy(org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) HashMap(java.util.HashMap) ResourceType(org.kie.api.io.ResourceType) EntityManager(javax.persistence.EntityManager) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Aggregations

JPAPlaceholderResolverStrategy (org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy)6 SerializablePlaceholderResolverStrategy (org.drools.core.marshalling.impl.SerializablePlaceholderResolverStrategy)5 HashMap (java.util.HashMap)3 EntityManager (javax.persistence.EntityManager)3 Test (org.junit.Test)3 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)3 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)3 Environment (org.kie.api.runtime.Environment)2 KieSession (org.kie.api.runtime.KieSession)2 TaskService (org.kie.api.task.TaskService)2 TaskSummary (org.kie.api.task.model.TaskSummary)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 UserTransaction (javax.transaction.UserTransaction)1 ProcessInstanceResolverStrategy (org.jbpm.marshalling.impl.ProcessInstanceResolverStrategy)1 CommandBasedTaskService (org.jbpm.services.task.impl.command.CommandBasedTaskService)1 Application (org.jbpm.test.entity.Application)1 DocumentVariable (org.jbpm.test.entity.DocumentVariable)1