|
32 | 32 | import org.jbpm.bpmn2.core.Association;
|
33 | 33 | import org.jbpm.bpmn2.core.DataStore;
|
34 | 34 | import org.jbpm.bpmn2.core.Definitions;
|
| 35 | +import org.jbpm.bpmn2.data.AssociationModel; |
| 36 | +import org.jbpm.bpmn2.data.AssociationProcess; |
| 37 | +import org.jbpm.bpmn2.data.CorrelationKeyModel; |
| 38 | +import org.jbpm.bpmn2.data.CorrelationKeyProcess; |
35 | 39 | import org.jbpm.bpmn2.data.DataInputAssociationsLazyCreatingModel;
|
36 | 40 | import org.jbpm.bpmn2.data.DataInputAssociationsLazyCreatingProcess;
|
37 | 41 | import org.jbpm.bpmn2.data.DataInputAssociationsModel;
|
|
50 | 54 | import org.jbpm.bpmn2.data.DataOutputAssociationsProcess;
|
51 | 55 | import org.jbpm.bpmn2.data.DataOutputAssociationsXmlNodeModel;
|
52 | 56 | import org.jbpm.bpmn2.data.DataOutputAssociationsXmlNodeProcess;
|
| 57 | +import org.jbpm.bpmn2.data.DataStoreModel; |
| 58 | +import org.jbpm.bpmn2.data.DataStoreProcess; |
53 | 59 | import org.jbpm.bpmn2.data.Evaluation2Model;
|
54 | 60 | import org.jbpm.bpmn2.data.Evaluation2Process;
|
55 | 61 | import org.jbpm.bpmn2.data.Evaluation3Model;
|
|
60 | 66 | import org.jbpm.bpmn2.data.ImportProcess;
|
61 | 67 | import org.jbpm.bpmn2.flow.DataOutputAssociationsHumanTaskModel;
|
62 | 68 | import org.jbpm.bpmn2.flow.DataOutputAssociationsHumanTaskProcess;
|
63 |
| -import org.jbpm.bpmn2.xml.ProcessHandler; |
64 | 69 | import org.jbpm.process.core.datatype.impl.type.ObjectDataType;
|
65 | 70 | import org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler;
|
66 | 71 | import org.jbpm.test.utils.ProcessTestHelper;
|
|
71 | 76 | import org.kie.kogito.internal.process.runtime.KogitoWorkItem;
|
72 | 77 | import org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler;
|
73 | 78 | import org.kie.kogito.internal.process.runtime.KogitoWorkItemManager;
|
74 |
| -import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance; |
75 | 79 | import org.kie.kogito.process.ProcessInstance;
|
76 | 80 | import org.w3c.dom.Document;
|
77 | 81 | import org.w3c.dom.Element;
|
@@ -106,31 +110,46 @@ public void testDataObject() {
|
106 | 110 |
|
107 | 111 | @Test
|
108 | 112 | public void testDataStore() throws Exception {
|
109 |
| - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-DataStore.bpmn2"); |
110 |
| - KogitoProcessInstance processInstance = kruntime.startProcess("DataStore"); |
111 |
| - Definitions def = (Definitions) processInstance.getProcess() |
112 |
| - .getMetaData().get("Definitions"); |
113 |
| - assertThat(def.getDataStores()).isNotNull().hasSize(1); |
| 113 | + Application app = ProcessTestHelper.newApplication(); |
| 114 | + |
| 115 | + org.kie.kogito.process.Process<DataStoreModel> processDefinition = DataStoreProcess.newProcess(app); |
| 116 | + DataStoreModel model = processDefinition.createModel(); |
| 117 | + org.kie.kogito.process.ProcessInstance<DataStoreModel> instance = processDefinition.createInstance(model); |
| 118 | + instance.start(); |
| 119 | + |
| 120 | + /* |
| 121 | + * metaData is not present, I think it is protected and hence cannot import. |
| 122 | + * How to get process metadata from the process object(only then we can get the definition metadata) |
| 123 | + */ |
114 | 124 |
|
| 125 | + Definitions def = (Definitions) instance.process().metaData().get("Definitions"); |
| 126 | + assertThat(def.getDataStores()).isNotNull().hasSize(1); |
115 | 127 | DataStore dataStore = def.getDataStores().get(0);
|
116 | 128 | assertThat(dataStore.getId()).isEqualTo("employee");
|
117 | 129 | assertThat(dataStore.getName()).isEqualTo("employeeStore");
|
118 | 130 | assertThat(((ObjectDataType) dataStore.getType()).getClassName()).isEqualTo(String.class.getCanonicalName());
|
119 |
| - |
120 | 131 | }
|
121 | 132 |
|
122 | 133 | @Test
|
123 | 134 | public void testAssociation() throws Exception {
|
124 |
| - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-Association.bpmn2"); |
125 |
| - KogitoProcessInstance processInstance = kruntime.startProcess("Association"); |
126 |
| - List<Association> associations = (List<Association>) processInstance.getProcess().getMetaData().get(ProcessHandler.ASSOCIATIONS); |
127 |
| - assertThat(associations).isNotNull().hasSize(1); |
| 135 | + Application app = ProcessTestHelper.newApplication(); |
| 136 | + org.kie.kogito.process.Process<AssociationModel> processDefinition = AssociationProcess.newProcess(app); |
| 137 | + AssociationModel model = processDefinition.createModel(); |
| 138 | + org.kie.kogito.process.ProcessInstance<AssociationModel> instance = processDefinition.createInstance(model); |
| 139 | + instance.start(); |
128 | 140 |
|
| 141 | + /* |
| 142 | + * metaData is not present, I think it is protected and hence cannot import. |
| 143 | + * How to get process metadata from the process object(only then we can get the definition metadata) |
| 144 | + */ |
| 145 | + |
| 146 | + Definitions def = (Definitions) instance.process().metaData().get("Definitions"); |
| 147 | + List<Association> associations = def.getAssociations(); |
| 148 | + assertThat(associations).isNotNull().hasSize(1); |
129 | 149 | Association assoc = associations.get(0);
|
130 | 150 | assertThat(assoc.getId()).isEqualTo("_1234");
|
131 | 151 | assertThat(assoc.getSourceRef()).isEqualTo("_1");
|
132 | 152 | assertThat(assoc.getTargetRef()).isEqualTo("_2");
|
133 |
| - |
134 | 153 | }
|
135 | 154 |
|
136 | 155 | @Test
|
@@ -482,17 +501,19 @@ public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr)
|
482 | 501 | instance.start();
|
483 | 502 | }
|
484 | 503 |
|
485 |
| - @Test |
486 |
| - public void testDefaultProcessVariableValue() throws Exception { |
487 |
| - |
488 |
| - kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/data/BPMN2-CorrelationKey.bpmn2"); |
489 |
| - |
490 |
| - Map<String, Object> parameters = new HashMap<String, Object>(); |
491 |
| - |
492 |
| - KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime.startProcess("CorrelationKey", parameters); |
| 504 | + public void testDefaultProcessVariableValue() { |
| 505 | + Application app = ProcessTestHelper.newApplication(); |
| 506 | + org.kie.kogito.process.Process<CorrelationKeyModel> processDefinition = CorrelationKeyProcess.newProcess(app); |
| 507 | + CorrelationKeyModel model = processDefinition.createModel(); |
| 508 | + org.kie.kogito.process.ProcessInstance<CorrelationKeyModel> instance = processDefinition.createInstance(model); |
| 509 | + instance.start(); |
493 | 510 |
|
494 |
| - assertThat(processInstance.getVariable("procVar")).isEqualTo("defaultProc"); |
495 |
| - assertThat(processInstance.getVariable("intVar")).isEqualTo(1); |
| 511 | + /* |
| 512 | + * CorrelationKeyModel class does not have methods named getProcVar and getIntVar . |
| 513 | + * This is due to acutal variables/methods being different in the CorrelationKeyModel class. |
| 514 | + */ |
| 515 | + assertThat(model.getProcVar()).isEqualTo("defaultProc"); |
| 516 | + assertThat(model.getIntVar()).isEqualTo(1); |
496 | 517 |
|
497 | 518 | }
|
498 | 519 |
|
|
0 commit comments