use of org.jbpm.persistence.session.objects.MyVariableExtendingSerializable in project jbpm by kiegroup.
the class VariablePersistenceStrategyTest method getKnowledgeBaseForExtendingInterfaceVariablePersistence.
private KieBase getKnowledgeBaseForExtendingInterfaceVariablePersistence(String processId, final String variableText) {
RuleFlowProcess process = new RuleFlowProcess();
process.setId(processId);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("x");
ObjectDataType extendingSerializableDataType = new ObjectDataType();
extendingSerializableDataType.setClassName(MyVariableExtendingSerializable.class.getName());
variable.setType(extendingSerializableDataType);
variables.add(variable);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
WorkItemNode workItemNode = new WorkItemNode();
workItemNode.setName("workItemNode");
workItemNode.setId(2);
Work work = new WorkImpl();
work.setName("MyWork");
workItemNode.setWork(work);
ActionNode actionNode = new ActionNode();
actionNode.setName("Print");
DroolsAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new Action() {
public void execute(ProcessContext context) throws Exception {
Assert.assertEquals(variableText, ((MyVariableExtendingSerializable) context.getVariable("x")).getText());
;
}
});
actionNode.setAction(action);
actionNode.setId(3);
EndNode endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(4);
connect(startNode, workItemNode);
connect(workItemNode, actionNode);
connect(actionNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(actionNode);
process.addNode(endNode);
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
((KnowledgeBaseImpl) kbase).addProcess(process);
return kbase;
}
use of org.jbpm.persistence.session.objects.MyVariableExtendingSerializable in project jbpm by kiegroup.
the class VariablePersistenceStrategyTest method testExtendingInterfaceVariablePersistence.
@Test
public void testExtendingInterfaceVariablePersistence() throws Exception {
// Setup
Environment env = createEnvironment();
String processId = "extendingInterfaceVariablePersistence";
String variableText = "my extending serializable variable text";
KieBase kbase = getKnowledgeBaseForExtendingInterfaceVariablePersistence(processId, variableText);
KieSession ksession = createSession(kbase, env);
Map<String, Object> initialParams = new HashMap<String, Object>();
initialParams.put("x", new MyVariableExtendingSerializable(variableText));
// Start process and execute workItem
long processInstanceId = ksession.startProcess(processId, initialParams).getId();
ksession = reloadSession(ksession, kbase, env);
long workItemId = TestWorkItemHandler.getInstance().getWorkItem().getId();
ksession.getWorkItemManager().completeWorkItem(workItemId, null);
// Test
Assert.assertNull(ksession.getProcessInstance(processInstanceId));
}
Aggregations