You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "martinweiler (via GitHub)" <gi...@apache.org> on 2026/05/19 18:40:36 UTC

Re: [PR] Adding validations for REST WIH parameters. [incubator-kie-kogito-apps]

martinweiler commented on code in PR #2327:
URL: https://github.com/apache/incubator-kie-kogito-apps/pull/2327#discussion_r3268730661


##########
jitexecutor/jitexecutor-bpmn/src/test/java/org/kie/kogito/jitexecutor/bpmn/JITBPMNServiceImplTest.java:
##########
@@ -160,4 +165,243 @@ void getErrorString() {
         assertThat(retrieved).isEqualTo(expected);
     }
 
+    @Test
+    void validateModel_RestWIHValid_ParsesSuccessfully() throws IOException {
+        String toValidate = new String(IoUtils.readBytesFromInputStream(Objects.requireNonNull(JITBPMNService.class.getResourceAsStream(REST_WIH_VALID_BPMN2_FILE))));
+        JITBPMNValidationResult retrieved = jitBpmnService.validateModel(toValidate);
+
+        assertThat(retrieved).isNotNull();
+        assertThat(retrieved.getErrors()).isNotNull();
+
+        assertThat(retrieved.getErrors()).allMatch(error -> error.contains("Url is required") || error.contains("AccessTokenAcquisitionStrategy is required"));
+    }
+
+    @Test
+    void validateModel_RestWIHValidProper_ParsesSuccessfully() throws IOException {
+        String toValidate = new String(IoUtils.readBytesFromInputStream(Objects.requireNonNull(JITBPMNService.class.getResourceAsStream(REST_WIH_VALID_PROPER_BPMN2_FILE))));
+        JITBPMNValidationResult retrieved = jitBpmnService.validateModel(toValidate);
+
+        assertThat(retrieved).isNotNull();
+        assertThat(retrieved.getErrors()).isNotNull();
+
+        assertThat(retrieved.getErrors()).allMatch(error -> error.contains("Url is required") || error.contains("AccessTokenAcquisitionStrategy is required"));
+    }
+
+    @Test
+    void validateModel_RestWIHValidSimple_ParsesSuccessfully() throws IOException {
+        String toValidate = new String(IoUtils.readBytesFromInputStream(Objects.requireNonNull(JITBPMNService.class.getResourceAsStream(REST_WIH_VALID_SIMPLE_BPMN2_FILE))));
+        JITBPMNValidationResult retrieved = jitBpmnService.validateModel(toValidate);
+
+        assertThat(retrieved).isNotNull();
+        assertThat(retrieved.getErrors()).isNotNull();
+
+        assertThat(retrieved.getErrors()).allMatch(error -> error.contains("Url is required") || error.contains("AccessTokenAcquisitionStrategy is required"));
+    }
+
+    @Test
+    void validateModel_RestWIHInvalid_HasValidationErrors() throws IOException {
+        String toValidate = new String(IoUtils.readBytesFromInputStream(Objects.requireNonNull(JITBPMNService.class.getResourceAsStream(REST_WIH_INVALID_BPMN2_FILE))));
+        JITBPMNValidationResult retrieved = jitBpmnService.validateModel(toValidate);
+
+        assertThat(retrieved).isNotNull();
+        assertThat(retrieved.getErrors()).isNotNull().isNotEmpty();
+
+        assertThat(retrieved.getErrors()).anyMatch(error -> error.contains("Missing Strategy") && error.contains("AccessTokenAcquisitionStrategy is required"));
+        assertThat(retrieved.getErrors()).anyMatch(error -> error.contains("Invalid Strategy") && error.contains("AccessTokenAcquisitionStrategy must be one of"));
+        assertThat(retrieved.getErrors()).anyMatch(error -> error.contains("Missing TaskId") && error.contains("RestServiceCallTaskId is required"));
+        assertThat(retrieved.getErrors()).anyMatch(error -> error.contains("Invalid TaskId Format") && error.contains("RestServiceCallTaskId must contain only alphanumeric"));
+        assertThat(retrieved.getErrors()).anyMatch(error -> error.contains("Missing URL") && error.contains("Url is required"));
+    }
+
+    @Test
+    void validateModel_AllValidScenarios_ParsesSuccessfully() throws IOException {
+        String toValidate = new String(IoUtils.readBytesFromInputStream(Objects.requireNonNull(JITBPMNService.class.getResourceAsStream(REST_WIH_ALL_VALID_SCENARIOS_BPMN2_FILE))));
+        JITBPMNValidationResult retrieved = jitBpmnService.validateModel(toValidate);
+
+        assertThat(retrieved).isNotNull();
+        assertThat(retrieved.getErrors()).isNotNull();
+
+        // The BPMN file should parse successfully
+        // Similar to above, validation errors for required fields will be present
+    }
+
+    private String createRestTaskBpmn(String processId, String url, String strategy, String taskId,

Review Comment:
   Where is this method used?



-- 
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: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org