martinweiler commented on code in PR #3597:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3597#discussion_r1700792719


##########
jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/DataTest.java:
##########
@@ -325,152 +355,129 @@ public void executeWorkItem(KogitoWorkItem workItem,
     @Test
     @Disabled
     public void testDataInputAssociationsWithTwoAssigns() throws Exception {
-        kruntime = 
createKogitoProcessRuntime("BPMN2-DataInputAssociations-two-assigns.bpmn2");
-        kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human 
Task",
-                new KogitoWorkItemHandler() {
-
-                    public void abortWorkItem(KogitoWorkItem manager,
-                            KogitoWorkItemManager mgr) {
-
-                    }
-
-                    public void executeWorkItem(KogitoWorkItem workItem,
-                            KogitoWorkItemManager mgr) {
-                        assertThat(((Element) 
workItem.getParameter("Comment")).getNodeName()).isEqualTo("foo");
-                        // assertEquals("mynode", ((Element)
-                        // 
workItem.getParameter("Comment")).getFirstChild().getNodeName());
-                        // assertEquals("user", ((Element)
-                        // 
workItem.getParameter("Comment")).getFirstChild().getFirstChild().getNodeName());
-                        // assertEquals("hello world", ((Element)
-                        // 
workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
-                    }
-
-                });
+        Application app = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerHandler(app, "Human Task", new 
KogitoWorkItemHandler() {
+            @Override
+            public void abortWorkItem(KogitoWorkItem workItem, 
KogitoWorkItemManager mgr) {
+            }
+
+            @Override
+            public void executeWorkItem(KogitoWorkItem workItem, 
KogitoWorkItemManager mgr) {
+                assertThat(((Element) 
workItem.getParameter("Comment")).getNodeName()).isEqualTo("foo");
+                // assertEquals("mynode", ((Element) 
workItem.getParameter("Comment")).getFirstChild().getNodeName());
+                // assertEquals("user", ((Element) 
workItem.getParameter("Comment")).getFirstChild().getFirstChild().getNodeName());
+                // assertEquals("hello world", ((Element) 
workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
+            }
+        });
+
         Document document = DocumentBuilderFactory
                 .newInstance()
                 .newDocumentBuilder()
-                .parse(new ByteArrayInputStream("<user hello='hello world' />"
-                        .getBytes()));
-        Map<String, Object> params = new HashMap<>();
-        params.put("instanceMetadata", document.getFirstChild());
-        KogitoProcessInstance processInstance = 
kruntime.startProcess("process",
-                params);
+                .parse(new ByteArrayInputStream("<user hello='hello world' 
/>".getBytes()));
+
+        org.kie.kogito.process.Process<DataInputAssociationsTwoAssignsModel> 
processDefinition = DataInputAssociationsTwoAssignsProcess.newProcess(app);
+        DataInputAssociationsTwoAssignsModel model = 
processDefinition.createModel();
+        model.setInstanceMetadata(document.getFirstChild());
 
+        
org.kie.kogito.process.ProcessInstance<DataInputAssociationsTwoAssignsModel> 
instance = processDefinition.createInstance(model);
+        instance.start();
     }
 
     @Test
-    public void testDataOutputAssociationsforHumanTask() throws Exception {
+    public void testDataOutputAssociationsforHumanTask() {
         Application app = ProcessTestHelper.newApplication();
-        ProcessTestHelper.registerHandler(app, "Human Task",
-                new KogitoWorkItemHandler() {
-
-                    public void abortWorkItem(KogitoWorkItem manager,
-                            KogitoWorkItemManager mgr) {
-
-                    }
-
-                    public void executeWorkItem(KogitoWorkItem workItem,
-                            KogitoWorkItemManager mgr) {
-                        DocumentBuilderFactory factory = DocumentBuilderFactory
-                                .newInstance();
-                        DocumentBuilder builder;
-                        try {
-                            builder = factory.newDocumentBuilder();
-                        } catch (ParserConfigurationException e) {
-                            throw new RuntimeException(e);
-                        }
-                        final Map<String, Object> results = new HashMap<>();
-
-                        // process metadata
-                        org.w3c.dom.Document processMetadaDoc = builder
-                                .newDocument();
-                        org.w3c.dom.Element processMetadata = processMetadaDoc
-                                .createElement("previoustasksowner");
-                        processMetadaDoc.appendChild(processMetadata);
-                        // org.w3c.dom.Element procElement =
-                        // 
processMetadaDoc.createElement("previoustasksowner");
-                        processMetadata
-                                .setAttribute("primaryname", "my_result");
-                        // processMetadata.appendChild(procElement);
-                        results.put("output", processMetadata);
-
-                        mgr.completeWorkItem(workItem.getStringId(), results);
-                    }
-
-                });
-
-        org.kie.kogito.process.Process<DataOutputAssociationsHumanTaskModel> 
definition = DataOutputAssociationsHumanTaskProcess.newProcess(app);
-        
org.kie.kogito.process.ProcessInstance<DataOutputAssociationsHumanTaskModel> 
instance = definition.createInstance(definition.createModel());
-
+        ProcessTestHelper.registerHandler(app, "Human Task", new 
KogitoWorkItemHandler() {
+            @Override
+            public void abortWorkItem(KogitoWorkItem workItem, 
KogitoWorkItemManager mgr) {
+            }
+
+            @Override
+            public void executeWorkItem(KogitoWorkItem workItem, 
KogitoWorkItemManager mgr) {
+                DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
+                DocumentBuilder builder;
+                try {
+                    builder = factory.newDocumentBuilder();
+                } catch (ParserConfigurationException e) {
+                    throw new RuntimeException(e);
+                }
+                final Map<String, Object> results = new HashMap<>();
+                // process metadata
+                org.w3c.dom.Document processMetadaDoc = builder.newDocument();
+                org.w3c.dom.Element processMetadata = 
processMetadaDoc.createElement("previoustasksowner");
+                processMetadaDoc.appendChild(processMetadata);
+                processMetadata.setAttribute("primaryname", "my_result");
+                results.put("output", processMetadata);
+                mgr.completeWorkItem(workItem.getStringId(), results);
+            }
+        });
+
+        org.kie.kogito.process.Process<DataOutputAssociationsHumanTaskModel> 
processDefinition = DataOutputAssociationsHumanTaskProcess.newProcess(app);
+        DataOutputAssociationsHumanTaskModel model = 
processDefinition.createModel();
+
+        
org.kie.kogito.process.ProcessInstance<DataOutputAssociationsHumanTaskModel> 
instance = processDefinition.createInstance(model);
         instance.start();
     }

Review Comment:
   In all these `testDataOutput*` tests, I am missing some sort of assert 
statement that actually evaluates the functionality. @Abhitocode I know your 
task was to migrate the tests as-is, but while we are looking at them, we might 
at least create another task to improve them in the future. WDYT @elguardian ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to