Search in sources :

Example 1 with DocumentVariable

use of org.jbpm.test.entity.DocumentVariable 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

HashMap (java.util.HashMap)1 EntityManager (javax.persistence.EntityManager)1 SerializablePlaceholderResolverStrategy (org.drools.core.marshalling.impl.SerializablePlaceholderResolverStrategy)1 JPAPlaceholderResolverStrategy (org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy)1 DocumentVariable (org.jbpm.test.entity.DocumentVariable)1 Test (org.junit.Test)1 ResourceType (org.kie.api.io.ResourceType)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1 BZ (qa.tools.ikeeper.annotation.BZ)1