Search in sources :

Example 11 with GetProcessInstanceCommand

use of org.drools.core.command.runtime.process.GetProcessInstanceCommand in project jbpm by kiegroup.

the class SingleSessionCommandServiceTest method testPersistenceTimer2.

@Test
public void testPersistenceTimer2() throws Exception {
    setUp();
    Properties properties = new Properties();
    properties.setProperty("drools.commandService", PersistableRunner.class.getName());
    properties.setProperty("drools.processInstanceManagerFactory", JPAProcessInstanceManagerFactory.class.getName());
    properties.setProperty("drools.workItemManagerFactory", JPAWorkItemManagerFactory.class.getName());
    properties.setProperty("drools.processSignalManagerFactory", JPASignalManagerFactory.class.getName());
    SessionConfiguration config = SessionConfiguration.newInstance(properties);
    config.setOption(TimerJobFactoryOption.get(TimerJobFactoryType.JPA.getId()));
    InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    Collection<KiePackage> kpkgs = getProcessTimer2();
    kbase.addPackages(kpkgs);
    PersistableRunner service = new PersistableRunner(kbase, config, env);
    Long sessionId = service.getSessionId();
    StartProcessCommand startProcessCommand = new StartProcessCommand();
    startProcessCommand.setProcessId("org.drools.test.TestProcess");
    ProcessInstance processInstance = service.execute(startProcessCommand);
    logger.info("Started process instance {}", processInstance.getId());
    Thread.sleep(2000);
    service = new PersistableRunner(sessionId, kbase, config, env);
    GetProcessInstanceCommand getProcessInstanceCommand = new GetProcessInstanceCommand();
    getProcessInstanceCommand.setProcessInstanceId(processInstance.getId());
    processInstance = service.execute(getProcessInstanceCommand);
    assertNull(processInstance);
}
Also used : JPASignalManagerFactory(org.jbpm.persistence.processinstance.JPASignalManagerFactory) Properties(java.util.Properties) JPAWorkItemManagerFactory(org.drools.persistence.jpa.processinstance.JPAWorkItemManagerFactory) StartProcessCommand(org.drools.core.command.runtime.process.StartProcessCommand) PersistableRunner(org.drools.persistence.PersistableRunner) GetProcessInstanceCommand(org.drools.core.command.runtime.process.GetProcessInstanceCommand) KiePackage(org.kie.api.definition.KiePackage) JPAProcessInstanceManagerFactory(org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) SessionConfiguration(org.drools.core.SessionConfiguration) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Aggregations

GetProcessInstanceCommand (org.drools.core.command.runtime.process.GetProcessInstanceCommand)11 Test (org.junit.Test)9 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)6 Properties (java.util.Properties)5 SessionConfiguration (org.drools.core.SessionConfiguration)5 StartProcessCommand (org.drools.core.command.runtime.process.StartProcessCommand)5 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)5 PersistableRunner (org.drools.persistence.PersistableRunner)5 JPAWorkItemManagerFactory (org.drools.persistence.jpa.processinstance.JPAWorkItemManagerFactory)5 JPAProcessInstanceManagerFactory (org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory)5 JPASignalManagerFactory (org.jbpm.persistence.processinstance.JPASignalManagerFactory)5 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 KiePackage (org.kie.api.definition.KiePackage)5 CompleteWorkItemCommand (org.drools.core.command.runtime.process.CompleteWorkItemCommand)3 JpaJDKTimerService (org.drools.persistence.jpa.JpaJDKTimerService)3 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)3 TestWorkItemHandler (org.jbpm.persistence.session.objects.TestWorkItemHandler)3 WorkItem (org.kie.api.runtime.process.WorkItem)3 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)2