Search in sources :

Example 1 with GeneralEvent

use of io.zeebe.client.event.GeneralEvent in project zeebe by zeebe-io.

the class RecordingEventHandler method assertTaskEvent.

public void assertTaskEvent(int index, long taskKey, String eventType) throws IOException {
    final List<GeneralEvent> taskEvents = events.stream().filter(e -> e.getMetadata().getType() == TopicEventType.TASK).collect(Collectors.toList());
    final GeneralEvent taskEvent = taskEvents.get(index);
    final EventMetadata eventMetadata = taskEvent.getMetadata();
    assertThat(eventMetadata.getType()).isEqualTo(TopicEventType.TASK);
    assertThat(eventMetadata.getKey()).isEqualTo(taskKey);
    final JsonNode event = objectMapper.readTree(taskEvent.getJson());
    assertThat(event.get("state").asText()).isEqualTo(eventType);
}
Also used : UniversalEventHandler(io.zeebe.client.event.UniversalEventHandler) List(java.util.List) GeneralEvent(io.zeebe.client.event.GeneralEvent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonNode(com.fasterxml.jackson.databind.JsonNode) Collectors(java.util.stream.Collectors) TopicEventType(io.zeebe.client.event.TopicEventType) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) EventMetadata(io.zeebe.client.event.EventMetadata) JsonNode(com.fasterxml.jackson.databind.JsonNode) GeneralEvent(io.zeebe.client.event.GeneralEvent) EventMetadata(io.zeebe.client.event.EventMetadata)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 EventMetadata (io.zeebe.client.event.EventMetadata)1 GeneralEvent (io.zeebe.client.event.GeneralEvent)1 TopicEventType (io.zeebe.client.event.TopicEventType)1 UniversalEventHandler (io.zeebe.client.event.UniversalEventHandler)1 IOException (java.io.IOException)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1