use of io.camunda.zeebe.protocol.jackson.ZeebeProtocolModule in project zeebe-process-test by camunda-cloud.
the class ContainerizedEngine method getRecords.
/**
* Gets a list of all records that have occurred on the test engine.
*
* @return a list of records
*/
public List<Record<?>> getRecords() {
final ManagedChannel channel = getChannel();
final EngineControlBlockingStub stub = getStub(channel);
final ObjectMapper mapper = new ObjectMapper().registerModule(new ZeebeProtocolModule());
final List<Record<?>> mappedRecords = new ArrayList<>();
final GetRecordsRequest request = GetRecordsRequest.newBuilder().build();
final Iterator<RecordResponse> response = stub.getRecords(request);
while (response.hasNext()) {
final RecordResponse recordResponse = response.next();
try {
final Record<?> record = mapper.readValue(recordResponse.getRecordJson(), new TypeReference<Record<?>>() {
});
mappedRecords.add(record);
} catch (final JsonProcessingException e) {
throw new RuntimeException(e);
}
}
closeChannel(channel);
return mappedRecords;
}
Aggregations