use of io.micronaut.http.client.sse.SseClient in project micronaut-core by micronaut-projects.
the class HeadlineControllerSpec method testConsumeEventStreamObject.
@Test
public void testConsumeEventStreamObject() {
SseClient client = embeddedServer.getApplicationContext().createBean(SseClient.class, embeddedServer.getURL());
List<Event<Headline>> events = new ArrayList<>();
Flux.from(client.eventStream(HttpRequest.GET("/headlines"), Headline.class)).subscribe(events::add);
await().until(() -> events.size() == 2);
assertEquals("Micronaut 1.0 Released", events.get(0).getData().getTitle());
assertEquals("Come and get it", events.get(0).getData().getDescription());
}