Search in sources :

Example 1 with DeployResourceRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe-process-test by camunda-cloud.

the class GrpcToLogStreamGateway method deployResource.

@Override
public void deployResource(final DeployResourceRequest request, final StreamObserver<DeployResourceResponse> responseObserver) {
    final Long requestId = gatewayRequestStore.registerNewRequest(request.getClass(), responseObserver);
    final RecordMetadata recordMetadata = prepareRecordMetadata().requestId(requestId).valueType(ValueType.DEPLOYMENT).intent(DeploymentIntent.CREATE);
    final DeploymentRecord deploymentRecord = new DeploymentRecord();
    final ValueArray<DeploymentResource> resources = deploymentRecord.resources();
    request.getResourcesList().forEach((resource -> resources.add().setResourceName(resource.getName()).setResource(resource.getContent().toByteArray())));
    writer.writeCommandWithoutKey(deploymentRecord, recordMetadata);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) RecordType(io.camunda.zeebe.protocol.record.RecordType) VariableDocumentIntent(io.camunda.zeebe.protocol.record.intent.VariableDocumentIntent) CompleteJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse) DeploymentIntent(io.camunda.zeebe.protocol.record.intent.DeploymentIntent) CreateProcessInstanceWithResultRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest) VariableDocumentRecord(io.camunda.zeebe.protocol.impl.record.value.variable.VariableDocumentRecord) TopologyResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) ActivateJobsRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest) RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) StreamObserver(io.grpc.stub.StreamObserver) CreateProcessInstanceWithResultResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultResponse) GatewayOuterClass(io.camunda.zeebe.gateway.protocol.GatewayOuterClass) ResolveIncidentRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ResolveIncidentRequest) VariableDocumentUpdateSemantic(io.camunda.zeebe.protocol.record.value.VariableDocumentUpdateSemantic) VersionUtil(io.camunda.zeebe.util.VersionUtil) ResolveIncidentResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ResolveIncidentResponse) BrokerInfo(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo) CreateProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest) SetVariablesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesResponse) TopologyRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) FailJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobRequest) ThrowErrorResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ThrowErrorResponse) JobBatchIntent(io.camunda.zeebe.protocol.record.intent.JobBatchIntent) ThrowErrorRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ThrowErrorRequest) CompleteJobRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest) DeployResourceResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceResponse) DeploymentRecord(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord) IncidentIntent(io.camunda.zeebe.protocol.record.intent.IncidentIntent) PublishMessageResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageResponse) CancelProcessInstanceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CancelProcessInstanceRequest) IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord) ProcessInstanceCreationIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceCreationIntent) BufferUtil(io.camunda.zeebe.util.buffer.BufferUtil) DeployProcessRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessRequest) SetVariablesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.SetVariablesRequest) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) CreateProcessInstanceResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceResponse) FailJobResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobResponse) ValueType(io.camunda.zeebe.protocol.record.ValueType) MessageIntent(io.camunda.zeebe.protocol.record.intent.MessageIntent) UpdateJobRetriesRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesRequest) DeployProcessResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessResponse) MsgPackConverter(io.camunda.zeebe.protocol.impl.encoding.MsgPackConverter) PublishMessageRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.PublishMessageRequest) DeploymentResource(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentResource) UpdateJobRetriesResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesResponse) Partition(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Partition) ValueArray(io.camunda.zeebe.msgpack.value.ValueArray) CancelProcessInstanceResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CancelProcessInstanceResponse) GatewayGrpc(io.camunda.zeebe.gateway.protocol.GatewayGrpc) ActivateJobsResponse(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) JobBatchRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobBatchRecord) MessageRecord(io.camunda.zeebe.protocol.impl.record.value.message.MessageRecord) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) DeploymentRecord(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord) DeploymentResource(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentResource)

Example 2 with DeployResourceRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.

the class TestInterceptor method interceptCall.

