Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessInstanceInfo set start date when constructed #1705

Merged
merged 7 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.jbpm.marshalling.impl.ProtobufRuleFlowProcessInstanceMarshaller;
import org.jbpm.persistence.api.PersistentProcessInstance;
import org.jbpm.process.instance.impl.ProcessInstanceImpl;
import org.jbpm.workflow.instance.WorkflowProcessInstance;
import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl;
import org.kie.api.runtime.Environment;
import org.kie.api.runtime.process.ProcessInstance;
Expand Down Expand Up @@ -103,6 +104,16 @@ public ProcessInstanceInfo(ProcessInstance processInstance) {
this.processInstance = processInstance;
this.processId = processInstance.getProcessId();
startDate = new Date();

// If we are creating a second Process Instance Info for the same process instance,
// it should not generate a new start date
if (this.processInstance != null) {
if (((WorkflowProcessInstanceImpl) this.processInstance).getStartDate() == null) {
((WorkflowProcessInstanceImpl) processInstance).internalSetStartDate(this.startDate);
} else {
startDate = ((WorkflowProcessInstanceImpl) this.processInstance).getStartDate();
}
}
}

public ProcessInstanceInfo(ProcessInstance processInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,18 @@ public void processWithNotNullStartDateTest() {
KieBase kbase = createKieBase(process);
StatefulKnowledgeSession crmPersistentSession = createSession(kbase);

RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) crmPersistentSession.startProcess( processId );
RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) crmPersistentSession.startProcess( processId );

// Ensure the Process Instance Start Date is set immediately when the processInstanceInfo is created
Assert.assertNotNull(processInstance.getStartDate());

InternalKnowledgeRuntime kruntime = processInstance.getKnowledgeRuntime();
Assert.assertEquals( ProcessInstance.STATE_ACTIVE,
processInstance.getState() );

ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(processInstance);
processInstance = (RuleFlowProcessInstance) processInstanceInfo.getProcessInstance(kruntime, crmPersistentSession.getEnvironment());

Assert.assertNotNull(processInstance.getStartDate());
Assert.assertEquals(processInstance.getStartDate(), processInstanceInfo.getStartDate());
}

Expand Down