Christine-Jose commented on code in PR #2327:
URL:
https://github.com/apache/incubator-kie-kogito-apps/pull/2327#discussion_r3269628875
##########
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:
Removed the unused method.
--
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]