@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> call, final Metadata headers, final ServerCallHandler<ReqT, RespT> next) {
    final var listener = next.startCall(call, headers);
    return new CloseAwareListener<>(listener) {

        @Override
        public void onMessage(final ReqT message) {
            if (message instanceof DeployResourceRequest) {
                call.close(Status.PERMISSION_DENIED.augmentDescription(ERROR_MESSAGE), new Metadata());
                isClosed = true;
                return;
            }
            super.onMessage(message);
        }
    };
}
Also used : Metadata(io.grpc.Metadata) CloseAwareListener(io.camunda.zeebe.test.util.grpc.CloseAwareListener) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest)

Example 3 with DeployResourceRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.

the class DeployResourceTest method shouldDeployResourceFromFile.

@Test
public void shouldDeployResourceFromFile() {
    // given
    final String path = DeployResourceTest.class.getResource(BPMN_1_FILENAME).getPath();
    // when
    client.newDeployResourceCommand().addResourceFile(path).send().join();
    // then
    final DeployResourceRequest request = gatewayService.getLastRequest();
    final Resource resource = request.getResources(0);
    assertThat(resource.getName()).isEqualTo(path);
    assertThat(resource.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
}
Also used : Resource(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Resource) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 4 with DeployResourceRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.

the class DeployResourceTest method shouldDeployMultipleResources.

@Test
public void shouldDeployMultipleResources() {
    // given
    final long key = 345L;
    final String filename1 = BPMN_1_FILENAME.substring(1);
    final String filename2 = BPMN_2_FILENAME.substring(1);
    gatewayService.onDeployResourceRequest(key, deployment(deployedProcess(BPMN_1_PROCESS_ID, 1, 1, filename1)), deployment(deployedProcess(BPMN_2_PROCESS_ID, 1, 2, filename2)));
    // when
    client.newDeployResourceCommand().addResourceFromClasspath(filename1).addResourceFromClasspath(filename2).send().join();
    // then
    final DeployResourceRequest request = gatewayService.getLastRequest();
    assertThat(request.getResourcesList()).hasSize(2);
    final Resource resource1 = request.getResources(0);
    assertThat(resource1.getName()).isEqualTo(filename1);
    assertThat(resource1.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
    final Resource resource2 = request.getResources(1);
    assertThat(resource2.getName()).isEqualTo(filename2);
    assertThat(resource2.getContent().toByteArray()).isEqualTo(getBytes(BPMN_2_FILENAME));
}
Also used : Resource(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Resource) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Example 5 with DeployResourceRequest

use of io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest in project zeebe by zeebe-io.

the class DeployResourceTest method shouldDeployResourceFromInputStream.

@Test
public void shouldDeployResourceFromInputStream() {
    // given
    final String filename = BPMN_1_FILENAME;
    final InputStream resourceAsStream = DeployResourceTest.class.getResourceAsStream(filename);
    // when
    client.newDeployResourceCommand().addResourceStream(resourceAsStream, filename).send().join();
    // then
    final DeployResourceRequest request = gatewayService.getLastRequest();
    final Resource resource = request.getResources(0);
    assertThat(resource.getName()).isEqualTo(filename);
    assertThat(resource.getContent().toByteArray()).isEqualTo(getBytes(BPMN_1_FILENAME));
}
Also used : InputStream(java.io.InputStream) Resource(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Resource) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest) ClientTest(io.camunda.zeebe.client.util.ClientTest) Test(org.junit.Test)

Aggregations

DeployResourceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest)21 ClientTest (io.camunda.zeebe.client.util.ClientTest)16 Resource (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.Resource)16 Test (org.junit.Test)16 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)2 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)2 DeploymentEventImpl (io.camunda.zeebe.client.impl.response.DeploymentEventImpl)2 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)2 CloseAwareListener (io.camunda.zeebe.test.util.grpc.CloseAwareListener)2 Metadata (io.grpc.Metadata)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 GatewayGrpc (io.camunda.zeebe.gateway.protocol.GatewayGrpc)1 GatewayOuterClass (io.camunda.zeebe.gateway.protocol.GatewayOuterClass)1 ActivateJobsRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsRequest)1 ActivateJobsResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse)1 BrokerInfo (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.BrokerInfo)1 CancelProcessInstanceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CancelProcessInstanceRequest)1 CancelProcessInstanceResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CancelProcessInstanceResponse)1 CompleteJobRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest)1 CompleteJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse)1