Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix_#2183] Removing quarkus test utils from common module #2184

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-test-utils</artifactId>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down Expand Up @@ -84,17 +80,6 @@
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-test-utils</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
</exclusion>
<exclusion>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,19 @@
package org.kie.kogito.test;

import java.time.Duration;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.awaitility.Awaitility;
import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;

import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;

public class TestUtils {

private TestUtils() {
}

public static JsonPath waitForEvent(KafkaTestClient kafkaClient, String topic, long seconds) throws Exception {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final AtomicReference<String> cloudEvent = new AtomicReference<>();
kafkaClient.consume(topic, rawCloudEvent -> {
cloudEvent.set(rawCloudEvent);
countDownLatch.countDown();
});
// give some time to consume the event.
assertThat(countDownLatch.await(seconds, TimeUnit.SECONDS)).isTrue();
return new JsonPath(cloudEvent.get());
}

public static void assertJobsAndProcessOnDataIndex(String dataIndexURL, String processId, String processInstanceId, String processStatus, String jobStatus, Duration timeout) {
if (dataIndexURL != null) {
String query = "{ \"query\" : " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.kie.kogito.it.jobs;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -26,7 +30,7 @@

import io.restassured.path.json.JsonPath;

import static org.kie.kogito.test.TestUtils.waitForEvent;
import static org.assertj.core.api.Assertions.assertThat;

public class KafkaBaseSwitchStateTimeoutsIT extends BaseSwitchStateTimeoutsIT {

Expand All @@ -44,6 +48,18 @@ void cleanUp() {
kafkaClient.shutdown();
}

private static JsonPath waitForEvent(KafkaTestClient kafkaClient, String topic, long seconds) throws Exception {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final AtomicReference<String> cloudEvent = new AtomicReference<>();
kafkaClient.consume(topic, rawCloudEvent -> {
cloudEvent.set(rawCloudEvent);
countDownLatch.countDown();
});
// give some time to consume the event.
assertThat(countDownLatch.await(seconds, TimeUnit.SECONDS)).isTrue();
return new JsonPath(cloudEvent.get());
}

@Override
protected void verifyNoDecisionEventWasProduced(String processInstanceId) throws Exception {
JsonPath result = waitForEvent(kafkaClient, KOGITO_OUTGOING_STREAM_TOPIC, 50);
Expand Down
Loading