use of io.smallrye.reactive.messaging.eventbus.codec.PersonCodec in project smallrye-reactive-messaging by smallrye.
the class EventBusSinkTest method testCodec.
@Test
@SuppressWarnings("unchecked")
public void testCodec() {
String topic = UUID.randomUUID().toString();
List<Person> persons = new ArrayList<>();
vertx.eventBus().<Person>consumer(topic, m -> persons.add(m.body()));
vertx.eventBus().getDelegate().registerCodec(new PersonCodec());
Map<String, Object> config = new HashMap<>();
config.put("address", topic);
config.put("codec", "PersonCodec");
EventBusSink sink = new EventBusSink(vertx, new VertxEventBusConnectorOutgoingConfiguration(new MapBasedConfig(config)));
SubscriberBuilder<? extends Message<?>, Void> subscriber = sink.sink();
Multi.createFrom().range(0, 10).map(i -> new Person().setName("name").setAge(i)).map(Message::of).subscribe((Subscriber<Message<?>>) subscriber.build());
await().until(() -> persons.size() == 10);
assertThat(persons.size()).isEqualTo(10);
}
Aggregations