Search in sources :

Example 1 with RxSseClient

use of io.micronaut.rxjava2.http.client.sse.RxSseClient in project kestra by kestra-io.

the class ExecutionControllerTest method triggerAndFollow.

@Test
void triggerAndFollow() {
    Execution result = triggerInputsFlowExecution();
    RxSseClient sseClient = embeddedServer.getApplicationContext().createBean(RxSseClient.class, embeddedServer.getURL());
    List<Event<Execution>> results = sseClient.eventStream("/api/v1/executions/" + result.getId() + "/follow", Execution.class).toList().blockingGet();
    assertThat(results.size(), is(greaterThan(0)));
    assertThat(results.get(results.size() - 1).getData().getState().getCurrent(), is(State.Type.SUCCESS));
}
Also used : Execution(io.kestra.core.models.executions.Execution) RxSseClient(io.micronaut.rxjava2.http.client.sse.RxSseClient) Event(io.micronaut.http.sse.Event) InputsTest(io.kestra.core.runners.InputsTest) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Example 2 with RxSseClient

use of io.micronaut.rxjava2.http.client.sse.RxSseClient in project akhq by tchiotludo.

the class SseControllerTest method searchApi.

@Test
void searchApi() {
    RxSseClient sseClient = embeddedServer.getApplicationContext().createBean(RxSseClient.class, embeddedServer.getURL());
    List<Record> results = sseClient.eventStream(BASE_URL + "/" + KafkaTestCluster.TOPIC_HUGE + "/data/search?searchByKey=key_100_C", TopicController.SearchRecord.class).toList().blockingGet().stream().flatMap(r -> r.getData() != null && r.getData().getRecords() != null ? r.getData().getRecords().stream() : Stream.empty()).collect(Collectors.toList());
    assertThat(results.size(), is(3));
}
Also used : Property(io.micronaut.context.annotation.Property) Record(org.akhq.models.Record) Collectors(java.util.stream.Collectors) AbstractTest(org.akhq.AbstractTest) Test(org.junit.jupiter.api.Test) List(java.util.List) RxSseClient(io.micronaut.rxjava2.http.client.sse.RxSseClient) Stream(java.util.stream.Stream) EmbeddedServer(io.micronaut.runtime.server.EmbeddedServer) KafkaTestCluster(org.akhq.KafkaTestCluster) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Inject(jakarta.inject.Inject) RxSseClient(io.micronaut.rxjava2.http.client.sse.RxSseClient) Record(org.akhq.models.Record) AbstractTest(org.akhq.AbstractTest) Test(org.junit.jupiter.api.Test)

Aggregations

RxSseClient (io.micronaut.rxjava2.http.client.sse.RxSseClient)2 Test (org.junit.jupiter.api.Test)2 Execution (io.kestra.core.models.executions.Execution)1 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)1 InputsTest (io.kestra.core.runners.InputsTest)1 Property (io.micronaut.context.annotation.Property)1 Event (io.micronaut.http.sse.Event)1 EmbeddedServer (io.micronaut.runtime.server.EmbeddedServer)1 Inject (jakarta.inject.Inject)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 AbstractTest (org.akhq.AbstractTest)1 KafkaTestCluster (org.akhq.KafkaTestCluster)1 Record (org.akhq.models.Record)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.is (org.hamcrest.Matchers.is)1