Search in sources :

Example 1 with EngineControlBlockingStub

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub in project zeebe-process-test by camunda.

the class ContainerizedEngine method increaseTime.

@Override
public void increaseTime(final Duration timeToAdd) {
    final ManagedChannel channel = getChannel();
    final EngineControlBlockingStub stub = getStub(channel);
    final IncreaseTimeRequest request = IncreaseTimeRequest.newBuilder().setMilliseconds((int) timeToAdd.toMillis()).build();
    stub.increaseTime(request);
    closeChannel(channel);
}
Also used : IncreaseTimeRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.IncreaseTimeRequest) ManagedChannel(io.grpc.ManagedChannel) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)

Example 2 with EngineControlBlockingStub

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub 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 3 with EngineControlBlockingStub

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub in project zeebe-process-test by camunda.

the class ContainerizedEngine method stop.

@Override
public void stop() {
    final ManagedChannel channel = getChannel();
    final EngineControlBlockingStub stub = getStub(channel);
    final StopEngineRequest request = StopEngineRequest.newBuilder().build();
    stub.stopEngine(request);
    closeChannel(channel);
}
Also used : ManagedChannel(io.grpc.ManagedChannel) StopEngineRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.StopEngineRequest) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)

Example 4 with EngineControlBlockingStub

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub in project zeebe-process-test by camunda.

the class ContainerizedEngine method reset.

/**
 * Reset the test engine. A reset stops the current engine, and replaces it with a new engine.
 * Note that you'll need to redeploy your processes because it is an entirely new engine.
 */
public void reset() {
    final ManagedChannel channel = getChannel();
    final EngineControlBlockingStub stub = getStub(channel);
    final ResetEngineRequest request = ResetEngineRequest.newBuilder().build();
    stub.resetEngine(request);
    closeChannel(channel);
}
Also used : ManagedChannel(io.grpc.ManagedChannel) ResetEngineRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.ResetEngineRequest) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)

Example 5 with EngineControlBlockingStub

use of io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub in project zeebe-process-test by camunda-cloud.

the class ContainerizedEngine method waitForIdleState.

@Override
public void waitForIdleState(final Duration timeout) {
    final ManagedChannel channel = getChannel();
    final EngineControlBlockingStub stub = getStub(channel);
    final WaitForIdleStateRequest request = WaitForIdleStateRequest.newBuilder().setTimeout(timeout.toMillis()).build();
    stub.waitForIdleState(request);
    closeChannel(channel);
}
Also used : WaitForIdleStateRequest(io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.WaitForIdleStateRequest) ManagedChannel(io.grpc.ManagedChannel) EngineControlBlockingStub(io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)

Aggregations

EngineControlBlockingStub (io.camunda.zeebe.process.test.engine.protocol.EngineControlGrpc.EngineControlBlockingStub)14 ManagedChannel (io.grpc.ManagedChannel)14 StatusRuntimeException (io.grpc.StatusRuntimeException)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 GetRecordsRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.GetRecordsRequest)2 IncreaseTimeRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.IncreaseTimeRequest)2 RecordResponse (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.RecordResponse)2 ResetEngineRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.ResetEngineRequest)2 StartEngineRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.StartEngineRequest)2 StopEngineRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.StopEngineRequest)2 WaitForBusyStateRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.WaitForBusyStateRequest)2 WaitForIdleStateRequest (io.camunda.zeebe.process.test.engine.protocol.EngineControlOuterClass.WaitForIdleStateRequest)2 Record (io.camunda.zeebe.protocol.record.Record)2 ArrayList (java.util.ArrayList)2 TimeoutException (java.util.concurrent.TimeoutException)2 ZeebeProtocolModule (io.camunda.zeebe.protocol.jackson.ZeebeProtocolModule)1 AbstractRecord (io.camunda.zeebe.protocol.jackson.record.AbstractRecord)1