Search in sources :

Example 1 with ValueType

use of io.camunda.zeebe.protocol.record.ValueType in project zeebe by zeebe-io.

the class IntentTypeIdResolver method typeFromId.

@Override
public JavaType typeFromId(final DatabindContext context, final String id) {
    final ValueType valueType = ValueType.valueOf(id);
    final TypeFactory typeFactory = context.getTypeFactory();
    return typeFactory.constructType(mapValueTypeToIntentClass(valueType));
}
Also used : ValueType(io.camunda.zeebe.protocol.record.ValueType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Example 2 with ValueType

use of io.camunda.zeebe.protocol.record.ValueType in project zeebe by camunda.

the class QueryApiIT method shouldRespondWithBpmnProcessIdWhenProcessInstanceFound.

@Test
public void shouldRespondWithBpmnProcessIdWhenProcessInstanceFound() {
    // given
    final var client = command.partitionClient(1);
    client.deploy(Bpmn.createExecutableProcess("OneProcessToRuleThemAll").startEvent().serviceTask("task", b -> b.zeebeJobType("type")).endEvent().done());
    final long key = client.createProcessInstance(r -> r.setBpmnProcessId("OneProcessToRuleThemAll")).getProcessInstanceKey();
    assertThat(RecordingExporter.processInstanceRecords().withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATING).withProcessInstanceKey(key).filterRootScope().limit(1).exists()).as("wait until the element instance actually exists in the state").isTrue();
    // when
    final DirectBuffer response = clientTransport.sendRequest(() -> serverAddress, new Request().partitionId(1).key(key).valueType(ValueType.PROCESS_INSTANCE), Duration.ofSeconds(10)).join();
    final var result = new ExecuteQueryResponse();
    result.wrap(response, 0, response.capacity());
    assertThat(result).extracting(ExecuteQueryResponse::getBpmnProcessId).isEqualTo("OneProcessToRuleThemAll");
}
Also used : Address(io.atomix.utils.net.Address) ErrorCode(io.camunda.zeebe.protocol.record.ErrorCode) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) ValueType(io.camunda.zeebe.protocol.record.ValueType) MessagingConfig(io.atomix.cluster.messaging.MessagingConfig) ErrorResponse(io.camunda.zeebe.protocol.impl.encoding.ErrorResponse) ExecuteQueryResponse(io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryResponse) Duration(java.time.Duration) ActorSchedulerRule(io.camunda.zeebe.util.sched.testing.ActorSchedulerRule) CommandApiRule(io.camunda.zeebe.test.broker.protocol.commandapi.CommandApiRule) NettyMessagingService(io.atomix.cluster.messaging.impl.NettyMessagingService) SocketUtil(io.camunda.zeebe.test.util.socket.SocketUtil) Before(org.junit.Before) NetUtil(io.netty.util.NetUtil) Test(org.junit.Test) ProcessIntent(io.camunda.zeebe.protocol.record.intent.ProcessIntent) ExecuteQueryRequest(io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RuleChain(org.junit.rules.RuleChain) ClientTransport(io.camunda.zeebe.transport.ClientTransport) Rule(org.junit.Rule) ClientRequest(io.camunda.zeebe.transport.ClientRequest) EmbeddedBrokerRule(io.camunda.zeebe.broker.test.EmbeddedBrokerRule) AtomixClientTransportAdapter(io.camunda.zeebe.transport.impl.AtomixClientTransportAdapter) RequestType(io.camunda.zeebe.transport.RequestType) MutableDirectBuffer(org.agrona.MutableDirectBuffer) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) DirectBuffer(org.agrona.DirectBuffer) MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) ExecuteQueryResponse(io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryResponse) ExecuteQueryRequest(io.camunda.zeebe.protocol.impl.encoding.ExecuteQueryRequest) ClientRequest(io.camunda.zeebe.transport.ClientRequest) Test(org.junit.Test)

Example 3 with ValueType

use of io.camunda.zeebe.protocol.record.ValueType in project zeebe by camunda.

the class TypedEventSerializationTest method createRecordTuple.

