Search in sources :

Example 1 with RecordResponse

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse in project zeebe-process-test by camunda.

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();
    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(), AbstractRecord.class);
            mappedRecords.add(record);
        } catch (final JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }
    closeChannel(channel);
    return mappedRecords;
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) ManagedChannel(io.grpc.ManagedChannel) AbstractRecord(io.camunda.zeebe.protocol.jackson.record.AbstractRecord) Record(io.camunda.zeebe.protocol.record.Record) RecordResponse(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub) GetRecordsRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.GetRecordsRequest)

Example 2 with RecordResponse

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse 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;
}
Also used : ArrayList(java.util.ArrayList) RecordResponse(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub) GetRecordsRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.GetRecordsRequest) ZeebeProtocolModule(io.camunda.zeebe.protocol.jackson.ZeebeProtocolModule) StatusRuntimeException(io.grpc.StatusRuntimeException) ManagedChannel(io.grpc.ManagedChannel) Record(io.camunda.zeebe.protocol.record.Record) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 EngineControlBlockingStub (io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)2 GetRecordsRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.GetRecordsRequest)2 RecordResponse (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse)2 Record (io.camunda.zeebe.protocol.record.Record)2 ManagedChannel (io.grpc.ManagedChannel)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 ArrayList (java.util.ArrayList)2 ZeebeProtocolModule (io.camunda.zeebe.protocol.jackson.ZeebeProtocolModule)1 AbstractRecord (io.camunda.zeebe.protocol.jackson.record.AbstractRecord)1