wmedvede commented on code in PR #3944:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3944#discussion_r2204069735
##########
kogito-build/kogito-dependencies-bom/pom.xml:
##########
@@ -51,7 +51,7 @@
<version.net.minidev.jsonsmart>2.4.10</version.net.minidev.jsonsmart>
<version.net.thisptr.jackson-jq>1.0.0-preview.20240207</version.net.thisptr.jackson-jq>
<version.io.quarkiverse.jackson-jq>2.2.0</version.io.quarkiverse.jackson-jq>
-
<version.io.quarkiverse.openapi.generator>2.10.0-lts</version.io.quarkiverse.openapi.generator>
+
<version.io.quarkiverse.openapi.generator>2.11.0-lts</version.io.quarkiverse.openapi.generator>
Review Comment:
I believe main already has 2.11.0-lts
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/EventWithHeaderIT.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.quarkus.workflows;
+
+import java.net.URI;
+import java.time.OffsetDateTime;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.test.quarkus.QuarkusTestProperty;
+import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;
+import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.cloudevents.jackson.JsonCloudEventData;
+import io.cloudevents.jackson.JsonFormat;
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.path.json.JsonPath;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.assertProcessInstanceHasFinished;
+
+@QuarkusIntegrationTest
+@QuarkusTestResource(SimpleServerServicesMock.class)
+@QuarkusTestResource(KafkaQuarkusTestResource.class)
+class EventWithHeaderIT {
+
+ private static final String SERVICE_URL = "/event-with-headers";
+ private static final String SERVICE_GET_BY_ID_URL = SERVICE_URL + "/{id}";
+ private static final String EVENT_TYPE = "lock-event";
+ private static final String EVENT_TOPIC = "lock-event";
+
+ private static final String DEFAULT_OUT_EVENT_TOPIC =
"kogito-sw-out-events";
+
+ public static final String SIMPLE_TOKEN = "TEST_TOKEN";
+
+ @QuarkusTestProperty(name = KafkaQuarkusTestResource.KOGITO_KAFKA_PROPERTY)
+ String kafkaBootstrapServers;
+ ObjectMapper objectMapper;
+ KafkaTestClient kafkaClient;
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(EventWithHeaderIT.class);
+
+ @BeforeEach
+ void setup() {
+ kafkaClient = new KafkaTestClient(kafkaBootstrapServers);
+ objectMapper = new ObjectMapper()
+ .registerModule(new JavaTimeModule())
+ .registerModule(JsonFormat.getCloudEventJacksonModule())
+
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ }
+
+ @AfterEach
+ void cleanUp() {
+ if (kafkaClient != null) {
+ kafkaClient.shutdown();
+ }
+ }
+
+ @Test
+ @SuppressWarnings("squid:S2699")
+ void callbackStateSuccessful() throws Exception {
+
+ String response =
objectMapper.writeValueAsString(CloudEventBuilder.v1()
Review Comment:
nitpick, `response` for the produced event confuses to follow the test
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/EventWithHeaderIT.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.quarkus.workflows;
+
+import java.net.URI;
+import java.time.OffsetDateTime;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.test.quarkus.QuarkusTestProperty;
+import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;
+import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.cloudevents.jackson.JsonCloudEventData;
+import io.cloudevents.jackson.JsonFormat;
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.path.json.JsonPath;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.assertProcessInstanceHasFinished;
+
+@QuarkusIntegrationTest
+@QuarkusTestResource(SimpleServerServicesMock.class)
+@QuarkusTestResource(KafkaQuarkusTestResource.class)
+class EventWithHeaderIT {
+
+ private static final String SERVICE_URL = "/event-with-headers";
+ private static final String SERVICE_GET_BY_ID_URL = SERVICE_URL + "/{id}";
+ private static final String EVENT_TYPE = "lock-event";
+ private static final String EVENT_TOPIC = "lock-event";
+
+ private static final String DEFAULT_OUT_EVENT_TOPIC =
"kogito-sw-out-events";
+
+ public static final String SIMPLE_TOKEN = "TEST_TOKEN";
+
+ @QuarkusTestProperty(name = KafkaQuarkusTestResource.KOGITO_KAFKA_PROPERTY)
+ String kafkaBootstrapServers;
+ ObjectMapper objectMapper;
+ KafkaTestClient kafkaClient;
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(EventWithHeaderIT.class);
+
+ @BeforeEach
+ void setup() {
+ kafkaClient = new KafkaTestClient(kafkaBootstrapServers);
+ objectMapper = new ObjectMapper()
+ .registerModule(new JavaTimeModule())
+ .registerModule(JsonFormat.getCloudEventJacksonModule())
+
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ }
+
+ @AfterEach
+ void cleanUp() {
+ if (kafkaClient != null) {
+ kafkaClient.shutdown();
+ }
+ }
+
+ @Test
+ @SuppressWarnings("squid:S2699")
+ void callbackStateSuccessful() throws Exception {
+
+ String response =
objectMapper.writeValueAsString(CloudEventBuilder.v1()
+ .withId(UUID.randomUUID().toString())
+ .withSource(URI.create(""))
+ .withType(EventWithHeaderIT.EVENT_TYPE)
+ .withTime(OffsetDateTime.now())
+ .withExtension("xauthorizationsimple", SIMPLE_TOKEN)
+
.withData(JsonCloudEventData.wrap(objectMapper.createObjectNode().put("name",
"The Kraken")))
+ .build());
+
+ final CountDownLatch countDownLatch = new CountDownLatch(1);
+ final AtomicReference<String> cloudEvent = new AtomicReference<>();
+ kafkaClient.consume(DEFAULT_OUT_EVENT_TOPIC, rawCloudEvent -> {
+ cloudEvent.set(rawCloudEvent);
+ countDownLatch.countDown();
Review Comment:
we received an event, ok. But is the event we are waiting for? would be nice
to have a verification probably by using the event type similar to this one:
https://github.com/kiegroup/kogito-runtimes/blob/153200d740d761ef0dcf859cf8b888f9134109c9/quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/CallbackStateWithTimeoutsErrorHandlerIT.java#L91
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/EventWithHeaderIT.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.quarkus.workflows;
+
+import java.net.URI;
+import java.time.OffsetDateTime;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.test.quarkus.QuarkusTestProperty;
+import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;
+import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.cloudevents.jackson.JsonCloudEventData;
+import io.cloudevents.jackson.JsonFormat;
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.path.json.JsonPath;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.assertProcessInstanceHasFinished;
+
+@QuarkusIntegrationTest
+@QuarkusTestResource(SimpleServerServicesMock.class)
+@QuarkusTestResource(KafkaQuarkusTestResource.class)
+class EventWithHeaderIT {
+
+ private static final String SERVICE_URL = "/event-with-headers";
+ private static final String SERVICE_GET_BY_ID_URL = SERVICE_URL + "/{id}";
+ private static final String EVENT_TYPE = "lock-event";
+ private static final String EVENT_TOPIC = "lock-event";
+
+ private static final String DEFAULT_OUT_EVENT_TOPIC =
"kogito-sw-out-events";
+
+ public static final String SIMPLE_TOKEN = "TEST_TOKEN";
+
+ @QuarkusTestProperty(name = KafkaQuarkusTestResource.KOGITO_KAFKA_PROPERTY)
+ String kafkaBootstrapServers;
+ ObjectMapper objectMapper;
+ KafkaTestClient kafkaClient;
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(EventWithHeaderIT.class);
+
+ @BeforeEach
+ void setup() {
+ kafkaClient = new KafkaTestClient(kafkaBootstrapServers);
+ objectMapper = new ObjectMapper()
+ .registerModule(new JavaTimeModule())
+ .registerModule(JsonFormat.getCloudEventJacksonModule())
+
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ }
+
+ @AfterEach
+ void cleanUp() {
+ if (kafkaClient != null) {
+ kafkaClient.shutdown();
+ }
+ }
+
+ @Test
+ @SuppressWarnings("squid:S2699")
+ void callbackStateSuccessful() throws Exception {
+
+ String response =
objectMapper.writeValueAsString(CloudEventBuilder.v1()
+ .withId(UUID.randomUUID().toString())
+ .withSource(URI.create(""))
+ .withType(EventWithHeaderIT.EVENT_TYPE)
+ .withTime(OffsetDateTime.now())
+ .withExtension("xauthorizationsimple", SIMPLE_TOKEN)
+
.withData(JsonCloudEventData.wrap(objectMapper.createObjectNode().put("name",
"The Kraken")))
+ .build());
+
+ final CountDownLatch countDownLatch = new CountDownLatch(1);
+ final AtomicReference<String> cloudEvent = new AtomicReference<>();
+ kafkaClient.consume(DEFAULT_OUT_EVENT_TOPIC, rawCloudEvent -> {
+ cloudEvent.set(rawCloudEvent);
+ countDownLatch.countDown();
+ });
+ kafkaClient.produce(response, EventWithHeaderIT.EVENT_TOPIC);
+ // give some time to consume the event and verify the expected
decision was made.
Review Comment:
The current working is not performing any decision, comment confuses to
follow the test.
##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/test/java/org/kie/kogito/quarkus/workflows/EventWithHeaderIT.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.quarkus.workflows;
+
+import java.net.URI;
+import java.time.OffsetDateTime;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.test.quarkus.QuarkusTestProperty;
+import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;
+import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+
+import io.cloudevents.core.builder.CloudEventBuilder;
+import io.cloudevents.jackson.JsonCloudEventData;
+import io.cloudevents.jackson.JsonFormat;
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.path.json.JsonPath;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static
org.kie.kogito.test.utils.ProcessInstancesRESTTestUtils.assertProcessInstanceHasFinished;
+
+@QuarkusIntegrationTest
+@QuarkusTestResource(SimpleServerServicesMock.class)
+@QuarkusTestResource(KafkaQuarkusTestResource.class)
+class EventWithHeaderIT {
+
+ private static final String SERVICE_URL = "/event-with-headers";
+ private static final String SERVICE_GET_BY_ID_URL = SERVICE_URL + "/{id}";
+ private static final String EVENT_TYPE = "lock-event";
+ private static final String EVENT_TOPIC = "lock-event";
+
+ private static final String DEFAULT_OUT_EVENT_TOPIC =
"kogito-sw-out-events";
+
+ public static final String SIMPLE_TOKEN = "TEST_TOKEN";
+
+ @QuarkusTestProperty(name = KafkaQuarkusTestResource.KOGITO_KAFKA_PROPERTY)
+ String kafkaBootstrapServers;
+ ObjectMapper objectMapper;
+ KafkaTestClient kafkaClient;
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(EventWithHeaderIT.class);
+
+ @BeforeEach
+ void setup() {
+ kafkaClient = new KafkaTestClient(kafkaBootstrapServers);
+ objectMapper = new ObjectMapper()
+ .registerModule(new JavaTimeModule())
+ .registerModule(JsonFormat.getCloudEventJacksonModule())
+
.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ }
+
+ @AfterEach
+ void cleanUp() {
+ if (kafkaClient != null) {
+ kafkaClient.shutdown();
+ }
+ }
+
+ @Test
+ @SuppressWarnings("squid:S2699")
+ void callbackStateSuccessful() throws Exception {
Review Comment:
method name doesn't look consistent with the test case.
--
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]