private static Tuple<TypedRecord, CopiedRecord> createRecordTuple() {
    final RecordMetadata recordMetadata = new RecordMetadata();
    final DeploymentIntent intent = DeploymentIntent.CREATE;
    final int protocolVersion = 1;
    final ValueType valueType = ValueType.DEPLOYMENT;
    final RecordType recordType = RecordType.COMMAND;
    final String rejectionReason = "fails";
    final RejectionType rejectionType = RejectionType.INVALID_ARGUMENT;
    final int requestId = 23;
    final int requestStreamId = 1;
    recordMetadata.intent(intent).protocolVersion(protocolVersion).valueType(valueType).recordType(recordType).rejectionReason(rejectionReason).rejectionType(rejectionType).requestId(requestId).requestStreamId(requestStreamId);
    final String resourceName = "resource";
    final DirectBuffer resource = wrapString("contents");
    final String bpmnProcessId = "testProcess";
    final long processDefinitionKey = 123;
    final int processVersion = 12;
    final DeploymentRecord record = new DeploymentRecord();
    record.resources().add().setResourceName(wrapString(resourceName)).setResource(resource);
    record.processesMetadata().add().setBpmnProcessId(wrapString(bpmnProcessId)).setKey(processDefinitionKey).setResourceName(wrapString(resourceName)).setVersion(processVersion).setChecksum(wrapString("checksum"));
    final long key = 1234;
    final long position = 4321;
    final long sourcePosition = 231;
    final long timestamp = 2191L;
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(position);
    when(loggedEvent.getKey()).thenReturn(key);
    when(loggedEvent.getSourceEventPosition()).thenReturn(sourcePosition);
    when(loggedEvent.getTimestamp()).thenReturn(timestamp);
    final TypedEventImpl typedEvent = new TypedEventImpl(0);
    typedEvent.wrap(loggedEvent, recordMetadata, record);
    final CopiedRecord copiedRecord = new CopiedRecord<>(record, recordMetadata, key, 0, position, sourcePosition, timestamp);
    return new Tuple<>(typedEvent, copiedRecord);
}
Also used : RejectionType(io.camunda.zeebe.protocol.record.RejectionType) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ValueType(io.camunda.zeebe.protocol.record.ValueType) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString) DeploymentIntent(io.camunda.zeebe.protocol.record.intent.DeploymentIntent) RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) DirectBuffer(org.agrona.DirectBuffer) RecordType(io.camunda.zeebe.protocol.record.RecordType) DeploymentRecord(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord) CopiedRecord(io.camunda.zeebe.protocol.impl.record.CopiedRecord) Tuple(io.camunda.zeebe.util.collection.Tuple)

Example 4 with ValueType

use of io.camunda.zeebe.protocol.record.ValueType in project zeebe by camunda-cloud.

the class ValueTypeIdResolver method typeFromId.

@Override
public JavaType typeFromId(final DatabindContext context, final String id) {
    final ValueType valueType = ValueType.valueOf(id);
    final TypeFactory typeFactory = context.getTypeFactory();
    return typeFactory.constructType(mapValueTypeToRecordValue(valueType));
}
Also used : ValueType(io.camunda.zeebe.protocol.record.ValueType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Example 5 with ValueType

use of io.camunda.zeebe.protocol.record.ValueType in project zeebe by camunda-cloud.

the class IntentTypeIdResolver method typeFromId.

@Override
public JavaType typeFromId(final DatabindContext context, final String id) {
    final ValueType valueType = ValueType.valueOf(id);
    final TypeFactory typeFactory = context.getTypeFactory();
    return typeFactory.constructType(mapValueTypeToIntentClass(valueType));
}
Also used : ValueType(io.camunda.zeebe.protocol.record.ValueType) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory)

Aggregations

ValueType (io.camunda.zeebe.protocol.record.ValueType)29 RecordType (io.camunda.zeebe.protocol.record.RecordType)9 DeploymentIntent (io.camunda.zeebe.protocol.record.intent.DeploymentIntent)9 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)8 ProcessInstanceIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)6 BufferUtil (io.camunda.zeebe.util.buffer.BufferUtil)6 LoggedEvent (io.camunda.zeebe.logstreams.log.LoggedEvent)5 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)4 DeploymentRecord (io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord)4 DirectBuffer (org.agrona.DirectBuffer)4 MessagingConfig (io.atomix.cluster.messaging.MessagingConfig)3 NettyMessagingService (io.atomix.cluster.messaging.impl.NettyMessagingService)3 Address (io.atomix.utils.net.Address)3 EmbeddedBrokerRule (io.camunda.zeebe.broker.test.EmbeddedBrokerRule)3 GatewayGrpc (io.camunda.zeebe.gateway.protocol.GatewayGrpc)3 GatewayOuterClass (io.camunda.zeebe.gateway.protocol.GatewayOuterClass)3 ActivateJobsRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest)3 ActivateJobsResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse)3 BrokerInfo (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)3 CancelProcessInstanceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CancelProcessInstanceRequest)3