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

Vert.x event bus - add a test for generic payload #29486

Merged
merged 1 commit into from
Nov 25, 2022
Merged
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 @@ -12,6 +12,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
Expand Down Expand Up @@ -56,6 +57,23 @@ public void testSend() throws InterruptedException {
assertEquals("HELLO", synchronizer.poll(2, TimeUnit.SECONDS));
}

@Test
public void testSendGenericType() throws InterruptedException {
BlockingQueue<Object> synchronizer = new LinkedBlockingQueue<>();
eventBus.request("foos", List.of(1, 2), ar -> {
if (ar.succeeded()) {
try {
synchronizer.put(ar.result().body());
} catch (InterruptedException e) {
fail(e);
}
} else {
fail(ar.cause());
}
});
assertEquals(3, synchronizer.poll(2, TimeUnit.SECONDS));
}

@Test
public void testSendAsync() throws InterruptedException {
BlockingQueue<Object> synchronizer = new LinkedBlockingQueue<>();
Expand Down Expand Up @@ -252,6 +270,11 @@ void consumeBlockingUsingRunOnWorkerThread(String message) {
String blockingRequestContextActive(String message) {
return transformer.transform(message);
}

@ConsumeEvent("foos")
int reply(List<Integer> numbers) {
return numbers.stream().collect(Collectors.summingInt(Integer::intValue));
}
}

@RequestScoped
Expand Down