Skip to content

Commit

Permalink
[Fix_#2183] Removing quarkus test utils from common module
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Feb 3, 2025
1 parent 0ab2453 commit 8996708
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
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,10 @@
<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>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>jobs-service-common</artifactId>
</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

0 comments on commit 8996708

Please sign in to comment.